Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError when creating a zero map from a zero dimensional vector space to a positive dimensional vector space #12412

Closed
sagetrac-JStarx mannequin opened this issue Feb 1, 2012 · 3 comments

Comments

@sagetrac-JStarx
Copy link
Mannequin

sagetrac-JStarx mannequin commented Feb 1, 2012

sage: V = GF(3)^0
sage: W = GF(3)^1
sage: H = V.Hom(W)
sage: H.zero_element()
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (398, 0))

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

[snip]

/Users/Starx/sage/local/lib/python2.6/site-packages/sage/categories/modules.pyc in zero(self)
    205                     True
    206                 """
--> 207                 return self(lambda x: self.codomain().zero())
    208 
    209     class EndCategory(HomCategory):

/Users/Starx/sage/local/lib/python2.6/site-packages/sage/modules/vector_space_homspace.pyc in __call__(self, A, check)
    383             msg = 'vector space homspace can only coerce matrices, vector space morphisms, functions or lists, not {0}'
    384             raise TypeError(msg.format(A))
--> 385         return vector_space_morphism.VectorSpaceMorphism(self, A)
    386 
    387     def _repr_(self):

/Users/Starx/sage/local/lib/python2.6/site-packages/sage/modules/vector_space_morphism.pyc in __init__(self, homspace, A)
    861             raise TypeError('domain dimension is incompatible with matrix size')
    862         if homspace.codomain().dimension() != A.ncols():
--> 863             raise TypeError('codomain dimension is incompatible with matrix size')
    864 
    865         A = homspace._matrix_space()(A)

TypeError: codomain dimension is incompatible with matrix size

The problem here is that sage creates a list of lists from that lambda function and then a matrix from those lists, so the list of lists results in a 0x0 matrix instead of a 0x1 matrix. The fix is to just add the dimensions to the matrix constructor in vector_space_homspace.py, I will post a patch shortly.

Component: algebra

Author: Jim Stark

Reviewer: Aly Deines

Merged: sage-5.0.beta3

Issue created by migration from https://trac.sagemath.org/ticket/12412

@sagetrac-JStarx sagetrac-JStarx mannequin added this to the sage-5.0 milestone Feb 1, 2012
@sagetrac-JStarx sagetrac-JStarx mannequin assigned aghitza Feb 1, 2012
@sagetrac-JStarx
Copy link
Mannequin Author

sagetrac-JStarx mannequin commented Feb 1, 2012

Attachment: vector.patch.gz

@adeines
Copy link
Mannequin

adeines mannequin commented Feb 2, 2012

Reviewer: Aly Deines

@jdemeyer
Copy link

jdemeyer commented Feb 7, 2012

Merged: sage-5.0.beta3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants