-
Notifications
You must be signed in to change notification settings - Fork 64
Expand file tree
/
Copy patharray_test.py
More file actions
69 lines (51 loc) · 2.04 KB
/
array_test.py
File metadata and controls
69 lines (51 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env python
#######################################################
# Copyright (c) 2019, ArrayFire
# All rights reserved.
#
# This file is distributed under 3-clause BSD license.
# The complete license agreement can be obtained at:
# http://arrayfire.com/licenses/BSD-3-Clause
########################################################
import array as host
import arrayfire as af
from . import _util
def simple_array(verbose=False):
display_func = _util.display_func(verbose)
print_func = _util.print_func(verbose)
a = af.array.Array([1, 2, 3])
display_func(a)
display_func(a.T)
display_func(a.H)
print_func(a.shape)
b = a.as_type(af.Dtype.s32)
display_func(b)
print_func(a.elements(), a.type(), a.dims(), a.numdims())
print_func(a.is_empty(), a.is_scalar(), a.is_column(), a.is_row())
print_func(a.is_complex(), a.is_real(), a.is_double(), a.is_single())
print_func(a.is_real_floating(), a.is_floating(), a.is_integer(), a.is_bool())
a = af.array.Array(host.array("i", [4, 5, 6]))
display_func(a)
print_func(a.elements(), a.type(), a.dims(), a.numdims())
print_func(a.is_empty(), a.is_scalar(), a.is_column(), a.is_row())
print_func(a.is_complex(), a.is_real(), a.is_double(), a.is_single())
print_func(a.is_real_floating(), a.is_floating(), a.is_integer(), a.is_bool())
a = af.array.Array(host.array("I", [7, 8, 9] * 3), (3, 3))
display_func(a)
print_func(a.elements(), a.type(), a.dims(), a.numdims())
print_func(a.is_empty(), a.is_scalar(), a.is_column(), a.is_row())
print_func(a.is_complex(), a.is_real(), a.is_double(), a.is_single())
print_func(a.is_real_floating(), a.is_floating(), a.is_integer(), a.is_bool())
c = a.to_ctype()
for n in range(a.elements()):
print_func(c[n])
c, s = a.to_ctype(True, True)
for n in range(a.elements()):
print_func(c[n])
print_func(s)
arr = a.to_array()
lst = a.to_list(True)
print_func(arr)
print_func(lst)
print_func(a.is_sparse())
_util.tests["array"] = simple_array