#4974: [with patch, needs work] make sage.libs.pari.gen._normalize_slice a
miscellaneous function for dealing with slices
--------------------+-------------------------------------------------------
Reporter: jason | Owner: craigcitro
Type: defect | Status: assigned
Priority: major | Milestone: sage-3.3
Component: misc | Resolution:
Keywords: |
--------------------+-------------------------------------------------------
Changes (by ylchapuy):
* summary: [with patch, needs review] make
sage.libs.pari.gen._normalize_slice a
miscellaneous function for dealing with slices
=> [with patch, needs work] make
sage.libs.pari.gen._normalize_slice a
miscellaneous function for dealing with slices
Comment:
A lot better, but there are still bugs.
I would recommand to try something like this to test extensively:
{{{
#!python
def safe_norm(i,j,k,l):
try:
return sage.misc.misc_c.normalize_slice(slice(i,j,k),l)
except ValueError:
return "error"
def safe_range(i,j,k,l):
try:
return range(l)[i:j:k]
except ValueError:
return "error"
d=[-5,-4,-3,-2,-1,0,-1,-2,-3,-4,-5,None]
ld=len(d)-1
for r in xrange(500):
i=d[randint(0,ld)]
j=d[randint(0,ld)]
k=d[randint(0,ld)]
l=randint(-8,8)
r1=safe_norm(i,j,k,l)
r2=safe_range(i,j,k,l)
if not r1==r2:
print i,j,k,l,r1,r2
}}}
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/4974#comment:11>
Sage <http://sagemath.org/>
Sage - Open Source Mathematical Software: Building the Car Instead of
Reinventing the Wheel
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---