#10489: plot_slope_field broken
---------------------------+------------------------------------------------
   Reporter:  ManDay       |       Owner:  jason, was               
       Type:  enhancement  |      Status:  needs_work               
   Priority:  major        |   Milestone:  sage-4.6.2               
  Component:  graphics     |    Keywords:  plot_slope_field beginner
     Author:               |    Upstream:  N/A                      
   Reviewer:  Aly Deines   |      Merged:                           
Work_issues:               |  
---------------------------+------------------------------------------------
Changes (by aly.deines):

  * status:  needs_review => needs_work
  * reviewer:  => Aly Deines


Comment:

 Running sage-4.6.1.rc0 on sage.math the patch did not apply:


 adei...@sage:~/sage-4.6.1.rc0/devel/sage$ hg qpush
 applying 10489_slope_field_lambda.patch
 patching file sage/plot/plot_field.py
 Hunk #1 FAILED at 218
 1 out of 1 hunks FAILED -- saving rejects to file
 sage/plot/plot_field.py.rej
 patch failed, unable to continue (try -v)
 patch failed, rejects left in working dir
 errors during apply, please fix and refresh 10489_slope_field_lambda.patch
 adei...@sage:~/sage-4.6.1.rc0/devel/sage$ vi sage/plot/plot_field.py.rej

 --- plot_field.py
 +++ plot_field.py
 @@ -219,10 +219,21 @@

          sage: x,y = var('x y')
          sage: plot_slope_field(sin(x+y)+cos(x+y), (x,-3,3), (y,-3,3))
 +
 +    Plot a slope field using a lambda function::
 +
 +        sage: plot_slope_field(lambda x,y: x+y, (-2,2), (-2,2))
 +
      """
      slope_options = {'headaxislength': 0, 'headlength': 0, 'pivot':
 'middle'}
      slope_options.update(kwds)

      from sage.functions.all import sqrt
 -    norm = sqrt((f**2+1))
 -    return plot_vector_field((1/norm, f/norm), xrange, yrange,
 **slope_options)
 +    from inspect import isfunction
 +    if isfunction(f):
 +        norm_inverse=lambda x,y: 1/sqrt(f(x,y)**2+1)
 +        f_normalized=lambda x,y: f(x,y)*norm_inverse(x,y)
 +    else:
 +        norm_inverse = 1/sqrt((f**2+1))
 +        f_normalized=f*norm_inverse
 +    return plot_vector_field((norm_inverse, f_normalized), xrange,
 yrange, **slope_options)

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/10489#comment:8>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to