id summary reporter owner description type status priority milestone component resolution keywords cc merged author reviewer upstream work_issues branch commit dependencies stopgaps
29639 Bug in initialization of vector field with rational components egourgoulhon "Initializing the components of a vector field with a rational number as first component leads to an error:
{{{
sage: M = Manifold(2, 'M')
sage: X. = M.chart()
sage: v = M.vector_field(1/2, -1)
...
IndexError: index n (=1) out of range; it must be 0
}}}
while providing the components as a list is OK:
{{{
sage: v = M.vector_field([1/2, -1])
sage: v.display()
1/2 d/dx - d/dy
}}}
This is due to `Rational` class having a `__getitem__()` method (for some reason...) and `TensorField._init_components` (introduced in #27581) testing its input by
{{{
if hasattr(comp0, '__getitem__'):
}}}
Replacing the above line by
{{{
if hasattr(comp0, '__len__') and hasattr(comp0, '__getitem__'):
}}}
fixes the bug, since `Rational` has no `__len__` method. " defect closed major sage-9.2 geometry fixed vector field, manifold tscrim Eric Gourgoulhon Travis Scrimshaw N/A 62dc948cc2fb4309af1cfa4b984e377f31852acb 62dc948cc2fb4309af1cfa4b984e377f31852acb