Replies: 2 comments 3 replies
-
NotImplemented should be returned |
Beta Was this translation helpful? Give feedback.
3 replies
-
Unfortunately NotImplemented is not returned. Here is what I get: Type "help", "copyright", "credits" or "license" for more information.
>>> from octonion import *
>>> (4+5j)*a
octonion(4.0*a0 - 5.0*a1, 5.0*a0 + 4.0*a1, 4.0*a2 - 5.0*a3, 5.0*a2 + 4.0*a3, 4.0*a4 - 5.0*a5, 5.0*a4 + 4.0*a5, 4.0*a6 + 5.0*a7, -5.0*a6 + 4.0*a7)
>>> Quaternion(1,2,3)*a
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.11/site-packages/sympy/algebras/quaternion.py", line 680, in __mul__
return self._generic_mul(self, _sympify(other))
^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/sympy/core/sympify.py", line 528, in _sympify
return sympify(a, strict=True)
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/sympy/core/sympify.py", line 449, in sympify
raise SympifyError(a)
sympy.core.sympify.SympifyError: SympifyError: octonion(a0, a1, a2, a3, a4, a5, a6, a7)
>``` |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
My code for the class Octonion in modul octonion.py octonion.zip uses class Quaternion in sympy. If
a
is an instance of Octonion andb
an instance of Quaternion, thena*b
is correctly evaluated asa.__mul__(b)
. Butb*a
doesn't do what it should do: I getSympifyError
sinceb*a
is resolved asb.__mul__(a)
and Quaternions don't know Octonions.Is there any idea to solve this problem? Of course I don't want change sympy. Is it possible that for an Octonion
a
Quaternion.__mul__(self,a)
returns a NotImplemented instead of stopping with a SympifyError?Beta Was this translation helpful? Give feedback.
All reactions