]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
mjo/misc.py: special case for Sage's octonions in _all2list()
authorMichael Orlitzky <michael@orlitzky.com>
Thu, 9 Apr 2026 00:09:32 +0000 (20:09 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Thu, 9 Apr 2026 00:30:35 +0000 (20:30 -0400)
These have vector(), not to_vector().

mjo/misc.py

index f4406a1aaec2a390e3e077157593d3e0d8e728fe..31e77b4d307a86c8daa57643ddcfd3801b9889cb 100644 (file)
@@ -16,7 +16,6 @@ def _all2list(x):
 
         sage: from mjo.misc import _all2list
         sage: from mjo.hurwitz import (QuaternionMatrixAlgebra,
-        ....:                          Octonions,
         ....:                          OctonionMatrixAlgebra)
 
     EXAMPLES::
@@ -44,7 +43,7 @@ def _all2list(x):
 
     ::
 
-        sage: _all2list(Octonions().one())
+        sage: _all2list(OctonionAlgebra(QQ).one())
         [1, 0, 0, 0, 0, 0, 0, 0]
         sage: _all2list(OctonionMatrixAlgebra(1).one())
         [1, 0, 0, 0, 0, 0, 0, 0]
@@ -67,6 +66,10 @@ def _all2list(x):
         [3, 4, 1, 0, 0, 0, 0, 0, 0, 0]
 
     """
+    if hasattr(x, 'vector'):
+        # Works on octonions, which have vector() but not to_vector().
+        return x.vector().list()
+
     if hasattr(x, 'to_vector'):
         # This works on matrices of e.g. octonions directly, without
         # first needing to convert them to a list of octonions and