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 10
10
from .util import *
11
11
from .base import *
12
12
from .broadcast import *
13
+ import math
13
14
14
15
class Seq (ct .Structure ):
15
16
_fields_ = [("begin" , ct .c_double ),
@@ -18,7 +19,6 @@ class Seq(ct.Structure):
18
19
19
20
def __init__ (self , S ):
20
21
num = __import__ ("numbers" )
21
-
22
22
self .begin = ct .c_double ( 0 )
23
23
self .end = ct .c_double (- 1 )
24
24
self .step = ct .c_double ( 1 )
@@ -27,12 +27,14 @@ def __init__ (self, S):
27
27
self .begin = ct .c_double (S )
28
28
self .end = ct .c_double (S )
29
29
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
30
34
if (S .start is not None ):
31
35
self .begin = ct .c_double (S .start )
32
36
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 ))
36
38
else :
37
39
raise IndexError ("Invalid type while indexing arrayfire.array" )
38
40
You can’t perform that action at this time.
0 commit comments