@@ -18,25 +18,25 @@ def test_single_array():
1818 """Test that the ltob algorithm rejects arrays with multiple dims"""
1919 x = np .linspace (0 , 1 , 100000 )
2020 y = np .random .rand (100000 )
21- assert sys .getrefcount (x ) = = 2
22- assert sys .getrefcount (y ) = = 2
21+ assert sys .getrefcount (x ) < = 2
22+ assert sys .getrefcount (y ) < = 2
2323 nx , ny = downsample .ltob (x , y , 100 )
2424 assert nx .dtype == np .double
2525 assert ny .dtype == np .double
26- assert sys .getrefcount (x ) = = 2
27- assert sys .getrefcount (y ) = = 2
26+ assert sys .getrefcount (x ) < = 2
27+ assert sys .getrefcount (y ) < = 2
2828 assert nx .shape == (100 ,)
2929 assert ny .shape == (100 ,)
30- assert sys .getrefcount (nx ) = = 2
31- assert sys .getrefcount (ny ) = = 2
30+ assert sys .getrefcount (nx ) < = 2
31+ assert sys .getrefcount (ny ) < = 2
3232
3333
3434def test_negative_threshold ():
3535 """Test if a negative threshold provides problems"""
3636 x = np .arange (100000 , dtype = np .int32 )
3737 y = np .random .randint (1000 , size = 100000 , dtype = np .uint64 )
38- assert sys .getrefcount (x ) = = 2
39- assert sys .getrefcount (y ) = = 2
38+ assert sys .getrefcount (x ) < = 2
39+ assert sys .getrefcount (y ) < = 2
4040 with pytest .raises (ValueError ):
4141 downsample .ltob (x , y , - 100 )
4242
@@ -45,35 +45,35 @@ def test_threshold_larger():
4545 """Test if a larger threshold provides problems"""
4646 x = np .arange (100000 , dtype = np .int32 )
4747 y = np .random .randint (1000 , size = 100000 , dtype = np .uint64 )
48- assert sys .getrefcount (x ) = = 2
49- assert sys .getrefcount (y ) = = 2
48+ assert sys .getrefcount (x ) < = 2
49+ assert sys .getrefcount (y ) < = 2
5050 # Will return the arrays!
5151 nx , ny = downsample .ltob (x , y , 100000 + 1 )
5252 assert len (nx ) == 100000
5353 assert len (ny ) == 100000
5454 assert nx .dtype == np .double
5555 assert ny .dtype == np .double
56- assert sys .getrefcount (x ) = = 2
57- assert sys .getrefcount (y ) = = 2
58- assert sys .getrefcount (nx ) = = 2
59- assert sys .getrefcount (ny ) = = 2
56+ assert sys .getrefcount (x ) < = 2
57+ assert sys .getrefcount (y ) < = 2
58+ assert sys .getrefcount (nx ) < = 2
59+ assert sys .getrefcount (ny ) < = 2
6060
6161
6262def test_input_list ():
6363 """Test the down sampling with lists types"""
6464 x = list (range (100000 ))
6565 y = [True ] * 100000
66- assert sys .getrefcount (x ) = = 2
67- assert sys .getrefcount (y ) = = 2
66+ assert sys .getrefcount (x ) < = 2
67+ assert sys .getrefcount (y ) < = 2
6868 nx , ny = downsample .ltob (x , y , 10 )
6969 assert len (nx ) == 10
7070 assert len (ny ) == 10
7171 assert nx .dtype == np .double
7272 assert ny .dtype == np .double
73- assert sys .getrefcount (x ) = = 2
74- assert sys .getrefcount (y ) = = 2
75- assert sys .getrefcount (nx ) = = 2
76- assert sys .getrefcount (ny ) = = 2
73+ assert sys .getrefcount (x ) < = 2
74+ assert sys .getrefcount (y ) < = 2
75+ assert sys .getrefcount (nx ) < = 2
76+ assert sys .getrefcount (ny ) < = 2
7777 test_array = np .array (
7878 [0. , 12499. , 24999. , 37499. , 49999. , 62498. ,
7979 74998. , 87498. , 99998. , 99999. ],
@@ -88,17 +88,17 @@ def test_input_list_array():
8888 """Test the down sampling with mixed types"""
8989 x = list (range (100000 ))
9090 y = np .array ([True ] * 100000 , dtype = bool )
91- assert sys .getrefcount (x ) = = 2
92- assert sys .getrefcount (y ) = = 2
91+ assert sys .getrefcount (x ) < = 2
92+ assert sys .getrefcount (y ) < = 2
9393 nx , ny = downsample .ltob (x , y , 100 )
9494 assert len (nx ) == 100
9595 assert len (ny ) == 100
9696 assert nx .dtype == np .double
9797 assert ny .dtype == np .double
98- assert sys .getrefcount (x ) = = 2
99- assert sys .getrefcount (y ) = = 2
100- assert sys .getrefcount (nx ) = = 2
101- assert sys .getrefcount (ny ) = = 2
98+ assert sys .getrefcount (x ) < = 2
99+ assert sys .getrefcount (y ) < = 2
100+ assert sys .getrefcount (nx ) < = 2
101+ assert sys .getrefcount (ny ) < = 2
102102 test_array = np .array ([1.0 ] * 100 , dtype = np .double )
103103 test_array_bool = np .array ([1.0 ] * 100 , dtype = bool )
104104 np .testing .assert_array_almost_equal (ny , test_array )
@@ -109,46 +109,46 @@ def test_array_size():
109109 """Test the input failure for different dimensions of arrays"""
110110 x = np .arange (100000 )
111111 y = np .random .randint (1000 , size = 100000 - 1 , dtype = np .uint64 )
112- assert sys .getrefcount (x ) = = 2
113- assert sys .getrefcount (y ) = = 2
112+ assert sys .getrefcount (x ) < = 2
113+ assert sys .getrefcount (y ) < = 2
114114 with pytest .raises (ValueError ):
115115 assert downsample .ltob (x , y , 100000 )
116- assert sys .getrefcount (x ) = = 2
117- assert sys .getrefcount (y ) = = 2
116+ assert sys .getrefcount (x ) < = 2
117+ assert sys .getrefcount (y ) < = 2
118118
119119
120120def test_ltob_uint64 ():
121121 """Test the base down sampling of the module"""
122122 x = np .arange (100000 , dtype = np .int32 )
123123 y = np .random .randint (1000 , size = 100000 , dtype = np .uint64 )
124- assert sys .getrefcount (x ) = = 2
125- assert sys .getrefcount (y ) = = 2
124+ assert sys .getrefcount (x ) < = 2
125+ assert sys .getrefcount (y ) < = 2
126126 nx , ny = downsample .ltob (x , y , 100 )
127127 assert len (nx ) == 100
128128 assert len (ny ) == 100
129129 assert nx .dtype == np .double
130130 assert ny .dtype == np .double
131- assert sys .getrefcount (x ) = = 2
132- assert sys .getrefcount (y ) = = 2
133- assert sys .getrefcount (nx ) = = 2
134- assert sys .getrefcount (ny ) = = 2
131+ assert sys .getrefcount (x ) < = 2
132+ assert sys .getrefcount (y ) < = 2
133+ assert sys .getrefcount (nx ) < = 2
134+ assert sys .getrefcount (ny ) < = 2
135135
136136
137137def test_ltob_bool ():
138138 """Test the down sampling with boolean types"""
139139 x = np .arange (100000 , dtype = np .int32 )
140140 y = np .array ([True ] * 100000 , dtype = bool )
141- assert sys .getrefcount (x ) = = 2
142- assert sys .getrefcount (y ) = = 2
141+ assert sys .getrefcount (x ) < = 2
142+ assert sys .getrefcount (y ) < = 2
143143 nx , ny = downsample .ltob (x , y , 100 )
144144 assert len (nx ) == 100
145145 assert len (ny ) == 100
146146 assert nx .dtype == np .double
147147 assert ny .dtype == np .double
148- assert sys .getrefcount (x ) = = 2
149- assert sys .getrefcount (y ) = = 2
150- assert sys .getrefcount (nx ) = = 2
151- assert sys .getrefcount (ny ) = = 2
148+ assert sys .getrefcount (x ) < = 2
149+ assert sys .getrefcount (y ) < = 2
150+ assert sys .getrefcount (nx ) < = 2
151+ assert sys .getrefcount (ny ) < = 2
152152 test_array = np .array ([1.0 ] * 100 , dtype = np .double )
153153 test_array_bool = np .array ([1.0 ] * 100 , dtype = bool )
154154 np .testing .assert_array_almost_equal (ny , test_array )
@@ -159,17 +159,17 @@ def test_inf():
159159 """Test the down sampling with inf types"""
160160 x = np .arange (100000 , dtype = np .int32 )
161161 y = np .array ([np .inf ] * 100000 , dtype = np .double )
162- assert sys .getrefcount (x ) = = 2
163- assert sys .getrefcount (y ) = = 2
162+ assert sys .getrefcount (x ) < = 2
163+ assert sys .getrefcount (y ) < = 2
164164 nx , ny = downsample .ltob (x , y , 100 )
165165 assert len (nx ) == 100
166166 assert len (ny ) == 100
167167 assert nx .dtype == np .double
168168 assert ny .dtype == np .double
169- assert sys .getrefcount (x ) = = 2
170- assert sys .getrefcount (y ) = = 2
171- assert sys .getrefcount (nx ) = = 2
172- assert sys .getrefcount (ny ) = = 2
169+ assert sys .getrefcount (x ) < = 2
170+ assert sys .getrefcount (y ) < = 2
171+ assert sys .getrefcount (nx ) < = 2
172+ assert sys .getrefcount (ny ) < = 2
173173 test_array = np .array ([0.0 ] * 100 , dtype = np .float64 )
174174 np .testing .assert_array_almost_equal (ny , test_array )
175175
@@ -181,17 +181,17 @@ def test_single_inf():
181181 [1.0 , 1.0 , 2.0 , np .inf , 4.0 , 5.0 , 6.0 , 7.0 , 8.0 , 9.0 , 10.0 ,
182182 11.0 , 12.0 , 13.0 , 14.0 , 15.0 , 16.0 , 17.0 , 18 , 19.0 , ],
183183 dtype = np .double , )
184- assert sys .getrefcount (x ) = = 2
185- assert sys .getrefcount (y ) = = 2
184+ assert sys .getrefcount (x ) < = 2
185+ assert sys .getrefcount (y ) < = 2
186186 nx , ny = downsample .ltob (x , y , 10 )
187187 assert len (nx ) == 10
188188 assert len (ny ) == 10
189189 assert nx .dtype == np .double
190190 assert ny .dtype == np .double
191- assert sys .getrefcount (x ) = = 2
192- assert sys .getrefcount (y ) = = 2
193- assert sys .getrefcount (nx ) = = 2
194- assert sys .getrefcount (ny ) = = 2
191+ assert sys .getrefcount (x ) < = 2
192+ assert sys .getrefcount (y ) < = 2
193+ assert sys .getrefcount (nx ) < = 2
194+ assert sys .getrefcount (ny ) < = 2
195195 test_array = np .array ([0. , 0. , 5. , 6. , 9. , 11. , 13. , 15. , 18. , 19. ],
196196 dtype = np .double )
197197 np .testing .assert_array_almost_equal (nx , test_array )
@@ -204,17 +204,17 @@ def test_nan():
204204 """Test the down sampling with NaN types"""
205205 x = np .arange (100000 , dtype = np .int32 )
206206 y = np .array ([np .nan ] * 100000 , dtype = np .double )
207- assert sys .getrefcount (x ) = = 2
208- assert sys .getrefcount (y ) = = 2
207+ assert sys .getrefcount (x ) < = 2
208+ assert sys .getrefcount (y ) < = 2
209209 nx , ny = downsample .ltob (x , y , 100 )
210210 assert len (nx ) == 100
211211 assert len (ny ) == 100
212212 assert nx .dtype == np .double
213213 assert ny .dtype == np .double
214- assert sys .getrefcount (x ) = = 2
215- assert sys .getrefcount (y ) = = 2
216- assert sys .getrefcount (nx ) = = 2
217- assert sys .getrefcount (ny ) = = 2
214+ assert sys .getrefcount (x ) < = 2
215+ assert sys .getrefcount (y ) < = 2
216+ assert sys .getrefcount (nx ) < = 2
217+ assert sys .getrefcount (ny ) < = 2
218218
219219
220220def test_array_mix_inf_nan ():
@@ -224,17 +224,17 @@ def test_array_mix_inf_nan():
224224 [0.0 , 1.0 , 2.0 , np .nan , 4.0 , 5.0 , 6.0 , np .nan , np .inf , np .inf ,
225225 10.0 , np .nan , 12.0 , - np .inf , 14.0 , 15.0 , 16.0 , 17.0 , np .nan , 19.0 , ],
226226 dtype = np .double )
227- assert sys .getrefcount (x ) = = 2
228- assert sys .getrefcount (y ) = = 2
227+ assert sys .getrefcount (x ) < = 2
228+ assert sys .getrefcount (y ) < = 2
229229 nx , ny = downsample .ltob (x , y , 10 )
230230 assert len (nx ) == 10
231231 assert len (ny ) == 10
232232 assert nx .dtype == np .double
233233 assert ny .dtype == np .double
234- assert sys .getrefcount (x ) = = 2
235- assert sys .getrefcount (y ) = = 2
236- assert sys .getrefcount (nx ) = = 2
237- assert sys .getrefcount (ny ) = = 2
234+ assert sys .getrefcount (x ) < = 2
235+ assert sys .getrefcount (y ) < = 2
236+ assert sys .getrefcount (nx ) < = 2
237+ assert sys .getrefcount (ny ) < = 2
238238 test_array = np .array ([0. , 0. , 5. , 0. , 0. , 0. , 0. , 15. , 0. , 19. ],
239239 dtype = np .double )
240240 np .testing .assert_array_almost_equal (ny , test_array )
@@ -246,18 +246,18 @@ def test_single_nan():
246246 y = np .array ([0.0 , 1.0 , 2.0 , np .nan , 4.0 , 5.0 , 6.0 , 7.0 , 8.0 ,
247247 9.0 , 10.0 , 11.0 , 12.0 , 13.0 , 14.0 , 15.0 , 16.0 ,
248248 17.0 , 18 , 19.0 , ], dtype = np .double )
249- assert sys .getrefcount (x ) = = 2
250- assert sys .getrefcount (y ) = = 2
249+ assert sys .getrefcount (x ) < = 2
250+ assert sys .getrefcount (y ) < = 2
251251 z = x .copy ()
252252 nx , ny = downsample .ltob (x , y , 10 )
253253 assert len (nx ) == 10
254254 assert len (ny ) == 10
255255 assert nx .dtype == np .double
256256 assert ny .dtype == np .double
257- assert sys .getrefcount (x ) = = 2
258- assert sys .getrefcount (y ) = = 2
259- assert sys .getrefcount (nx ) = = 2
260- assert sys .getrefcount (ny ) = = 2
257+ assert sys .getrefcount (x ) < = 2
258+ assert sys .getrefcount (y ) < = 2
259+ assert sys .getrefcount (nx ) < = 2
260+ assert sys .getrefcount (ny ) < = 2
261261 test_array = np .array ([0. , 0. , 5. , 6. , 9. , 11. , 13. , 15. , 18. , 19. ],
262262 dtype = np .double )
263263 np .testing .assert_array_almost_equal (x , z )
0 commit comments