Skip to content

Commit 7d6eacc

Browse files
committed
Add number to dtype conversion
1 parent bff0ab5 commit 7d6eacc

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

arrayfire/util.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@ def dim4(d0=1, d1=1, d2=1, d3=1):
2222
def is_number(a):
2323
return isinstance(a, numbers.Number)
2424

25+
def number_dtype(a):
26+
if isinstance(a, bool):
27+
return b8
28+
if isinstance(a, int):
29+
return s64
30+
elif isinstance(a, float):
31+
return f64
32+
elif isinstance(a, complex):
33+
return c64
34+
else:
35+
return to_dtype[a.dtype.char]
36+
2537
def dim4_tuple(dims, default=1):
2638
assert(isinstance(dims, tuple))
2739

0 commit comments

Comments
 (0)