]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
eja: use hasattr() to avoid a try/except.
authorMichael Orlitzky <michael@orlitzky.com>
Fri, 12 Mar 2021 13:11:47 +0000 (08:11 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Fri, 12 Mar 2021 13:11:47 +0000 (08:11 -0500)
mjo/eja/eja_algebra.py

index 8e522527413b89c0e704687583dc9c4636303170..4a1c6f94f589c80b9021b71ee01693765aabcaeb 100644 (file)
@@ -779,13 +779,9 @@ class FiniteDimensionalEJA(CombinatorialFreeModule):
             if elt.parent().superalgebra() == self:
                 return elt.superalgebra_element()
 
-        try:
-            # Try to convert a vector into a column-matrix...
+        if hasattr(elt, 'column'):
+            # Convert a vector into a column-matrix...
             elt = elt.column()
-        except (AttributeError, TypeError):
-            # and ignore failure, because we weren't really expecting
-            # a vector as an argument anyway.
-            pass
 
         if elt not in self.matrix_space():
             raise ValueError(msg)