99  Jordan algebra 
1010""" 
1111
12- #** *************************************************************************** 
12+ #  *************************************************************************** 
1313#  Copyright (C) 2014, 2023 Travis Scrimshaw <tscrim at ucdavis.edu> 
1414# 
1515#  Distributed under the terms of the GNU General Public License (GPL) 
1616#                  https://www.gnu.org/licenses/ 
17- #** *************************************************************************** 
17+ #  *************************************************************************** 
1818
1919from  sage .structure .parent  import  Parent 
2020from  sage .structure .unique_representation  import  UniqueRepresentation 
@@ -209,7 +209,7 @@ def __classcall_private__(self, arg0, arg1=None, names=None):
209209        if  not  arg1 .is_symmetric ():
210210            raise  ValueError ("the bilinear form is not symmetric" )
211211
212-         arg1  =  arg1 .change_ring (arg0 ) # This makes a copy 
212+         arg1  =  arg1 .change_ring (arg0 )   # This makes a copy 
213213        arg1 .set_immutable ()
214214        return  JordanAlgebraSymmetricBilinear (arg0 , arg1 , names = names )
215215
@@ -311,7 +311,7 @@ def _an_element_(self):
311311        return  self .element_class (self , self ._A .an_element ())
312312
313313    @cached_method  
314-     def  basis (self ):
314+     def  basis (self )  ->   Family :
315315        """ 
316316        Return the basis of ``self``. 
317317
@@ -323,19 +323,13 @@ def basis(self):
323323            Lazy family (Term map(i))_{i in Free monoid on 3 generators (x, y, z)} 
324324        """ 
325325        B  =  self ._A .basis ()
326-         return  Family (B .keys (), lambda  x : self .element_class (self , B [x ]), name = "Term map" )
326+         return  Family (B .keys (),
327+                       lambda  x : self .element_class (self , B [x ]), name = "Term map" )
327328
328-     def  algebra_generators (self ):
329-         B  =  self ._A .basis ()
330-         K  =  B .keys ()
331-         try :
332-             len (K )
333-         except  NotImplementedError :
334-             raise  NotImplementedError ("infinite set" )
335-         return  Family (K , lambda  x : self .element_class (self , B [x ]), name = "Term map" )
329+     algebra_generators  =  basis 
336330
337331    # TODO: Keep this until we can better handle R.<...> shorthand 
338-     def  gens (self ) ->  tuple :
332+     def  gens (self ) ->  Family :
339333        """ 
340334        Return the generators of ``self``. 
341335
@@ -345,22 +339,14 @@ def gens(self) -> tuple:
345339            sage: C = CombinatorialFreeModule(QQ, ['x','y','z'], category=cat) 
346340            sage: J = JordanAlgebra(C) 
347341            sage: J.gens() 
348-             ( B['x'], B['y'], B['z'])  
342+             Finite family {'x':  B['x'], 'y':  B['y'], 'z':  B['z']}  
349343
350344            sage: F.<x,y,z> = FreeAlgebra(QQ) 
351345            sage: J = JordanAlgebra(F) 
352346            sage: J.gens() 
353-             Traceback (most recent call last): 
354-             ... 
355-             NotImplementedError: infinite set 
347+             Lazy family (Term map(i))_{i in Free monoid on 3 generators (x, y, z)} 
356348        """ 
357-         G  =  self .algebra_generators ()
358-         # If G is infinite, len(G) will raise NotImplementedError('infinite set') 
359-         try :
360-             len (G )
361-         except  NotImplementedError :
362-             raise 
363-         return  tuple (G )
349+         return  self .algebra_generators ()
364350
365351    @cached_method  
366352    def  zero (self ):
@@ -754,7 +740,7 @@ def _coerce_map_from_base_ring(self):
754740        return  self ._generic_coerce_map (self .base_ring ())
755741
756742    @cached_method  
757-     def  basis (self ):
743+     def  basis (self )  ->   Family :
758744        """ 
759745        Return a basis of ``self``. 
760746
@@ -776,7 +762,7 @@ def basis(self):
776762
777763    algebra_generators  =  basis 
778764
779-     def  gens (self ) ->  tuple :
765+     def  gens (self ) ->  Family :
780766        """ 
781767        Return the generators of ``self``. 
782768
@@ -785,9 +771,9 @@ def gens(self) -> tuple:
785771            sage: m = matrix([[0,1],[1,1]]) 
786772            sage: J = JordanAlgebra(m) 
787773            sage: J.gens() 
788-             (1 + (0, 0), 0 + (1, 0), 0 + (0, 1)) 
774+             Family  (1 + (0, 0), 0 + (1, 0), 0 + (0, 1)) 
789775        """ 
790-         return  tuple ( self .algebra_generators () )
776+         return  self .algebra_generators ()
791777
792778    @cached_method  
793779    def  zero (self ):
@@ -987,7 +973,7 @@ def _mul_(self, other):
987973            P  =  self .parent ()
988974            return  self .__class__ (P ,
989975                                  self ._s  *  other ._s 
990-                                     +  (self ._v  *  P ._form  *  other ._v .column ())[0 ],
976+                                   +  (self ._v  *  P ._form  *  other ._v .column ())[0 ],
991977                                  other ._s  *  self ._v  +  self ._s  *  other ._v )
992978
993979        def  _lmul_ (self , other ):
@@ -1036,8 +1022,8 @@ def monomial_coefficients(self, copy=True):
10361022                {0: 1, 1: 2, 2: -1} 
10371023            """ 
10381024            d  =  {0 : self ._s }
1039-             for  i ,c  in  enumerate (self ._v ):
1040-                 d [i + 1 ] =  c 
1025+             for  i ,  c  in  enumerate (self ._v ):
1026+                 d [i   +   1 ] =  c 
10411027            return  d 
10421028
10431029        def  trace (self ):
@@ -1271,8 +1257,8 @@ def _test_multiplication_self_adjoint(self, **options):
12711257                 [SD [3 ].conjugate (), SD [1 ], SD [5 ]],
12721258                 [SD [4 ].conjugate (), SD [5 ].conjugate (), SD [2 ]]]
12731259            Y  =  [[OD [0 ], OD [3 ], OD [4 ]],
1274-                    [OD [3 ].conjugate (), OD [1 ], OD [5 ]],
1275-                    [OD [4 ].conjugate (), OD [5 ].conjugate (), OD [2 ]]]
1260+                  [OD [3 ].conjugate (), OD [1 ], OD [5 ]],
1261+                  [OD [4 ].conjugate (), OD [5 ].conjugate (), OD [2 ]]]
12761262            for  r , c  in  data_pairs :
12771263                if  r  !=  c :
12781264                    val  =  sum (X [r ][i ] *  Y [i ][c ] +  Y [r ][i ] *  X [i ][c ] for  i  in  range (3 )) *  self ._half 
@@ -1283,7 +1269,7 @@ def _test_multiplication_self_adjoint(self, **options):
12831269                    tester .assertEqual (val .imag_part (), zerO )
12841270
12851271    @cached_method  
1286-     def  basis (self ):
1272+     def  basis (self )  ->   Family :
12871273        r""" 
12881274        Return a basis of ``self``. 
12891275
@@ -1328,7 +1314,7 @@ def basis(self):
13281314
13291315    algebra_generators  =  basis 
13301316
1331-     def  gens (self ) ->  tuple :
1317+     def  gens (self ) ->  Family :
13321318        """ 
13331319        Return the generators of ``self``. 
13341320
@@ -1350,7 +1336,7 @@ def gens(self) -> tuple:
13501336            [ 0  0  k] 
13511337            [ 0 -k  0] 
13521338        """ 
1353-         return  tuple ( self .algebra_generators () )
1339+         return  self .basis ( )
13541340
13551341    @cached_method  
13561342    def  zero (self ):
@@ -1697,8 +1683,8 @@ def _mul_(self, other):
16971683                 [SD [3 ].conjugate (), SD [1 ], SD [5 ]],
16981684                 [SD [4 ].conjugate (), SD [5 ].conjugate (), SD [2 ]]]
16991685            Y  =  [[OD [0 ], OD [3 ], OD [4 ]],
1700-                    [OD [3 ].conjugate (), OD [1 ], OD [5 ]],
1701-                    [OD [4 ].conjugate (), OD [5 ].conjugate (), OD [2 ]]]
1686+                  [OD [3 ].conjugate (), OD [1 ], OD [5 ]],
1687+                  [OD [4 ].conjugate (), OD [5 ].conjugate (), OD [2 ]]]
17021688            # we do a simplified multiplication for the diagonal entries since 
17031689            # we have, e.g., \alpha * \alpha' + (x (x')^* + x' x^* + y (y')^* + y' y^*) / 2 
17041690            ret  =  [X [0 ][0 ] *  Y [0 ][0 ] +  (X [0 ][1 ] *  Y [1 ][0 ]).real_part () +  (X [0 ][2 ] *  Y [2 ][0 ]).real_part (),
0 commit comments