Opened 10 years ago

Closed 10 years ago

#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: Merged in: sage-5.0.beta3
Authors: Jim Stark Reviewers: Aly Deines
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges


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)


/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())
    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)
    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')
    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, I will post a patch shortly.

Attachments (1)

vector.patch (2.0 KB) - added by JStarx 10 years ago.

Download all attachments as: .zip

Change History (4)

Changed 10 years ago by JStarx

comment:1 Changed 10 years ago by JStarx

  • Status changed from new to needs_review

comment:2 Changed 10 years ago by aly.deines

  • Reviewers set to Aly Deines
  • Status changed from needs_review to positive_review

comment:3 Changed 10 years ago by jdemeyer

  • Merged in set to sage-5.0.beta3
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.