#11753: Fix step=0 in (x)srange
------------------------+---------------------------------------------------
   Reporter:  ppurka    |          Owner:  jason, was                     
       Type:  defect    |         Status:  new                            
   Priority:  minor     |      Milestone:  sage-4.7.2                     
  Component:  graphics  |       Keywords:  srange xsrange division_by_zero
Work_issues:            |       Upstream:  N/A                            
   Reviewer:            |         Author:                                 
     Merged:            |   Dependencies:                                 
------------------------+---------------------------------------------------
 The following command
 {{{
 plot(x,3,3)
 }}}
 generates the following error:
 {{{
 Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "_sage_input_4.py", line 10, in <module>
     exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8
 -*-\\n" +
 
_support_.preparse_worksheet_cell(base64.b64decode("cGxvdCh4LDMsMyk="),globals())+"\\n");
 execfile(os.path.abspath("___code___.py"))
   File "", line 1, in <module>

   File "/tmp/tmpezK4rJ/___code___.py", line 3, in <module>
     exec compile(u'plot(x,_sage_const_3 ,_sage_const_3 )
   File "", line 1, in <module>

   File "/home/punarbasu/Installations/sage-4.7/local/lib/python2.6/site-
 packages/sage/misc/decorators.py", line 573, in wrapper
     return func(*args, **kwds)
   File "/home/punarbasu/Installations/sage-4.7/local/lib/python2.6/site-
 packages/sage/misc/decorators.py", line 432, in wrapper
     return func(*args, **options)
   File "/home/punarbasu/Installations/sage-4.7/local/lib/python2.6/site-
 packages/sage/plot/plot.py", line 3032, in plot
     G = funcs.plot(*args, **original_opts)
   File "expression.pyx", line 8023, in
 sage.symbolic.expression.Expression.plot
 (sage/symbolic/expression.cpp:31185)
   File "/home/punarbasu/Installations/sage-4.7/local/lib/python2.6/site-
 packages/sage/misc/decorators.py", line 573, in wrapper
     return func(*args, **kwds)
   File "/home/punarbasu/Installations/sage-4.7/local/lib/python2.6/site-
 packages/sage/misc/decorators.py", line 432, in wrapper
     return func(*args, **options)
   File "/home/punarbasu/Installations/sage-4.7/local/lib/python2.6/site-
 packages/sage/plot/plot.py", line 3051, in plot
     G = _plot(funcs, (xmin, xmax), *args, **kwds)
   File "/home/punarbasu/Installations/sage-4.7/local/lib/python2.6/site-
 packages/sage/plot/plot.py", line 3154, in _plot
     data = generate_plot_points(f, xrange, plot_points,
 adaptive_tolerance, adaptive_recursion, randomize)
   File "/home/punarbasu/Installations/sage-4.7/local/lib/python2.6/site-
 packages/sage/plot/plot.py", line 4154, in generate_plot_points
     data = srange(*ranges[0], include_endpoint=True)
   File "/home/punarbasu/Installations/sage-4.7/local/lib/python2.6/site-
 packages/sage/misc/misc.py", line 1149, in srange
     L =
 
list(xsrange(start,end,step,universe,check,include_endpoint,endpoint_tolerance))
   File "/home/punarbasu/Installations/sage-4.7/local/lib/python2.6/site-
 packages/sage/misc/misc.py", line 1236, in xsrange
     count = (end-start)/step
 ZeroDivisionError: float division
 }}}
 The error seems to be in misc.py. Attached is a patch which simply sets
 '''step''' to the default value of 1 if it is found to be 0.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/11753>
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