From 1ba4748f125c32d51ed1b3b89188f34546c9136f Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sun, 22 Nov 2020 22:13:52 -0500 Subject: [PATCH] eja: check the (co)domain of each EJA operator. --- mjo/eja/eja_operator.py | 46 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/mjo/eja/eja_operator.py b/mjo/eja/eja_operator.py index 667e3d5..468a921 100644 --- a/mjo/eja/eja_operator.py +++ b/mjo/eja/eja_operator.py @@ -3,12 +3,48 @@ from sage.categories.all import FreeModules from sage.categories.map import Map class FiniteDimensionalEuclideanJordanAlgebraOperator(Map): + r""" + An operator between two finite-dimensional Euclidean Jordan algebras. + + SETUP:: + + sage: from mjo.eja.eja_algebra import HadamardEJA + sage: from mjo.eja.eja_operator import FiniteDimensionalEuclideanJordanAlgebraOperator + + EXAMPLES: + + The domain and codomain must be finite-dimensional Euclidean + Jordan algebras; if either is not, then an error is raised:: + + sage: J = HadamardEJA(3) + sage: V = VectorSpace(J.base_ring(), 3) + sage: M = matrix.identity(J.base_ring(), 3) + sage: FiniteDimensionalEuclideanJordanAlgebraOperator(V,J,M) + Traceback (most recent call last): + ... + TypeError: domain must be a finite-dimensional Euclidean + Jordan algebra + sage: FiniteDimensionalEuclideanJordanAlgebraOperator(J,V,M) + Traceback (most recent call last): + ... + TypeError: codomain must be a finite-dimensional Euclidean + Jordan algebra + + """ + def __init__(self, domain_eja, codomain_eja, mat): - # if not ( - # isinstance(domain_eja, FiniteDimensionalEuclideanJordanAlgebra) and - # isinstance(codomain_eja, FiniteDimensionalEuclideanJordanAlgebra) ): - # raise ValueError('(co)domains must be finite-dimensional Euclidean ' - # 'Jordan algebras') + from mjo.eja.eja_algebra import FiniteDimensionalEuclideanJordanAlgebra + + # I guess we should check this, because otherwise you could + # pass in pretty much anything algebraish. + if not isinstance(domain_eja, + FiniteDimensionalEuclideanJordanAlgebra): + raise TypeError('domain must be a finite-dimensional ' + 'Euclidean Jordan algebra') + if not isinstance(codomain_eja, + FiniteDimensionalEuclideanJordanAlgebra): + raise TypeError('codomain must be a finite-dimensional ' + 'Euclidean Jordan algebra') F = domain_eja.base_ring() if not (F == codomain_eja.base_ring()): -- 2.44.2