]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
eja: fix tests for new random_eja() structure.
authorMichael Orlitzky <michael@orlitzky.com>
Thu, 11 Mar 2021 00:40:26 +0000 (19:40 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Thu, 11 Mar 2021 00:40:26 +0000 (19:40 -0500)
mjo/eja/eja_algebra.py
mjo/eja/eja_element.py

index 70a150ab2d841d00c6576ee29f9fad275e2cca12..db1f4769ad84068903356bc119749ad90a64dc88 100644 (file)
@@ -1947,8 +1947,8 @@ class RealSymmetricEJA(MatrixEJA, RationalBasisEJA, ConcreteEJA):
     The dimension of this algebra is `(n^2 + n) / 2`::
 
         sage: set_random_seed()
-        sage: n_max = RealSymmetricEJA._max_random_instance_size()
-        sage: n = ZZ.random_element(1, n_max)
+        sage: d = RealSymmetricEJA._max_random_instance_dimension()
+        sage: n = RealSymmetricEJA._max_random_instance_size(d)
         sage: J = RealSymmetricEJA(n)
         sage: J.dimension() == (n^2 + n)/2
         True
@@ -1981,7 +1981,8 @@ class RealSymmetricEJA(MatrixEJA, RationalBasisEJA, ConcreteEJA):
     @staticmethod
     def _max_random_instance_size(max_dimension):
         # Obtained by solving d = (n^2 + n)/2.
-        return int(ZZ(8*max_dimension + 1).sqrt()/2 - 1/2)
+        # The ZZ-int-ZZ thing is just "floor."
+        return ZZ(int(ZZ(8*max_dimension + 1).sqrt()/2 - 1/2))
 
     @classmethod
     def random_instance(cls, max_dimension=None, **kwargs):
@@ -2053,8 +2054,8 @@ class ComplexHermitianEJA(MatrixEJA, RationalBasisEJA, ConcreteEJA):
     The dimension of this algebra is `n^2`::
 
         sage: set_random_seed()
-        sage: n_max = ComplexHermitianEJA._max_random_instance_size()
-        sage: n = ZZ.random_element(1, n_max)
+        sage: d = ComplexHermitianEJA._max_random_instance_dimension()
+        sage: n = ComplexHermitianEJA._max_random_instance_size(d)
         sage: J = ComplexHermitianEJA(n)
         sage: J.dimension() == n^2
         True
@@ -2104,7 +2105,8 @@ class ComplexHermitianEJA(MatrixEJA, RationalBasisEJA, ConcreteEJA):
     @staticmethod
     def _max_random_instance_size(max_dimension):
         # Obtained by solving d = n^2.
-        return int(ZZ(max_dimension).sqrt())
+        # The ZZ-int-ZZ thing is just "floor."
+        return ZZ(int(ZZ(max_dimension).sqrt()))
 
     @classmethod
     def random_instance(cls, max_dimension=None, **kwargs):
@@ -2143,8 +2145,8 @@ class QuaternionHermitianEJA(MatrixEJA, RationalBasisEJA, ConcreteEJA):
     The dimension of this algebra is `2*n^2 - n`::
 
         sage: set_random_seed()
-        sage: n_max = QuaternionHermitianEJA._max_random_instance_size()
-        sage: n = ZZ.random_element(1, n_max)
+        sage: d = QuaternionHermitianEJA._max_random_instance_dimension()
+        sage: n = QuaternionHermitianEJA._max_random_instance_size(d)
         sage: J = QuaternionHermitianEJA(n)
         sage: J.dimension() == 2*(n^2) - n
         True
@@ -2199,7 +2201,8 @@ class QuaternionHermitianEJA(MatrixEJA, RationalBasisEJA, ConcreteEJA):
         The maximum rank of a random QuaternionHermitianEJA.
         """
         # Obtained by solving d = 2n^2 - n.
-        return int(ZZ(8*max_dimension + 1).sqrt()/4 + 1/4)
+        # The ZZ-int-ZZ thing is just "floor."
+        return ZZ(int(ZZ(8*max_dimension + 1).sqrt()/4 + 1/4))
 
     @classmethod
     def random_instance(cls, max_dimension=None, **kwargs):
index c98d9a2b64651562928a6489ef88e03fdd2b0dc9..16e15e5d081447d9b5c046e88a02edfdf678f21c 100644 (file)
@@ -993,8 +993,8 @@ class FiniteDimensionalEJAElement(IndexedFreeModuleElement):
         two here so that said elements actually exist::
 
             sage: set_random_seed()
-            sage: n_max = max(2, JordanSpinEJA._max_random_instance_size())
-            sage: n = ZZ.random_element(2, n_max)
+            sage: d_max = JordanSpinEJA._max_random_instance_dimension()
+            sage: n = ZZ.random_element(2, max(2,d_max))
             sage: J = JordanSpinEJA(n)
             sage: y = J.random_element()
             sage: while y == y.coefficient(0)*J.one():
@@ -1019,8 +1019,8 @@ class FiniteDimensionalEJAElement(IndexedFreeModuleElement):
         and in particular, a re-scaling of the basis::
 
             sage: set_random_seed()
-            sage: n_max = RealSymmetricEJA._max_random_instance_size()
-            sage: n = ZZ.random_element(1, n_max)
+            sage: d_max = RealSymmetricEJA._max_random_instance_dimension()
+            sage: n = ZZ.random_element(1, d_max)
             sage: J1 = RealSymmetricEJA(n)
             sage: J2 = RealSymmetricEJA(n,orthonormalize=False)
             sage: X = random_matrix(AA,n)