On 11/3/12 9:56 AM, Jason Grout wrote:
sage: phi = (ZZ^2).hom(matrix(ZZ,2,[1..4]))
sage: h = (RR^2).hom(matrix(RR, 2, [1..4]))
sage: type(phi.parent())
sage.modules.free_module_homspace.FreeModuleHomspace_with_category
sage: type(h.parent())
sage.modules.vector_space_homspace.VectorSpaceHomspace_with_category
Looking at the code, h.parent() is a direct subclass of phi.parent().
Actually, maybe that's part of my confusion. The *_with_category
classes are not subclasses.
In fact, the error is boiled down to: the default implementation of
_an_element_ works fine for phi.parent(), but not for h.parent(), since:
sage: phi.parent()(2)
Free module morphism defined by the matrix
[2 0]
[0 2]
Domain: Ambient free module of rank 2 over the principal ideal domain
Integer Ring
Codomain: Ambient free module of rank 2 over the principal ideal domain
Integer Ring
sage: h.parent()(2)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-148-11d17a12ebdf> in <module>()
----> 1 h.parent()(Integer(2))
/Users/grout/sage-trees/sage-5.4.rc1/local/lib/python2.7/site-packages/sage/modules/vector_space_homspace.pyc
in __call__(self, A, check)
393 else:
394 msg = 'vector space homspace can only coerce
matrices, vector space morphisms, functions or lists, not {0}'
--> 395 raise TypeError(msg.format(A))
396 return vector_space_morphism.VectorSpaceMorphism(self, A)
397
TypeError: vector space homspace can only coerce matrices, vector space
morphisms, functions or lists, not 2
So all we have to do is get h.parent()(i) working for some i in
['_an_element_', 'pi', 1.2, 2, 1, 0, infinity].
Here is one way to do it: delete a bunch of the over-eager
error-checking code:
https://gist.github.com/4007685
Rob Beezer, what do you think?
Thanks,
Jason
--
You received this message because you are subscribed to the Google Groups
"sage-devel" group.
To post to this group, send email to sage-devel@googlegroups.com.
To unsubscribe from this group, send email to
sage-devel+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel?hl=en.