@@ -18,25 +18,25 @@ def test_single_array():
1818 """Test that the ltd 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 .ltd (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 .ltd (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 .ltd (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 .ltd (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 ([0.0 , 1.0 , 12500.0 , 25000.0 , 37500.0 ,
7878 50000.0 , 62499.0 , 74999.0 , 87499.0 , 99999.0 ],
7979 dtype = np .double )
@@ -87,17 +87,17 @@ def test_input_list_array():
8787 """Test the down sampling with mixed types"""
8888 x = list (range (100000 ))
8989 y = np .array ([True ] * 100000 , dtype = bool )
90- assert sys .getrefcount (x ) = = 2
91- assert sys .getrefcount (y ) = = 2
90+ assert sys .getrefcount (x ) < = 2
91+ assert sys .getrefcount (y ) < = 2
9292 nx , ny = downsample .ltd (x , y , 100 )
9393 assert len (nx ) == 100
9494 assert len (ny ) == 100
9595 assert nx .dtype == np .double
9696 assert ny .dtype == np .double
97- assert sys .getrefcount (x ) = = 2
98- assert sys .getrefcount (y ) = = 2
99- assert sys .getrefcount (nx ) = = 2
100- assert sys .getrefcount (ny ) = = 2
97+ assert sys .getrefcount (x ) < = 2
98+ assert sys .getrefcount (y ) < = 2
99+ assert sys .getrefcount (nx ) < = 2
100+ assert sys .getrefcount (ny ) < = 2
101101 test_array = np .array ([1.0 ] * 100 , dtype = np .double )
102102 test_array_bool = np .array ([1.0 ] * 100 , dtype = bool )
103103 np .testing .assert_array_almost_equal (ny , test_array )
@@ -108,46 +108,46 @@ def test_array_size():
108108 """Test the input failure for different dimensions of arrays"""
109109 x = np .arange (100000 )
110110 y = np .random .randint (1000 , size = 100000 - 1 , dtype = np .uint64 )
111- assert sys .getrefcount (x ) = = 2
112- assert sys .getrefcount (y ) = = 2
111+ assert sys .getrefcount (x ) < = 2
112+ assert sys .getrefcount (y ) < = 2
113113 with pytest .raises (ValueError ):
114114 assert downsample .ltd (x , y , 100000 )
115- assert sys .getrefcount (x ) = = 2
116- assert sys .getrefcount (y ) = = 2
115+ assert sys .getrefcount (x ) < = 2
116+ assert sys .getrefcount (y ) < = 2
117117
118118
119119def test_ltd_uint64 ():
120120 """Test the base down sampling of the module"""
121121 x = np .arange (100000 , dtype = np .int32 )
122122 y = np .random .randint (1000 , size = 100000 , dtype = np .uint64 )
123- assert sys .getrefcount (x ) = = 2
124- assert sys .getrefcount (y ) = = 2
123+ assert sys .getrefcount (x ) < = 2
124+ assert sys .getrefcount (y ) < = 2
125125 nx , ny = downsample .ltd (x , y , 100 )
126126 assert len (nx ) == 100
127127 assert len (ny ) == 100
128128 assert nx .dtype == np .double
129129 assert ny .dtype == np .double
130- assert sys .getrefcount (x ) = = 2
131- assert sys .getrefcount (y ) = = 2
132- assert sys .getrefcount (nx ) = = 2
133- assert sys .getrefcount (ny ) = = 2
130+ assert sys .getrefcount (x ) < = 2
131+ assert sys .getrefcount (y ) < = 2
132+ assert sys .getrefcount (nx ) < = 2
133+ assert sys .getrefcount (ny ) < = 2
134134
135135
136136def test_ltd_bool ():
137137 """Test the down sampling with boolean types"""
138138 x = np .arange (100000 , dtype = np .int32 )
139139 y = np .array ([True ] * 100000 , dtype = bool )
140- assert sys .getrefcount (x ) = = 2
141- assert sys .getrefcount (y ) = = 2
140+ assert sys .getrefcount (x ) < = 2
141+ assert sys .getrefcount (y ) < = 2
142142 nx , ny = downsample .ltd (x , y , 100 )
143143 assert len (nx ) == 100
144144 assert len (ny ) == 100
145145 assert nx .dtype == np .double
146146 assert ny .dtype == np .double
147- assert sys .getrefcount (x ) = = 2
148- assert sys .getrefcount (y ) = = 2
149- assert sys .getrefcount (nx ) = = 2
150- assert sys .getrefcount (ny ) = = 2
147+ assert sys .getrefcount (x ) < = 2
148+ assert sys .getrefcount (y ) < = 2
149+ assert sys .getrefcount (nx ) < = 2
150+ assert sys .getrefcount (ny ) < = 2
151151 test_array = np .array ([1.0 ] * 100 , dtype = np .double )
152152 test_array_bool = np .array ([1.0 ] * 100 , dtype = bool )
153153 np .testing .assert_array_almost_equal (ny , test_array )
@@ -158,17 +158,17 @@ def test_inf():
158158 """Test the down sampling with inf types"""
159159 x = np .arange (100000 , dtype = np .int32 )
160160 y = np .array ([np .inf ] * 100000 , dtype = np .double )
161- assert sys .getrefcount (x ) = = 2
162- assert sys .getrefcount (y ) = = 2
161+ assert sys .getrefcount (x ) < = 2
162+ assert sys .getrefcount (y ) < = 2
163163 nx , ny = downsample .ltd (x , y , 100 )
164164 assert len (nx ) == 100
165165 assert len (ny ) == 100
166166 assert nx .dtype == np .double
167167 assert ny .dtype == np .double
168- assert sys .getrefcount (x ) = = 2
169- assert sys .getrefcount (y ) = = 2
170- assert sys .getrefcount (nx ) = = 2
171- assert sys .getrefcount (ny ) = = 2
168+ assert sys .getrefcount (x ) < = 2
169+ assert sys .getrefcount (y ) < = 2
170+ assert sys .getrefcount (nx ) < = 2
171+ assert sys .getrefcount (ny ) < = 2
172172 test_array = np .array ([np .inf ] * 100 , dtype = np .double )
173173 np .testing .assert_array_almost_equal (ny , test_array )
174174
@@ -180,17 +180,17 @@ def test_single_inf():
180180 [1.0 , 1.0 , 2.0 , np .inf , 4.0 , 5.0 , 6.0 , 7.0 , 8.0 , 9.0 , 10.0 ,
181181 11.0 , 12.0 , 13.0 , 14.0 , 15.0 , 16.0 , 17.0 , 18 , 19.0 , ],
182182 dtype = np .double , )
183- assert sys .getrefcount (x ) = = 2
184- assert sys .getrefcount (y ) = = 2
183+ assert sys .getrefcount (x ) < = 2
184+ assert sys .getrefcount (y ) < = 2
185185 nx , ny = downsample .ltd (x , y , 10 )
186186 assert len (nx ) == 10
187187 assert len (ny ) == 10
188188 assert nx .dtype == np .double
189189 assert ny .dtype == np .double
190- assert sys .getrefcount (x ) = = 2
191- assert sys .getrefcount (y ) = = 2
192- assert sys .getrefcount (nx ) = = 2
193- assert sys .getrefcount (ny ) = = 2
190+ assert sys .getrefcount (x ) < = 2
191+ assert sys .getrefcount (y ) < = 2
192+ assert sys .getrefcount (nx ) < = 2
193+ assert sys .getrefcount (ny ) < = 2
194194 test_array = np .array ([0. , 0. , 4. , 5. , 7. , 10. , 12. , 14. , 16. , 19. ],
195195 dtype = np .double )
196196 np .testing .assert_array_almost_equal (nx , test_array )
@@ -203,17 +203,17 @@ def test_nan():
203203 """Test the down sampling with NaN types"""
204204 x = np .arange (100000 , dtype = np .int32 )
205205 y = np .array ([np .nan ] * 100000 , dtype = np .double )
206- assert sys .getrefcount (x ) = = 2
207- assert sys .getrefcount (y ) = = 2
206+ assert sys .getrefcount (x ) < = 2
207+ assert sys .getrefcount (y ) < = 2
208208 nx , ny = downsample .ltd (x , y , 100 )
209209 assert len (nx ) == 100
210210 assert len (ny ) == 100
211211 assert nx .dtype == np .double
212212 assert ny .dtype == np .double
213- assert sys .getrefcount (x ) = = 2
214- assert sys .getrefcount (y ) = = 2
215- assert sys .getrefcount (nx ) = = 2
216- assert sys .getrefcount (ny ) = = 2
213+ assert sys .getrefcount (x ) < = 2
214+ assert sys .getrefcount (y ) < = 2
215+ assert sys .getrefcount (nx ) < = 2
216+ assert sys .getrefcount (ny ) < = 2
217217
218218
219219def test_array_mix_inf_nan ():
@@ -223,17 +223,17 @@ def test_array_mix_inf_nan():
223223 [0.0 , 1.0 , 2.0 , np .nan , 4.0 , 5.0 , 6.0 , np .nan , np .inf , np .inf ,
224224 10.0 , np .nan , 12.0 , - np .inf , 14.0 , 15.0 , 16.0 , 17.0 , np .nan , 19.0 , ],
225225 dtype = np .double )
226- assert sys .getrefcount (x ) = = 2
227- assert sys .getrefcount (y ) = = 2
226+ assert sys .getrefcount (x ) < = 2
227+ assert sys .getrefcount (y ) < = 2
228228 nx , ny = downsample .ltd (x , y , 10 )
229229 assert len (nx ) == 10
230230 assert len (ny ) == 10
231231 assert nx .dtype == np .double
232232 assert ny .dtype == np .double
233- assert sys .getrefcount (x ) = = 2
234- assert sys .getrefcount (y ) = = 2
235- assert sys .getrefcount (nx ) = = 2
236- assert sys .getrefcount (ny ) = = 2
233+ assert sys .getrefcount (x ) < = 2
234+ assert sys .getrefcount (y ) < = 2
235+ assert sys .getrefcount (nx ) < = 2
236+ assert sys .getrefcount (ny ) < = 2
237237 test_array = np .array (
238238 [0. , 0. , 4. , 4. , 6. , np .inf , np .nan , - np .inf , 15. , 19. ],
239239 dtype = np .double )
@@ -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 .ltd (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. , 4. , 5. , 7. , 10. , 12. , 14. , 16. , 19. ],
262262 dtype = np .double )
263263 np .testing .assert_array_almost_equal (x , z )
0 commit comments