1 | initial version |
You can work around this by replacing sqrt(2) with RR(sqrt(2)) or sqrt(2).n() or float(sqrt(2)) -- anything which turns it from an Expression into a number.
I think this is a bug caused by the quirk that matplotlib thinks that Sage Expressions are iterable because it tests whether "len" works:
def iterable(obj):
'return true if *obj* is iterable'
try: len(obj)
except: return False
return True
and sqrt(2) does have a working len, even though it's not iterable:
sage: len(sqrt(2))
2
sage: list(sqrt(2))
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
[...]
TypeError: 'sage.symbolic.expression.Expression' object is not iterable
I've confirmed that if I hack matplotlib.cbook.iterable it works. Probably the right way to fix this is to get plot to coerce to floats at the start using to_float_list, which strangely enough isn't currently used anywhere in sage/plot.
2 | No.2 Revision |
You can work around this by replacing sqrt(2) with RR(sqrt(2)) or sqrt(2).n() or float(sqrt(2)) -- anything which turns it from an Expression into a (real) number.
I think this is a bug caused by the quirk that matplotlib thinks that Sage Expressions are iterable because it tests whether "len" works:
def iterable(obj):
'return true if *obj* is iterable'
try: len(obj)
except: return False
return True
and sqrt(2) does have a working len, even though it's not iterable:
sage: len(sqrt(2))
2
sage: list(sqrt(2))
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
[...]
TypeError: 'sage.symbolic.expression.Expression' object is not iterable
I've confirmed that if I hack matplotlib.cbook.iterable it works. Probably the right way to fix this is to get plot to coerce to floats at the start using to_float_list, which strangely enough isn't currently used anywhere in sage/plot.