On Nov 14, 2008, at 3:08 PM, Jason Grout wrote:

> William Stein wrote:
>> I did try pasting that example into sagenb.org and it gives
>> some weird errors involving _fast_float.  Jason Grout -- maybe
>> you could look at why your interact appears broken?
>
> Robert Bradshaw: I've asked a question at the bottom of this email to
> you about partial function evaluation of fast_float functions...
>
> Okay, I've updated the code to be smarter.  The code ended up calling
> maxima a *lot* for what basically was partial function evaluation.
> Instead, I switched it to use the functools.partial class to partially
> evaluate a fast_float function.  Apparently I triggered the surge
> protection on the wiki and so cannot post the update there.  It is  
> here:
> http://sagenb.org:8000/home/pub/69 and also just in case sometime  
> in the
> future, the public notebook server goes down, here is the code so it's
> archived on the list:
>
> var('u v')
> from sage.ext.fast_eval import fast_float
> from functools import partial
> @interact
> def trans(x=input_box(u^2-v^2, label="x=",type=SR), \
>          y=input_box(u*v+cos(u*v), label="y=",type=SR), \
>          t_val=slider(0,10,0.2,6, label="Length of curves"), \
>          u_percent=slider(0,1,0.05,label="<font color='red'>u</font>",
> default=.7),
>          v_percent=slider(0,1,0.05,label="<font color='blue'>v</ 
> font>",
> default=.7),
>          u_range=input_box(range(-5,5,1), label="u lines"),
>          v_range=input_box(range(-5,5,1), label="v lines")):
>      thickness=4
>      u_val = min(u_range)+(max(u_range)-min(u_range))*u_percent
>      v_val = min(v_range)+(max(v_range)-min(v_range))*v_percent
>      t_min = -t_val
>      t_max = t_val
>      g1=sum([parametric_plot((i,v), t_min,t_max, rgbcolor=(1,0,0))  
> for i
> in u_range])
>      g2=sum([parametric_plot((u,i), t_min,t_max, rgbcolor=(0,0,1))  
> for i
> in v_range])
>      vline_straight=parametric_plot((u,v_val), t_min,t_max,
> rgbcolor=(0,0,1), linestyle='-',thickness=thickness)
>      uline_straight=parametric_plot((u_val, v),
> t_min,t_max,rgbcolor=(1,0,0), linestyle='-',thickness=thickness)
>
> (g1+g2+vline_straight+uline_straight).save 
> ("uv_coord.png",aspect_ratio=1,
> figsize=[5,5], axes_labels=['$u$','$v$'])
>      xuv = fast_float(x,'u','v')
>      yuv = fast_float(y,'u','v')
>      xvu = fast_float(x,'v','u')
>      yvu = fast_float(y,'v','u')
>      g3=sum([parametric_plot((partial(xuv,i),partial(yuv,i)),
> t_min,t_max, rgbcolor=(1,0,0)) for i in u_range])
>      g4=sum([parametric_plot((partial(xvu,i),partial(yvu,i)),
> t_min,t_max, rgbcolor=(0,0,1)) for i in v_range])
>      vline=parametric_plot((partial(xvu,v_val),partial(yvu,v_val)),
> t_min,t_max, rgbcolor=(0,0,1), linestyle='-',thickness=thickness)
>      uline=parametric_plot((partial(xuv,u_val),partial(yuv,u_val)),
> t_min,t_max,rgbcolor=(1,0,0), linestyle='-',thickness=thickness)
>      (g3+g4+vline+uline).save("xy_coord.png", aspect_ratio=1,
> figsize=[5,5], axes_labels=['$x$','$y$'])
>      print jsmath("x=%s, \: y=%s"%(latex(x), latex(y)))
>      print "<html><table><tr><td><img
> src='cell://uv_coord.png'/></td><td><img
> src='cell://xy_coord.png'/></td></tr></table></html>"
>
>
>
> Robert, can we make partial function evaluation part of fast_float?
> That way, given the following:
>
> var("u,v")
> x=u^2+v^2
> xuv = fast_float(x,'u','v')
>
> the following are equivalent:
>
> xuv(2)(3)
>
> and
>
> xuv(2,3)
>
>
> Of course, right now, we can do this (with a slight performance  
> penalty)
> by doing:
>
> import functools.partial
>
> functools.partial(xuv,2)(3)
>
>
> My whole reason for doing this (to avoid expensive maxima calls) is
> disappearing soon, so maybe it's not worth the effort, especially  
> since
> functools.partial provides a standard python way to get this.

It certainly could be done, but I don't know how worth it it would  
be. What notation should we use. (I'd much rather have an error when  
one enters an incomplete list of arguments).

- Robert




--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to