From 3940dadefa5ede86fd81917ace7d145e4d3f0da9 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Thu, 25 Feb 2021 21:20:58 -0500 Subject: [PATCH] eja: simplify some calls to super(...). --- mjo/eja/TODO | 2 -- mjo/eja/eja_algebra.py | 60 ++++++++++++++++++++--------------------- mjo/eja/eja_operator.py | 3 +-- 3 files changed, 31 insertions(+), 34 deletions(-) diff --git a/mjo/eja/TODO b/mjo/eja/TODO index 7dd4788..90a49d3 100644 --- a/mjo/eja/TODO +++ b/mjo/eja/TODO @@ -14,5 +14,3 @@ sage: a0 = (1/4)*X[4]**2*X[6]**2 - (1/2)*X[2]*X[5]*X[6]**2 - (1/2)*X[3]*X[4]*X[6 5. Profile the construction of "large" matrix algebras (like the 15-dimensional QuaternionHermitianAlgebra(3)) to find out why they're so slow. - -6. Use super() where it works. diff --git a/mjo/eja/eja_algebra.py b/mjo/eja/eja_algebra.py index 40b4bca..ad4e2c7 100644 --- a/mjo/eja/eja_algebra.py +++ b/mjo/eja/eja_algebra.py @@ -1994,11 +1994,11 @@ class RealSymmetricEJA(ConcreteEJA, RealMatrixEJA): if n <= 1: associative = True - super(RealSymmetricEJA, self).__init__(self._denormalized_basis(n), - self.jordan_product, - self.trace_inner_product, - associative=associative, - **kwargs) + super().__init__(self._denormalized_basis(n), + self.jordan_product, + self.trace_inner_product, + associative=associative, + **kwargs) # TODO: this could be factored out somehow, but is left here # because the MatrixEJA is not presently a subclass of the @@ -2088,7 +2088,7 @@ class ComplexMatrixEJA(MatrixEJA): True """ - super(ComplexMatrixEJA,cls).real_embed(M) + super().real_embed(M) n = M.nrows() # We don't need any adjoined elements... @@ -2135,7 +2135,7 @@ class ComplexMatrixEJA(MatrixEJA): True """ - super(ComplexMatrixEJA,cls).real_unembed(M) + super().real_unembed(M) n = ZZ(M.nrows()) d = cls.dimension_over_reals() F = cls.complex_extension(M.base_ring()) @@ -2287,11 +2287,11 @@ class ComplexHermitianEJA(ConcreteEJA, ComplexMatrixEJA): if n <= 1: associative = True - super(ComplexHermitianEJA, self).__init__(self._denormalized_basis(n), - self.jordan_product, - self.trace_inner_product, - associative=associative, - **kwargs) + super().__init__(self._denormalized_basis(n), + self.jordan_product, + self.trace_inner_product, + associative=associative, + **kwargs) # TODO: this could be factored out somehow, but is left here # because the MatrixEJA is not presently a subclass of the # FDEJA class that defines rank() and one(). @@ -2374,7 +2374,7 @@ class QuaternionMatrixEJA(MatrixEJA): True """ - super(QuaternionMatrixEJA,cls).real_embed(M) + super().real_embed(M) quaternions = M.base_ring() n = M.nrows() @@ -2429,7 +2429,7 @@ class QuaternionMatrixEJA(MatrixEJA): True """ - super(QuaternionMatrixEJA,cls).real_unembed(M) + super().real_unembed(M) n = ZZ(M.nrows()) d = cls.dimension_over_reals() @@ -2598,11 +2598,11 @@ class QuaternionHermitianEJA(ConcreteEJA, QuaternionMatrixEJA): if n <= 1: associative = True - super(QuaternionHermitianEJA, self).__init__(self._denormalized_basis(n), - self.jordan_product, - self.trace_inner_product, - associative=associative, - **kwargs) + super().__init__(self._denormalized_basis(n), + self.jordan_product, + self.trace_inner_product, + associative=associative, + **kwargs) # TODO: this could be factored out somehow, but is left here # because the MatrixEJA is not presently a subclass of the @@ -2835,11 +2835,11 @@ class BilinearFormEJA(ConcreteEJA): if n <= 2: associative = True - super(BilinearFormEJA, self).__init__(column_basis, - jordan_product, - inner_product, - associative=associative, - **kwargs) + super().__init__(column_basis, + jordan_product, + inner_product, + associative=associative, + **kwargs) # The rank of this algebra is two, unless we're in a # one-dimensional ambient space (because the rank is bounded @@ -2944,7 +2944,7 @@ class JordanSpinEJA(BilinearFormEJA): # But also don't pass check_field=False here, because the user # can pass in a field! - super(JordanSpinEJA, self).__init__(B, **kwargs) + super().__init__(B, **kwargs) @staticmethod def _max_random_instance_size(): @@ -3002,11 +3002,11 @@ class TrivialEJA(ConcreteEJA): if "orthonormalize" not in kwargs: kwargs["orthonormalize"] = False if "check_axioms" not in kwargs: kwargs["check_axioms"] = False - super(TrivialEJA, self).__init__(basis, - jordan_product, - inner_product, - associative=True, - **kwargs) + super().__init__(basis, + jordan_product, + inner_product, + associative=True, + **kwargs) # The rank is zero using my definition, namely the dimension of the # largest subalgebra generated by any element. diff --git a/mjo/eja/eja_operator.py b/mjo/eja/eja_operator.py index 75a0820..4d24b35 100644 --- a/mjo/eja/eja_operator.py +++ b/mjo/eja/eja_operator.py @@ -272,8 +272,7 @@ class FiniteDimensionalEJAOperator(Map): # This should eventually delegate to _composition_ after performing # some sanity checks for us. - mor = super(FiniteDimensionalEJAOperator,self) - return mor.__mul__(other) + return super().__mul__(other) def _neg_(self): -- 2.43.2