File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change 1010from .util import *
1111from .base import *
1212from .broadcast import *
13+ import math
1314
1415class Seq (ct .Structure ):
1516 _fields_ = [("begin" , ct .c_double ),
@@ -18,7 +19,6 @@ class Seq(ct.Structure):
1819
1920 def __init__ (self , S ):
2021 num = __import__ ("numbers" )
21-
2222 self .begin = ct .c_double ( 0 )
2323 self .end = ct .c_double (- 1 )
2424 self .step = ct .c_double ( 1 )
@@ -27,12 +27,14 @@ def __init__ (self, S):
2727 self .begin = ct .c_double (S )
2828 self .end = ct .c_double (S )
2929 elif isinstance (S , slice ):
30+ if (S .step is not None ):
31+ self .step = ct .c_double (S .step )
32+ if (S .step < 0 ):
33+ self .begin , self .end = self .end , self .begin
3034 if (S .start is not None ):
3135 self .begin = ct .c_double (S .start )
3236 if (S .stop is not None ):
33- self .end = ct .c_double (S .stop - 1 )
34- if (S .step is not None ):
35- self .step = ct .c_double (S .step )
37+ self .end = ct .c_double (S .stop - math .copysign (1 , self .step ))
3638 else :
3739 raise IndexError ("Invalid type while indexing arrayfire.array" )
3840
You can’t perform that action at this time.
0 commit comments