]> gitweb.michael.orlitzky.com - sage.d.git/blobdiff - mjo/eja/eja_algebra.py
eja: split "check" args into check_field and check_axioms.
[sage.d.git] / mjo / eja / eja_algebra.py
index 4bef201cd2d0bbda251dbfd347cd9006185d82a5..26fe1929be872b393fe41926eeda801dbd0a9436 100644 (file)
@@ -57,7 +57,8 @@ class FiniteDimensionalEuclideanJordanAlgebra(CombinatorialFreeModule):
                  prefix='e',
                  category=None,
                  natural_basis=None,
-                 check=True):
+                 check_field=True,
+                 check_axioms=True):
         """
         SETUP::
 
@@ -78,14 +79,14 @@ class FiniteDimensionalEuclideanJordanAlgebra(CombinatorialFreeModule):
 
         TESTS:
 
-        The ``field`` we're given must be real with ``check=True``::
+        The ``field`` we're given must be real with ``check_field=True``::
 
             sage: JordanSpinEJA(2,QQbar)
             Traceback (most recent call last):
             ...
-            ValueError: field is not real
+            ValueError: scalar field is not real
 
-        The multiplication table must be square with ``check=True``::
+        The multiplication table must be square with ``check_axioms=True``::
 
             sage: FiniteDimensionalEuclideanJordanAlgebra(QQ,((),()))
             Traceback (most recent call last):
@@ -93,12 +94,18 @@ class FiniteDimensionalEuclideanJordanAlgebra(CombinatorialFreeModule):
             ValueError: multiplication table is not square
 
         """
-        if check:
+        if check_field:
             if not field.is_subring(RR):
                 # Note: this does return true for the real algebraic
-                # field, and any quadratic field where we've specified
-                # a real embedding.
-                raise ValueError('field is not real')
+                # field, the rationals, and any quadratic field where
+                # we've specified a real embedding.
+                raise ValueError("scalar field is not real")
+
+        # The multiplication table had better be square
+        n = len(mult_table)
+        if check_axioms:
+            if not all( len(l) == n for l in mult_table ):
+                raise ValueError("multiplication table is not square")
 
         self._natural_basis = natural_basis
 
@@ -106,12 +113,6 @@ class FiniteDimensionalEuclideanJordanAlgebra(CombinatorialFreeModule):
             category = MagmaticAlgebras(field).FiniteDimensional()
             category = category.WithBasis().Unital()
 
-        # The multiplication table had better be square
-        n = len(mult_table)
-        if check:
-            if not all( len(l) == n for l in mult_table ):
-                raise ValueError("multiplication table is not square")
-
         fda = super(FiniteDimensionalEuclideanJordanAlgebra, self)
         fda.__init__(field,
                      range(n),
@@ -130,7 +131,7 @@ class FiniteDimensionalEuclideanJordanAlgebra(CombinatorialFreeModule):
             for ls in mult_table
         ]
 
-        if check:
+        if check_axioms:
             if not self._is_commutative():
                 raise ValueError("algebra is not commutative")
             if not self._is_jordanian():
@@ -263,8 +264,8 @@ class FiniteDimensionalEuclideanJordanAlgebra(CombinatorialFreeModule):
         Whether or not this algebra's multiplication table is commutative.
 
         This method should of course always return ``True``, unless
-        this algebra was constructed with ``check=False`` and passed
-        an invalid multiplication table.
+        this algebra was constructed with ``check_axioms=False`` and
+        passed an invalid multiplication table.
         """
         return all( self.product_on_basis(i,j) == self.product_on_basis(i,j)
                     for i in range(self.dimension())
@@ -279,7 +280,7 @@ class FiniteDimensionalEuclideanJordanAlgebra(CombinatorialFreeModule):
         ``True`` result to be truly true, you should also check
         :meth:`_is_commutative`. This method should of course always
         return ``True``, unless this algebra was constructed with
-        ``check=False`` and passed an invalid multiplication table.
+        ``check_axioms=False`` and passed an invalid multiplication table.
         """
         return all( (self.monomial(i)**2)*(self.monomial(i)*self.monomial(j))
                     ==
@@ -293,13 +294,13 @@ class FiniteDimensionalEuclideanJordanAlgebra(CombinatorialFreeModule):
         associative; that is, whether or not `B(xy,z) = B(x,yz)`.
 
         This method should of course always return ``True``, unless
-        this algebra was constructed with ``check=False`` and passed
-        an invalid multiplication table.
+        this algebra was constructed with ``check_axioms=False`` and
+        passed an invalid multiplication table.
         """
 
         # Used to check whether or not something is zero in an inexact
         # ring. This number is sufficient to allow the construction of
-        # QuaternionHermitianEJA(2, RDF) with check=True.
+        # QuaternionHermitianEJA(2, RDF) with check_axioms=True.
         epsilon = 1e-16
 
         for i in range(self.dimension()):
@@ -747,7 +748,7 @@ class FiniteDimensionalEuclideanJordanAlgebra(CombinatorialFreeModule):
                 gens = tuple( self.from_vector(b) for b in eigspace.basis() )
                 subalg = FiniteDimensionalEuclideanJordanSubalgebra(self,
                                                                     gens,
-                                                                    check=False)
+                                                                    check_axioms=False)
                 if eigval == 0:
                     J0 = subalg
                 elif eigval == 1:
@@ -1053,7 +1054,7 @@ class HadamardEJA(FiniteDimensionalEuclideanJordanAlgebra):
 
         super(HadamardEJA, self).__init__(field,
                                           mult_table,
-                                          check=False,
+                                          check_axioms=False,
                                           **kwargs)
         self.rank.set_cache(n)
 
@@ -1165,13 +1166,14 @@ class MatrixEuclideanJordanAlgebra(FiniteDimensionalEuclideanJordanAlgebra):
 
             # Do this over the rationals and convert back at the end.
             # Only works because we know the entries of the basis are
-            # integers. The argument ``check=False`` is required
+            # integers. The argument ``check_axioms=False`` is required
             # because the trace inner-product method for this
             # class is a stub and can't actually be checked.
             J = MatrixEuclideanJordanAlgebra(QQ,
                                              basis,
                                              normalize_basis=False,
-                                             check=False)
+                                             check_field=False,
+                                             check_axioms=False)
             a = J._charpoly_coefficients()
 
             # Unfortunately, changing the basis does change the
@@ -1411,7 +1413,7 @@ class RealSymmetricEJA(RealMatrixEuclideanJordanAlgebra):
         basis = self._denormalized_basis(n, field)
         super(RealSymmetricEJA, self).__init__(field,
                                                basis,
-                                               check=False,
+                                               check_axioms=False,
                                                **kwargs)
         self.rank.set_cache(n)
 
@@ -1710,7 +1712,7 @@ class ComplexHermitianEJA(ComplexMatrixEuclideanJordanAlgebra):
         basis = self._denormalized_basis(n,field)
         super(ComplexHermitianEJA,self).__init__(field,
                                                  basis,
-                                                 check=False,
+                                                 check_axioms=False,
                                                  **kwargs)
         self.rank.set_cache(n)
 
@@ -2014,7 +2016,7 @@ class QuaternionHermitianEJA(QuaternionMatrixEuclideanJordanAlgebra):
         basis = self._denormalized_basis(n,field)
         super(QuaternionHermitianEJA,self).__init__(field,
                                                     basis,
-                                                    check=False,
+                                                    check_axioms=False,
                                                     **kwargs)
         self.rank.set_cache(n)
 
@@ -2100,7 +2102,7 @@ class BilinearFormEJA(FiniteDimensionalEuclideanJordanAlgebra):
         # by the ambient dimension).
         super(BilinearFormEJA, self).__init__(field,
                                               mult_table,
-                                              check=False,
+                                              check_axioms=False,
                                               **kwargs)
         self.rank.set_cache(min(n,2))
 
@@ -2229,7 +2231,7 @@ class TrivialEJA(FiniteDimensionalEuclideanJordanAlgebra):
         mult_table = []
         super(TrivialEJA, self).__init__(field,
                                          mult_table,
-                                         check=False,
+                                         check_axioms=False,
                                          **kwargs)
         # The rank is zero using my definition, namely the dimension of the
         # largest subalgebra generated by any element.
@@ -2280,6 +2282,6 @@ class DirectSumEJA(FiniteDimensionalEuclideanJordanAlgebra):
 
         super(DirectSumEJA, self).__init__(field,
                                            mult_table,
-                                           check=False,
+                                           check_axioms=False,
                                            **kwargs)
         self.rank.set_cache(J1.rank() + J2.rank())