From: Michael Orlitzky Date: Mon, 23 Nov 2020 03:13:52 +0000 (-0500) Subject: eja: check the (co)domain of each EJA operator. X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=1ba4748f125c32d51ed1b3b89188f34546c9136f;p=sage.d.git eja: check the (co)domain of each EJA operator. --- 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()):