id summary reporter owner description type status priority milestone component resolution keywords cc merged author reviewer upstream work_issues branch commit dependencies stopgaps
31316 Method subs() ineffective on tensor fields egourgoulhon "As reported in this [https://ask.sagemath.org/question/55527/subs-in-vector-field/ ask.sagemath question], tensor fields are endowed with a method `subs()` which is totally ineffective:
{{{
sage: E. = EuclideanSpace()
sage: a = var('a')
sage: v = E.vector_field(a*x, a^2 + y)
sage: v.display()
a*x e_x + (a^2 + y) e_y
sage: v.subs(a==1)
Vector field on the Euclidean plane E^2
sage: v.display()
a*x e_x + (a^2 + y) e_y
}}}
This is because `subs()` is inherited from the generic base class `Element` and the code of `Element.subs()` has
{{{
parent = self._parent
try:
ngens = parent.ngens()
except (AttributeError, NotImplementedError, TypeError):
return self
}}}
Since `v.parent().ngens()` returns an `AttributeError`, this explains the silent failure.
Currently, the required substitution can be achieved by means of the method `apply_map`:
{{{
sage: v.apply_map(lambda comp: comp.subs(a==1))
sage: v.display()
x e_x + (y + 1) e_y
}}}
" defect new major sage-9.7 manifolds tensor field, subs, substitution tscrim gh-mjungmath N/A