]> gitweb.michael.orlitzky.com - sage.d.git/blobdiff - mjo/eja/eja_algebra.py
eja: remove a completed TODO, and doctest it.
[sage.d.git] / mjo / eja / eja_algebra.py
index 811850586f21048aba1ed07292eaf51f15350fe1..3a832c1051694dc8e19d6c8dfb002ceda1203279 100644 (file)
@@ -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