1 | initial version |
This is Trac 10246. I knew I'd seen it before (in fact, I reported it), but it took a little while to find it. Unfortunately, that one has been on the back burner, but it's an easy fix once someone makes time to do it.
You definitely need to make the function callable, and this is one way to do it. So I don't see an obvious way around question 1. As for question 2, you may just have to catch this case explicitly for now (a try/except block where if plot(self.f)
doesn't work, you check if the function is the identity and plot that).
2 | No.2 Revision |
This is Trac 10246. I knew I'd seen it before (in fact, I reported it), but it took a little while to find it. Unfortunately, that one has been on the back burner, but it's an easy fix once someone makes time to do it.
You definitely need to make the function callable, and this is one way to do it. So I don't see an obvious way around question 1. As for question 2, you may just have to catch this case explicitly for now (a try/except block where if plot(self.f)
doesn't work, you check if the function is the identity and plot that).
Edit: I have a fix, but can't log on to Trac.
if name in svars:
return self.ff.fast_float_arg(svars.index(name))
+ if ex._is_symbol(): # case of callable function which is the variable, like f(x)=x
+ name = repr(SR(ex)) # this gets back just the 'output' of the function
+ if name in svars:
+ return self.ff.fast_float_arg(svars.index(name))
+
try:
return self.ff.fast_float_constant(float(ex))
except TypeError:
Full patch includes nice doctests, of course :)
3 | No.3 Revision |
This is Trac 10246. I knew I'd seen it before (in fact, I reported it), but it took a little while to find it. Unfortunately, that one has been on the back burner, but it's an easy fix once someone makes time to do it.
You definitely need to make the function callable, and this is one way to do it. So I don't see an obvious way around question 1. As for question 2, you may just have to catch this case explicitly for now (a try/except block where if plot(self.f)
doesn't work, you check if the function is the identity and plot that).
Edit: I have a fix, but can't log on to Trac. Patch at Trac 10246 is now ready for review.
if name in svars:
return self.ff.fast_float_arg(svars.index(name))
+ if ex._is_symbol(): # case of callable function which is the variable, like f(x)=x
+ name = repr(SR(ex)) # this gets back just the 'output' of the function
+ if name in svars:
+ return self.ff.fast_float_arg(svars.index(name))
+
try:
return self.ff.fast_float_constant(float(ex))
except TypeError:
Full patch includes nice doctests, of course :)