Ricardo Massaro to sage-devel
show details 8:28 PM (18 minutes ago)
Reply
Hello all,
First of all, I'd like to thank you for Sage, it's really helping me a
lot.
I found a strange behavior that i *think* it's a bug, but I'm not
sure, since I'm a completely newbie to Sage and Python:
sage: a = var('a')
sage: m = matrix(SR, 2, [a,a,a,a])
sage: v = vector(SR, 2, [a,a])
Then,
sage: m.subs(a=1)
[1 1]
[1 1]
but
sage: v.subs(a=1)
(a, a)
I *think* the problem is in the Element.subs() method in devel/sage/
sage/structure/element.pyx. It seems to assume that the generators are
symbols, which is not true in the example vector.
Am I missing something, or is it really a bug?
Here's a dirty fix that apparently fixes this problem, but will likely
beak something else:
def subs(self, in_dict=None, **kwds):
v = [a.subs(in_dict, **kwds) for a in self.list()]
return self.parent()(v)
Thanks,
Ricardo