Skip to content

Commit 71b0955

Browse files
committed
STYLE: Changing array class to Array to comply with python style guide
- Also helps in avoiding path conflicts and
1 parent a5b1721 commit 71b0955

File tree

16 files changed

+134
-134
lines changed

16 files changed

+134
-134
lines changed

arrayfire/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
del os
3333

3434
#do not export internal classes
35-
del base_array
35+
del BaseArray
3636
del uidx
3737
del seq
3838
del index

arrayfire/algorithm.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from .array import *
1212

1313
def parallel_dim(a, dim, c_func):
14-
out = array()
14+
out = Array()
1515
safe_call(c_func(ct.pointer(out.arr), a.arr, ct.c_int(dim)))
1616
return out
1717

@@ -67,8 +67,8 @@ def count(a, dim=None):
6767

6868
def imin(a, dim=None):
6969
if dim is not None:
70-
out = array()
71-
idx = array()
70+
out = Array()
71+
idx = Array()
7272
safe_call(clib.af_imin(ct.pointer(out.arr), ct.pointer(idx.arr), a.arr, ct.c_int(dim)))
7373
return out,idx
7474
else:
@@ -83,8 +83,8 @@ def imin(a, dim=None):
8383

8484
def imax(a, dim=None):
8585
if dim is not None:
86-
out = array()
87-
idx = array()
86+
out = Array()
87+
idx = Array()
8888
safe_call(clib.af_imax(ct.pointer(out.arr), ct.pointer(idx.arr), a.arr, ct.c_int(dim)))
8989
return out,idx
9090
else:
@@ -102,7 +102,7 @@ def accum(a, dim=0):
102102
return parallel_dim(a, dim, clib.af_accum)
103103

104104
def where(a):
105-
out = array()
105+
out = Array()
106106
safe_call(clib.af_where(ct.pointer(out.arr), a.arr))
107107
return out
108108

@@ -113,35 +113,35 @@ def diff2(a, dim=0):
113113
return parallel_dim(a, dim, clib.af_diff2)
114114

115115
def sort(a, dim=0, is_ascending=True):
116-
out = array()
116+
out = Array()
117117
safe_call(clib.af_sort(ct.pointer(out.arr), a.arr, ct.c_uint(dim), ct.c_bool(is_ascending)))
118118
return out
119119

120120
def sort_index(a, dim=0, is_ascending=True):
121-
out = array()
122-
idx = array()
121+
out = Array()
122+
idx = Array()
123123
safe_call(clib.af_sort_index(ct.pointer(out.arr), ct.pointer(idx.arr), a.arr, \
124124
ct.c_uint(dim), ct.c_bool(is_ascending)))
125125
return out,idx
126126

127127
def sort_by_key(iv, ik, dim=0, is_ascending=True):
128-
ov = array()
129-
ok = array()
128+
ov = Array()
129+
ok = Array()
130130
safe_call(clib.af_sort_by_key(ct.pointer(ov.arr), ct.pointer(ok.arr), \
131131
iv.arr, ik.arr, ct.c_uint(dim), ct.c_bool(is_ascending)))
132132
return ov,ok
133133

134134
def set_unique(a, is_sorted=False):
135-
out = array()
135+
out = Array()
136136
safe_call(clib.af_set_unique(ct.pointer(out.arr), a.arr, ct.c_bool(is_sorted)))
137137
return out
138138

139139
def set_union(a, b, is_unique=False):
140-
out = array()
140+
out = Array()
141141
safe_call(clib.af_set_union(ct.pointer(out.arr), a.arr, b.arr, ct.c_bool(is_unique)))
142142
return out
143143

144144
def set_intersect(a, b, is_unique=False):
145-
out = array()
145+
out = Array()
146146
safe_call(clib.af_set_intersect(ct.pointer(out.arr), a.arr, b.arr, ct.c_bool(is_unique)))
147147
return out

arrayfire/arith.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
from .broadcast import *
1313

1414
def arith_binary_func(lhs, rhs, c_func):
15-
out = array()
15+
out = Array()
1616

17-
is_left_array = isinstance(lhs, array)
18-
is_right_array = isinstance(rhs, array)
17+
is_left_array = isinstance(lhs, Array)
18+
is_right_array = isinstance(rhs, Array)
1919

2020
if not (is_left_array or is_right_array):
2121
raise TypeError("Atleast one input needs to be of type arrayfire.array")
@@ -26,26 +26,26 @@ def arith_binary_func(lhs, rhs, c_func):
2626
elif (is_number(rhs)):
2727
ldims = dim4_tuple(lhs.dims())
2828
rty = number_dtype(rhs)
29-
other = array()
29+
other = Array()
3030
other.arr = constant_array(rhs, ldims[0], ldims[1], ldims[2], ldims[3], rty)
3131
safe_call(c_func(ct.pointer(out.arr), lhs.arr, other.arr, bcast.get()))
3232

3333
else:
3434
rdims = dim4_tuple(rhs.dims())
3535
lty = number_dtype(lhs)
36-
other = array()
36+
other = Array()
3737
other.arr = constant_array(lhs, rdims[0], rdims[1], rdims[2], rdims[3], lty)
3838
safe_call(c_func(ct.pointer(out.arr), other.arr, rhs.arr, bcast.get()))
3939

4040
return out
4141

4242
def arith_unary_func(a, c_func):
43-
out = array()
43+
out = Array()
4444
safe_call(c_func(ct.pointer(out.arr), a.arr))
4545
return out
4646

4747
def cast(a, dtype=f32):
48-
out=array()
48+
out=Array()
4949
safe_call(clib.af_cast(ct.pointer(out.arr), a.arr, dtype))
5050
return out
5151

arrayfire/array.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,39 +55,39 @@ def constant_array(val, d0, d1=None, d2=None, d3=None, dtype=f32):
5555

5656

5757
def binary_func(lhs, rhs, c_func):
58-
out = array()
58+
out = Array()
5959
other = rhs
6060

6161
if (is_number(rhs)):
6262
ldims = dim4_tuple(lhs.dims())
6363
rty = number_dtype(rhs)
64-
other = array()
64+
other = Array()
6565
other.arr = constant_array(rhs, ldims[0], ldims[1], ldims[2], ldims[3], rty)
66-
elif not isinstance(rhs, array):
66+
elif not isinstance(rhs, Array):
6767
raise TypeError("Invalid parameter to binary function")
6868

6969
safe_call(c_func(ct.pointer(out.arr), lhs.arr, other.arr, bcast.get()))
7070

7171
return out
7272

7373
def binary_funcr(lhs, rhs, c_func):
74-
out = array()
74+
out = Array()
7575
other = lhs
7676

7777
if (is_number(lhs)):
7878
rdims = dim4_tuple(rhs.dims())
7979
lty = number_dtype(lhs)
80-
other = array()
80+
other = Array()
8181
other.arr = constant_array(lhs, rdims[0], rdims[1], rdims[2], rdims[3], lty)
82-
elif not isinstance(lhs, array):
82+
elif not isinstance(lhs, Array):
8383
raise TypeError("Invalid parameter to binary function")
8484

8585
c_func(ct.pointer(out.arr), other.arr, rhs.arr, bcast.get())
8686

8787
return out
8888

8989
def transpose(a, conj=False):
90-
out = array()
90+
out = Array()
9191
safe_call(clib.af_transpose(ct.pointer(out.arr), a.arr, conj))
9292
return out
9393

@@ -124,11 +124,11 @@ def get_info(dims, buf_len):
124124
return numdims, idims
125125

126126

127-
class array(base_array):
127+
class Array(BaseArray):
128128

129129
def __init__(self, src=None, dims=(0,), type_char=None):
130130

131-
super(array, self).__init__()
131+
super(Array, self).__init__()
132132

133133
buf=None
134134
buf_len=0
@@ -137,7 +137,7 @@ def __init__(self, src=None, dims=(0,), type_char=None):
137137

138138
if src is not None:
139139

140-
if (isinstance(src, array)):
140+
if (isinstance(src, Array)):
141141
safe_call(clib.af_retain_array(ct.pointer(self.arr), src.arr))
142142
return
143143

@@ -178,7 +178,7 @@ def __init__(self, src=None, dims=(0,), type_char=None):
178178
self.arr = create_array(buf, numdims, idims, to_dtype[_type_char])
179179

180180
def copy(self):
181-
out = array()
181+
out = Array()
182182
safe_call(clib.af_copy_array(ct.pointer(out.arr), self.arr))
183183
return out
184184

@@ -424,7 +424,7 @@ def __nonzero__(self):
424424

425425
def __getitem__(self, key):
426426
try:
427-
out = array()
427+
out = Array()
428428
n_dims = self.numdims()
429429
inds = get_indices(key, n_dims)
430430

arrayfire/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
from .library import *
1010
from .util import *
1111

12-
class base_array(object):
12+
class BaseArray(object):
1313
def __init__(self):
1414
self.arr = ct.c_void_p(0)

arrayfire/blas.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,31 @@
1111
from .array import *
1212

1313
def matmul(lhs, rhs, lhs_opts=AF_MAT_NONE, rhs_opts=AF_MAT_NONE):
14-
out = array()
14+
out = Array()
1515
safe_call(clib.af_matmul(ct.pointer(out.arr), lhs.arr, rhs.arr,\
1616
lhs_opts, rhs_opts))
1717
return out
1818

1919
def matmulTN(lhs, rhs):
20-
out = array()
20+
out = Array()
2121
safe_call(clib.af_matmul(ct.pointer(out.arr), lhs.arr, rhs.arr,\
2222
AF_MAT_TRANS, AF_MAT_NONE))
2323
return out
2424

2525
def matmulNT(lhs, rhs):
26-
out = array()
26+
out = Array()
2727
safe_call(clib.af_matmul(ct.pointer(out.arr), lhs.arr, rhs.arr,\
2828
AF_MAT_NONE, AF_MAT_TRANS))
2929
return out
3030

3131
def matmulTT(lhs, rhs):
32-
out = array()
32+
out = Array()
3333
safe_call(clib.af_matmul(ct.pointer(out.arr), lhs.arr, rhs.arr,\
3434
AF_MAT_TRANS, AF_MAT_TRANS))
3535
return out
3636

3737
def dot(lhs, rhs, lhs_opts=AF_MAT_NONE, rhs_opts=AF_MAT_NONE):
38-
out = array()
38+
out = Array()
3939
safe_call(clib.af_dot(ct.pointer(out.arr), lhs.arr, rhs.arr,\
4040
lhs_opts, rhs_opts))
4141
return out

arrayfire/data.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from .util import *
1414

1515
def constant(val, d0, d1=None, d2=None, d3=None, dtype=f32):
16-
out = array()
16+
out = Array()
1717
out.arr = constant_array(val, d0, d1, d2, d3, dtype)
1818
return out
1919

@@ -28,7 +28,7 @@ def range(d0, d1=None, d2=None, d3=None, dim=-1, dtype=f32):
2828
else:
2929
raise TypeError("Invalid dtype")
3030

31-
out = array()
31+
out = Array()
3232
dims = dim4(d0, d1, d2, d3)
3333

3434
safe_call(clib.af_range(ct.pointer(out.arr), 4, ct.pointer(dims), dim, dtype))
@@ -42,7 +42,7 @@ def iota(d0, d1=None, d2=None, d3=None, dim=-1, tile_dims=None, dtype=f32):
4242
else:
4343
raise TypeError("Invalid dtype")
4444

45-
out = array()
45+
out = Array()
4646
dims = dim4(d0, d1, d2, d3)
4747
td=[1]*4
4848

@@ -63,7 +63,7 @@ def randu(d0, d1=None, d2=None, d3=None, dtype=f32):
6363
else:
6464
raise TypeError("Invalid dtype")
6565

66-
out = array()
66+
out = Array()
6767
dims = dim4(d0, d1, d2, d3)
6868

6969
safe_call(clib.af_randu(ct.pointer(out.arr), 4, ct.pointer(dims), dtype))
@@ -77,7 +77,7 @@ def randn(d0, d1=None, d2=None, d3=None, dtype=f32):
7777
else:
7878
raise TypeError("Invalid dtype")
7979

80-
out = array()
80+
out = Array()
8181
dims = dim4(d0, d1, d2, d3)
8282

8383
safe_call(clib.af_randn(ct.pointer(out.arr), 4, ct.pointer(dims), dtype))
@@ -99,22 +99,22 @@ def identity(d0, d1=None, d2=None, d3=None, dtype=f32):
9999
else:
100100
raise TypeError("Invalid dtype")
101101

102-
out = array()
102+
out = Array()
103103
dims = dim4(d0, d1, d2, d3)
104104

105105
safe_call(clib.af_identity(ct.pointer(out.arr), 4, ct.pointer(dims), dtype))
106106
return out
107107

108108
def diag(a, num=0, extract=True):
109-
out = array()
109+
out = Array()
110110
if extract:
111111
safe_call(clib.af_diag_extract(ct.pointer(out.arr), a.arr, ct.c_int(num)))
112112
else:
113113
safe_call(clib.af_diag_create(ct.pointer(out.arr), a.arr, ct.c_int(num)))
114114
return out
115115

116116
def join(dim, first, second, third=None, fourth=None):
117-
out = array()
117+
out = Array()
118118
if (third is None and fourth is None):
119119
safe_call(clib.af_join(ct.pointer(out.arr), dim, first.arr, second.arr))
120120
else:
@@ -131,43 +131,43 @@ def join(dim, first, second, third=None, fourth=None):
131131

132132

133133
def tile(a, d0, d1=1, d2=1, d3=1):
134-
out = array()
134+
out = Array()
135135
safe_call(clib.af_tile(ct.pointer(out.arr), a.arr, d0, d1, d2, d3))
136136
return out
137137

138138

139139
def reorder(a, d0=1, d1=0, d2=2, d3=3):
140-
out = array()
140+
out = Array()
141141
safe_call(clib.af_reorder(ct.pointer(out.arr), a.arr, d0, d1, d2, d3))
142142
return out
143143

144144
def shift(a, d0, d1=0, d2=0, d3=0):
145-
out = array()
145+
out = Array()
146146
safe_call(clib.af_shift(ct.pointer(out.arr), a.arr, d0, d1, d2, d3))
147147
return out
148148

149149
def moddims(a, d0, d1=1, d2=1, d3=1):
150-
out = array()
150+
out = Array()
151151
dims = dim4(d0, d1, d2, d3)
152152
safe_call(clib.af_moddims(ct.pointer(out.arr), a.arr, 4, ct.pointer(dims)))
153153
return out
154154

155155
def flat(a):
156-
out = array()
156+
out = Array()
157157
safe_call(clib.af_flat(ct.pointer(out.arr), a.arr))
158158
return out
159159

160160
def flip(a, dim=0):
161-
out = array()
161+
out = Array()
162162
safe_call(clib.af_flip(ct.pointer(out.arr), a.arr, ct.c_int(dim)))
163163
return out
164164

165165
def lower(a, is_unit_diag=False):
166-
out = array()
166+
out = Array()
167167
safe_call(clib.af_lower(ct.pointer(out.arr), a.arr, is_unit_diag))
168168
return out
169169

170170
def upper(a, is_unit_diag=False):
171-
out = array()
171+
out = Array()
172172
safe_call(clib.af_upper(ct.pointer(out.arr), a.arr, is_unit_diag))
173173
return out

0 commit comments

Comments
 (0)