Ticket #12412 (closed defect: fixed)
TypeError when creating a zero map from a zero dimensional vector space to a positive dimensional vector space
| Reported by: | JStarx | Owned by: | AlexGhitza |
|---|---|---|---|
| Priority: | major | Milestone: | sage-5.0 |
| Component: | algebra | Keywords: | |
| Cc: | Work issues: | ||
| Report Upstream: | N/A | Reviewers: | Aly Deines |
| Authors: | Jim Stark | Merged in: | sage-5.0.beta3 |
| Dependencies: | Stopgaps: |
Description
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.
Attachments
Change History
Note: See
TracTickets for help on using
tickets.

