1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 from numpy import int8, int16, int32, int64, float32, float64, zeros
25
26
27 from relax_io import DummyFileObject
28
30 """A class to act as a container."""
31
32 pass
33
34
36 """A dummy function for testing data types."""
37
38 pass
39
41 """A second dummy function for testing data types."""
42
43 return "Hello"
44
45
46
47 DATA_TYPES = []
48 """An array of many different Python objects for testing the correct behaviour of user function args."""
49
50
51
52 DATA_TYPES.append(['bin', 0])
53 DATA_TYPES.append(['bin', 1])
54
55
56 DATA_TYPES.append(['bool', True])
57 DATA_TYPES.append(['bool', False])
58
59
60 DATA_TYPES.append(['class obj', Container()])
61
62
63 DATA_TYPES.append(['class', Container])
64
65
66 DATA_TYPES.append(['dict', {}])
67 DATA_TYPES.append(['dict', {'a': 0, 'b': 1}])
68
69
70 DATA_TYPES.append(['int', 2])
71 DATA_TYPES.append(['int', 10])
72 DATA_TYPES.append(['int', -10])
73
74
75 DATA_TYPES.append(['int', zeros(2, int8)[0]])
76 DATA_TYPES.append(['int', zeros(2, int16)[0]])
77 DATA_TYPES.append(['int', zeros(2, int32)[0]])
78 DATA_TYPES.append(['int', zeros(2, int64)[0]])
79
80
81 DATA_TYPES.append(['file', DummyFileObject()])
82
83
84 DATA_TYPES.append(['float', 0.0])
85 DATA_TYPES.append(['float', 1e-7])
86 DATA_TYPES.append(['float', 1000000.0])
87
88
89 DATA_TYPES.append(['float', zeros(2, float32)[0]])
90 DATA_TYPES.append(['float', zeros(2, float64)[0]])
91
92
93 DATA_TYPES.append(['function', dummy_fn])
94 DATA_TYPES.append(['function', dummy_fn2])
95
96
97 DATA_TYPES.append(['list', []])
98 DATA_TYPES.append(['none list', [None, None]])
99
100
101 DATA_TYPES.append(['int list', [-1, 0, 1]])
102 DATA_TYPES.append(['int list', [zeros(2, int32)[0]]])
103
104
105 DATA_TYPES.append(['float list', [-1., 0., 1.]])
106 DATA_TYPES.append(['float list', [zeros(2, float64)[0]]])
107
108
109 DATA_TYPES.append(['number list', [-1., 0, 1.]])
110
111
112 DATA_TYPES.append(['str list', ['a']])
113 DATA_TYPES.append(['str list', ['a', 'asldfjk']])
114
115
116 DATA_TYPES.append(['None', None])
117
118
119 DATA_TYPES.append(['str', 'a'])
120 DATA_TYPES.append(['str', '10'])
121
122
123 DATA_TYPES.append(['tuple', (None, None)])
124
125
126 DATA_TYPES.append(['float tuple', (0.0,)])
127 DATA_TYPES.append(['float tuple', (0.0, 0.0)])
128 DATA_TYPES.append(['float tuple', (0.0, 0.0, 0.0)])
129 DATA_TYPES.append(['float tuple', (0.0, 0.0, 0.0, 0.0)])
130 DATA_TYPES.append(['float tuple', (0.0, 0.0, 0.0, 0.0, 0.0)])
131 DATA_TYPES.append(['float tuple', (0.0, 0.0, 0.0, 0.0, 0.0, 0.0)])
132 DATA_TYPES.append(['float tuple', (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)])
133
134
135 DATA_TYPES.append(['str tuple', ('a',)])
136 DATA_TYPES.append(['str tuple', ('a', 'b')])
137 DATA_TYPES.append(['str tuple', ('a', 'b', 'c')])
138