X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=mjo%2Feja%2Feja_algebra.py;h=3a832c1051694dc8e19d6c8dfb002ceda1203279;hb=ee9ac102b8b392793466c13039a6e50b1e3c4c01;hp=811850586f21048aba1ed07292eaf51f15350fe1;hpb=667e0df9c07589c03616ad8cf42eebe5c86de50b;p=sage.d.git diff --git a/mjo/eja/eja_algebra.py b/mjo/eja/eja_algebra.py index 8118505..3a832c1 100644 --- a/mjo/eja/eja_algebra.py +++ b/mjo/eja/eja_algebra.py @@ -447,13 +447,23 @@ class FiniteDimensionalEJA(CombinatorialFreeModule): sage: J(x.to_vector().column()) == x True + We cannot coerce elements between algebras just because their + matrix representations are compatible:: + + sage: J1 = HadamardEJA(3) + sage: J2 = JordanSpinEJA(3) + sage: J2(J1.one()) + Traceback (most recent call last): + ... + ValueError: not an element of this algebra + sage: J1(J2.zero()) + Traceback (most recent call last): + ... + ValueError: not an element of this algebra + """ msg = "not an element of this algebra" - if elt == 0: - # The superclass implementation of random_element() - # needs to be able to coerce "0" into the algebra. - return self.zero() - elif elt in self.base_ring(): + if elt in self.base_ring(): # Ensure that no base ring -> algebra coercion is performed # by this method. There's some stupidity in sage that would # otherwise propagate to this method; for example, sage thinks @@ -461,9 +471,11 @@ class FiniteDimensionalEJA(CombinatorialFreeModule): raise ValueError(msg) try: + # Try to convert a vector into a column-matrix... elt = elt.column() except (AttributeError, TypeError): - # Try to convert a vector into a column-matrix + # and ignore failure, because we weren't really expecting + # a vector as an argument anyway. pass if elt not in self.matrix_space(): @@ -477,7 +489,7 @@ class FiniteDimensionalEJA(CombinatorialFreeModule): # could be QQ instead of QQbar. # # And, we also have to handle Cartesian product bases (when - # the matric basis consists of tuples) here. The "good news" + # the matrix basis consists of tuples) here. The "good news" # is that we're already converting everything to long vectors, # and that strategy works for tuples as well. # @@ -3133,9 +3145,3 @@ class CartesianProductEJA(CombinatorialFreeModule_CartesianProduct, FiniteDimensionalEJA.CartesianProduct = CartesianProductEJA random_eja = ConcreteEJA.random_instance -#def random_eja(*args, **kwargs): -# from sage.categories.cartesian_product import cartesian_product -# J1 = HadamardEJA(1, **kwargs) -# J2 = RealSymmetricEJA(2, **kwargs) -# J = cartesian_product([J1,J2]) -# return J