11import unittest
22import warnings
3+ from distutils .version import LooseVersion
34from itertools import chain
45from functools import partial , wraps
56
67import numpy as np
78from scipy .sparse import csr_matrix , issparse , lil_matrix , csc_matrix , \
89 SparseEfficiencyWarning
910
11+ import Orange
1012from Orange .statistics .util import bincount , countnans , contingency , digitize , \
1113 mean , nanmax , nanmean , nanmedian , nanmin , nansum , nanunique , stats , std , \
12- unique , var , nanstd , nanvar , nanmode , array_equal , FDR
14+ unique , var , nanstd , nanvar , nanmode , FDR
1315from sklearn .utils import check_random_state
1416
1517
@@ -34,10 +36,20 @@ def sparse_with_explicit_zero(x, array):
3436
3537 return sp_array
3638
39+ # Make sure to call setUp and tearDown methods in between test runs so
40+ # any widget state doesn't interfere between tests
41+ def _setup_teardown ():
42+ self .tearDown ()
43+ self .setUp ()
44+
3745 test_case (self , np .array )
46+ _setup_teardown ()
3847 test_case (self , csr_matrix )
48+ _setup_teardown ()
3949 test_case (self , csc_matrix )
50+ _setup_teardown ()
4051 test_case (self , partial (sparse_with_explicit_zero , array = csr_matrix ))
52+ _setup_teardown ()
4153 test_case (self , partial (sparse_with_explicit_zero , array = csc_matrix ))
4254
4355 return _wrapper
@@ -295,6 +307,17 @@ def test_FDR_list(self):
295307 np .array ([0.00033 , 0.0004 , 0.00005 , 0.00038 , 0.00025 ]),
296308 result , decimal = 5 )
297309
310+ def test_array_equal_deprecated (self ):
311+ """This test is to be included in the 3.22 release and will fail in
312+ version 3.24. This serves as a reminder to remove the deprecated method
313+ and this test."""
314+ if LooseVersion (Orange .__version__ ) >= LooseVersion ("3.24" ):
315+ self .fail (
316+ "`Orange.statistics.util.array_equal` was deprecated in "
317+ "version 3.22, and there have been two minor versions in "
318+ "between. Please remove the deprecated method from the module."
319+ )
320+
298321
299322class TestNanmean (unittest .TestCase ):
300323 def setUp (self ):
@@ -622,25 +645,6 @@ def test_nanunique_ignores_nans_in_counts(self, array):
622645 np .testing .assert_equal (nanunique (x , return_counts = True )[1 ], expected )
623646
624647
625- class TestArrayEqual (unittest .TestCase ):
626- @dense_sparse
627- def test_same_matrices (self , array ):
628- x = array ([0 , 1 , 0 , 0 , 2 ])
629- self .assertTrue (array_equal (x , x ))
630-
631- @dense_sparse
632- def test_with_different_shapes (self , array ):
633- x = array (np .eye (4 ))
634- y = array (np .eye (5 ))
635- self .assertFalse (array_equal (x , y ))
636-
637- @dense_sparse
638- def test_with_different_values (self , array ):
639- x = array ([0 , 1 , 0 , 0 , 2 ])
640- y = array ([0 , 3 , 0 , 0 , 2 ])
641- self .assertFalse (array_equal (x , y ))
642-
643-
644648class TestNanModeAppVeyor (unittest .TestCase ):
645649 def test_appveyour_still_not_onscipy_1_2_0 (self ):
646650 import scipy
0 commit comments