1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 from numpy import int8, int16, int32, int64, float32, float64, zeros
24
25
26 from lib.io import DummyFileObject
27
29 """A class to act as a container."""
30
31 pass
32
33
35 """A dummy function for testing data types."""
36
37 pass
38
40 """A second dummy function for testing data types."""
41
42 return "Hello"
43
44
45
46 DATA_TYPES = []
47 """An array of many different Python objects for testing the correct behaviour of user function args."""
48
49
50
51 DATA_TYPES.append(['bin', 0])
52 DATA_TYPES.append(['bin', 1])
53
54
55 DATA_TYPES.append(['bool', True])
56 DATA_TYPES.append(['bool', False])
57
58
59 DATA_TYPES.append(['class obj', Container()])
60
61
62 DATA_TYPES.append(['class', Container])
63
64
65 DATA_TYPES.append(['dict', {}])
66 DATA_TYPES.append(['dict', {'a': 0, 'b': 1}])
67
68
69 DATA_TYPES.append(['int', 2])
70 DATA_TYPES.append(['int', 10])
71 DATA_TYPES.append(['int', -10])
72
73
74 DATA_TYPES.append(['int', zeros(2, int8)[0]])
75 DATA_TYPES.append(['int', zeros(2, int16)[0]])
76 DATA_TYPES.append(['int', zeros(2, int32)[0]])
77 DATA_TYPES.append(['int', zeros(2, int64)[0]])
78
79
80 DATA_TYPES.append(['file', DummyFileObject()])
81 DATA_TYPES.append(['file list', [DummyFileObject(), 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