On Nov 8, 9:09 am, Michael Orlitzky <mich...@orlitzky.com> wrote: > On 11/07/11 21:03, kcrisman wrote: > > > > > So are you saying that Python and Piecewise functions will no longer > > behave correctly if this behavior goes from warning to error? It > > would be great if you had a "toy" example with full code; maybe there > > is a workaround that needs to become standard practice here... > > For piecewise, the problem and toy example are easy. The first > evaluation gives the warning, the second an error. > > $ cat piecewise_test.py > #!/home/mjo/bin/sage > > from sage.all import * > > x = SR.symbol('x', domain='real') > > interval0 = (0, 0.5) > function0 = 4.0*(x - 0.5)**2 > f = piecewise([[interval0, function0]]) > > print "f(1/2):" > print f(1/2) > print ""
Note that this goes away if you instead define sage: f0(x) = 4.0*(x-0.5)^2 (I mean after restarting Sage; the deprecation warning only will show up once in any case.) So I'm not sure this is a problem per se, though that doesn't mean there isn't another problem lurking. I agree that we would have to make sure people didn't do this, but the documentation for piecewise functions already expects people to use f(x)= notation, except if inserted directly in like Piecewise([[(0,1),x^2]]) or something. > print "f(x=1/2):" > print f(x=1/2) > print "" Hmm, yeah - piecewise functions don't have a subs() method nor do they allow this notation. That is a separate problem, and it does seem like a problem, since sage: g = x^2 sage: g(x=2) 4 sage: g(2) DeprecationWarning: Subst... -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org