X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=mjo%2Feja%2Feja_algebra.py;h=3a832c1051694dc8e19d6c8dfb002ceda1203279;hb=ee9ac102b8b392793466c13039a6e50b1e3c4c01;hp=618e09cf41d58eec7ade00aca846eb9677f468ae;hpb=21fa036e86711c6c28b6d89af2b1bfe4ceb24b29;p=sage.d.git diff --git a/mjo/eja/eja_algebra.py b/mjo/eja/eja_algebra.py index 618e09c..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. #