I am writing some functions where I want the user to specify the arguments as tuples if they want. So, in the code, I am writing something like :
arg = map(vector, arg) Of course, I want my function to work also if arg is already a list of vectors, but I ran into the following problem : {{{ sage: K.<sqrt3> = QuadraticField(3); K Number Field in sqrt3 with defining polynomial x^2 - 3 sage: v = vector(K, (1/2, sqrt3/2) ); v (1/2, 1/2*sqrt3) sage: v.parent() Vector space of dimension 2 over Number Field in sqrt3 with defining polynomial x^2 - 3 sage: vector(v).parent() Vector space of dimension 2 over Number Field in sqrt3 with defining polynomial x^2 - 3 }}} {{{ sage: v3 = vector(K, (0, 1) ) sage: v3.parent() Vector space of dimension 2 over Number Field in sqrt3 with defining polynomial x^2 - 3 sage: vector(v3).parent() Ambient free module of rank 2 over the principal ideal domain Integer Ring }}} For vector of integers, it changes the ring for ZZ, which I doesn't like because I want to be able to add them (the addition of those vector appears to be unsupported yet by the coercion system). {{{ sage: vector(v) + vector(v3) Traceback (most recent call last): ... AttributeError: 'NotImplementedType' object has no attribute 'natural_map' }}} I just created a ticket (#6643) for it and added a patch. My question is : Is there a reason why the vector function changes the ring of a vector for ZZ when possible, because my patch removes this behavior. I want to avoid to break something somewhere else... See http://trac.sagemath.org/sage_trac/ticket/6643 My other question is : Should I create a ticket for the vector(v) + vector(v3) coercion problem? Thank you, Sébastien Labbé PhD Student LaCIM, UQAM, Montréal --~--~---------~--~----~------------~-------~--~----~ 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 For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---