X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;ds=sidebyside;f=mjo%2Feja%2Feja_utils.py;h=2402d9f0e5f6d1b174690688b8f9b2d7f17eba61;hb=44ef5b665217783bbeb05341476d6e02bbc44d4f;hp=430113d5cddaede7074ca9798f7f3f920a3e93ab;hpb=b0044b0f4a417ecbdf72a9d13b268fd7f94694de;p=sage.d.git diff --git a/mjo/eja/eja_utils.py b/mjo/eja/eja_utils.py index 430113d..2402d9f 100644 --- a/mjo/eja/eja_utils.py +++ b/mjo/eja/eja_utils.py @@ -58,6 +58,11 @@ def _all2list(x): EXAMPLES:: + sage: _all2list([[1]]) + [1] + + :: + sage: V1 = VectorSpace(QQ,2) sage: V2 = MatrixSpace(QQ,2) sage: x1 = V1([1,1]) @@ -81,6 +86,16 @@ def _all2list(x): sage: _all2list(OctonionMatrixAlgebra(1).one()) [1, 0, 0, 0, 0, 0, 0, 0] + :: + + sage: V1 = VectorSpace(QQ,2) + sage: V2 = OctonionMatrixAlgebra(1,field=QQ) + sage: C = cartesian_product([V1,V2]) + sage: x1 = V1([3,4]) + sage: y1 = V2.one() + sage: _all2list(C( (x1,y1) )) + [3, 4, 1, 0, 0, 0, 0, 0, 0, 0] + """ if hasattr(x, 'to_vector'): # This works on matrices of e.g. octonions directly, without @@ -96,9 +111,9 @@ def _all2list(x): except TypeError: # x is not iterable return [x] - if len(xl) == 1: + if xl == [x]: # Avoid the retardation of list(QQ(1)) == [1]. - return xl + return [x] return sum(list( map(_all2list, xl) ), [])