Ticket #110 (closed enhancement: fixed)

Opened 3 years ago

Last modified 3 years ago

srange should accept negative step value

Reported by: dmharvey Owned by: somebody
Priority: minor Milestone:
Component: basic arithmetic Keywords:
Cc: Author(s):
Report Upstream: Reviewer(s):
Merged in: Work issues:

Description

It should work more like Python's ordinary range, not like this:

sage: srange(1, 5, -1)
---------------------------------------------------------------------------
exceptions.ValueError                                Traceback (most recent call last)

/home/dmharvey/sage-1.3.7.3.3/<ipython console> 

/home/dmharvey/sage/local/lib/python2.4/site-packages/sage/misc/misc.py in srange(a, b, step, include_endpoint)
    630         
    631     if step <= 0:
--> 632         raise ValueError, "step (=%s) must be positive"%step
    633     num_steps = int(float((b-a)/step)) + 1
    634     v = [a] + [a + k*step for k in range(1,num_steps)]

ValueError: step (=-1) must be positive

Change History

Changed 3 years ago by was

  • status changed from new to closed
  • resolution set to fixed

I fixed this for sage-1.4

Note: See TracTickets for help on using tickets.