Is there a way to run those same examples from Python or do they need
to be run from the SageMath application?
$ ./sage -python
Python 3.9.6 (default, Jun 29 2021, 05:25:02)
[Clang 12.0.5 (clang-1205.0.22.9)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
from sage.all import var, cos, sin, matrix, pi
>>> x, y = var('x y')
>>> M = matrix([[sin(x), cos(x)], [-cos(x), sin(x)]]); M
[ sin(x) cos(x)]
[-cos(x) sin(x)]
>>> sM = M._sympy_(); sM
Matrix([
[ sin(x), cos(x)],
[-cos(x), sin(x)]])
>>> sM.subs(x, pi/4) # computation in SymPy
Matrix([
[ sqrt(2)/2, sqrt(2)/2],
[-sqrt(2)/2, sqrt(2)/2]])
>>> from sage.all import WeylGroup
>>> W = WeylGroup(["A",1,1])
>>> sW = W._sympy_(); sW
SageSet(Weyl Group of type ['A', 1, 1] (as a matrix group acting on the root space))
>>> sW.is_finite_set
False
>>> sW.is_iterable
True
>>> sB3 = WeylGroup(["B", 3])._sympy_(); sB3
SageSet(Weyl Group of type ['B', 3] (as a matrix group acting on the ambient space))
>>> len(sB3)
48
Also since SymPy switched from Travis to GitHub Actions for CI I
haven't figured out how to make a setup that tests the latest master
SymPy as part of Sage. Currently I don't think we have any CI tests
for this. Do you have an idea how to set that up?
sage: from sage.all import WeylGroup
sage: W = WeylGroup(["A",1,1])
Assertion failed: ((STATE_SLOTS_SIZE - StateNextFreeOffset) >= size), function RegisterModuleState, file src/modules.c, line 106.
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
/var/tmp/sage-9.4-current/local/lib/python3.9/site-packages/sage/misc/cachefunc.pyx in sage.misc.cachefunc.CachedFunction.__call__ (build/cythonized/sage/misc/cachefunc.c:5974)()
995 try:
--> 996 return self.cache[k]
997 except TypeError: # k is not hashable
/var/tmp/sage-9.4-current/local/lib/python3.9/site-packages/sage/misc/weak_dict.pyx in sage.misc.weak_dict.WeakValueDictionary.__getitem__ (build/cythonized/sage/misc/weak_dict.c:3736)()
703 if wr == NULL:
--> 704 raise KeyError(k)
705 out = PyWeakref_GetObject(wr)
KeyError: ((<class 'sage.combinat.root_system.weyl_group.WeylGroup_gens'>, Root space over the Rational Field of the Root system of type ['A', 1, 1], None), ())
During handling of the above exception, another exception occurred:
RuntimeError Traceback (most recent call last)
<ipython-input-37-3528b02e71d0> in <module>
----> 1 W = WeylGroup(["A",Integer(1),Integer(1)])
/var/tmp/sage-9.4-current/local/lib/python3.9/site-packages/sage/misc/lazy_import.pyx in sage.misc.lazy_import.LazyImport.__call__ (build/cythonized/sage/misc/lazy_import.c:4036)()
360 True
361 """
--> 362 return self.get_object()(*args, **kwds)
363
364 def __repr__(self):
/var/tmp/sage-9.4-current/local/lib/python3.9/site-packages/sage/combinat/root_system/weyl_group.py in WeylGroup(x, prefix, implementation)
207 if ct.is_finite():
208 return WeylGroup_gens(ct.root_system().ambient_space(), prefix=prefix)
--> 209 return WeylGroup_gens(ct.root_system().root_space(), prefix=prefix)
210
211
/var/tmp/sage-9.4-current/local/lib/python3.9/site-packages/sage/misc/classcall_metaclass.pyx in sage.misc.classcall_metaclass.ClasscallMetaclass.__call__ (build/cythonized/sage/misc/classcall_metaclass.c:1761)()
320 """
321 if cls.classcall is not None:
--> 322 return cls.classcall(cls, *args, **kwds)
323 else:
324 # Fast version of type.__call__(cls, *args, **kwds)
/var/tmp/sage-9.4-current/local/lib/python3.9/site-packages/sage/combinat/root_system/weyl_group.py in __classcall__(cls, domain, prefix)
215 @staticmethod
216 def __classcall__(cls, domain, prefix=None):
--> 217 return super(WeylGroup_gens, cls).__classcall__(cls, domain, prefix)
218
219 def __init__(self, domain, prefix):
/var/tmp/sage-9.4-current/local/lib/python3.9/site-packages/sage/misc/cachefunc.pyx in sage.misc.cachefunc.CachedFunction.__call__ (build/cythonized/sage/misc/cachefunc.c:6100)()
999 return self.cache[k]
1000 except KeyError:
-> 1001 w = self.f(*args, **kwds)
1002 self.cache[k] = w
1003 return w
/var/tmp/sage-9.4-current/local/lib/python3.9/site-packages/sage/structure/unique_representation.py in __classcall__(cls, *args, **options)
1005 True
1006 """
-> 1007 instance = typecall(cls, *args, **options)
1008 assert isinstance( instance, cls )
1009 if instance.__class__.__reduce__ == CachedRepresentation.__reduce__:
/var/tmp/sage-9.4-current/local/lib/python3.9/site-packages/sage/misc/classcall_metaclass.pyx in sage.misc.classcall_metaclass.typecall (build/cythonized/sage/misc/classcall_metaclass.c:2223)()
484 TypeError: Argument 'cls' has incorrect type (expected type, got classobj)
485 """
--> 486 return (<PyTypeObject*>type).tp_call(cls, args, kwds)
487
488 # Class for timing::
/var/tmp/sage-9.4-current/local/lib/python3.9/site-packages/sage/combinat/root_system/weyl_group.py in __init__(self, domain, prefix)
243 for i in self.index_set()]
244 from sage.libs.all import libgap
--> 245 libgap_group = libgap.Group(gens_matrix)
246 degree = ZZ(self.domain().dimension())
247 ring = self.domain().base_ring()
/var/tmp/sage-9.4-current/local/lib/python3.9/site-packages/sage/libs/gap/libgap.pyx in sage.libs.gap.libgap.Gap.__getattr__ (build/cythonized/sage/libs/gap/libgap.c:6806)()
698
699 try:
--> 700 g = self.eval(name)
701 except ValueError:
702 raise AttributeError(f'No such attribute: {name}.')
/var/tmp/sage-9.4-current/local/lib/python3.9/site-packages/sage/libs/gap/libgap.pyx in sage.libs.gap.libgap.Gap.eval (build/cythonized/sage/libs/gap/libgap.c:4241)()
397 gap_command = str(gap_command._libgap_init_())
398
--> 399 initialize()
400 elem = make_any_gap_element(self, gap_eval(gap_command))
401
/var/tmp/sage-9.4-current/local/lib/python3.9/site-packages/sage/libs/gap/util.pyx in sage.libs.gap.util.initialize (build/cythonized/sage/libs/gap/util.c:5619)()
287 argv[argc] = NULL
288
--> 289 sig_on()
290 # Initialize GAP but disable their SIGINT handler
291 GAP_Initialize(argc, argv, gasman_callback, error_handler,
RuntimeError: Aborted
--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/0326a9eb-9dac-4a6d-b928-42e830410b06n%40googlegroups.com.
I just downloaded SageMath 9.4 on OSX from here:
https://github.com/3-manifolds/Sage_macOS/releasesI ran most of the examples fine but there was a problem with the Weyl group example:sage: from sage.all import WeylGroup
sage: W = WeylGroup(["A",1,1])
Assertion failed: ((STATE_SLOTS_SIZE - StateNextFreeOffset) >= size), function RegisterModuleState, file src/modules.c, line 106.
From the page: "also, Sage attaches _sage_ methods to various SymPy
classes, which provide the opposite conversion."
SymPy also has various _sage_ methods, but mainly only in the core.
Should we keep these in SymPy? It sounds like you are already adding a
bunch of your own, so maybe we should just move them all to the sage
codebase. We could also move them all to the SymPy codebase too, if
that sounds more preferable. I would assume having them in Sage is
better