From 046d2b5d664f7b6794e81e7ebf0fb224c0c3d52c Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 10 Mar 2021 19:40:26 -0500 Subject: [PATCH] eja: fix tests for new random_eja() structure. --- mjo/eja/eja_algebra.py | 21 ++++++++++++--------- mjo/eja/eja_element.py | 8 ++++---- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/mjo/eja/eja_algebra.py b/mjo/eja/eja_algebra.py index 70a150a..db1f476 100644 --- a/mjo/eja/eja_algebra.py +++ b/mjo/eja/eja_algebra.py @@ -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): diff --git a/mjo/eja/eja_element.py b/mjo/eja/eja_element.py index c98d9a2..16e15e5 100644 --- a/mjo/eja/eja_element.py +++ b/mjo/eja/eja_element.py @@ -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) -- 2.44.2