diff options
-rw-r--r-- | numpy/core/tests/test_deprecations.py | 15 | ||||
-rw-r--r-- | numpy/lib/function_base.py | 4 | ||||
-rw-r--r-- | numpy/ma/tests/test_core.py | 8 |
3 files changed, 20 insertions, 7 deletions
diff --git a/numpy/core/tests/test_deprecations.py b/numpy/core/tests/test_deprecations.py index 518b367f0..372af9c0b 100644 --- a/numpy/core/tests/test_deprecations.py +++ b/numpy/core/tests/test_deprecations.py @@ -89,7 +89,7 @@ class _DeprecationTestCase(object): if num is not None and num_found != num: msg = "%i warnings found but %i expected." % (len(self.log), num) lst = [w.category for w in self.log] - raise AssertionError("\n".join([msg] + [lst])) + raise AssertionError("\n".join([msg] + lst)) with warnings.catch_warnings(): warnings.filterwarnings("error", message=self.message, @@ -400,5 +400,18 @@ class TestNonCContiguousViewDeprecation(_DeprecationTestCase): self.assert_deprecated(np.ones((2,2)).T.view, args=(np.int8,)) +class TestTestDeprecated(object): + def test_assert_deprecated(self): + test_case_instance = _DeprecationTestCase() + test_case_instance.setUp() + assert_raises(AssertionError, + test_case_instance.assert_deprecated, + lambda: None) + + def foo(): + warnings.warn("foo", category=DeprecationWarning) + + test_case_instance.assert_deprecated(foo) + if __name__ == "__main__": run_module_suite() diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index 9261dba22..3298789ee 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -268,14 +268,14 @@ def histogram(a, bins=10, range=None, normed=False, weights=None, large datasets respectively. Switchover point is usually x.size~1000. 'FD' (Freedman Diaconis Estimator) - .. math:: h = 2 \\frac{IQR}{n^{-1/3}} + .. math:: h = 2 \\frac{IQR}{n^{1/3}} The binwidth is proportional to the interquartile range (IQR) and inversely proportional to cube root of a.size. Can be too conservative for small datasets, but is quite good for large datasets. The IQR is very robust to outliers. 'Scott' - .. math:: h = \\frac{3.5\\sigma}{n^{-1/3}} + .. math:: h = \\frac{3.5\\sigma}{n^{1/3}} The binwidth is proportional to the standard deviation (sd) of the data and inversely proportional to cube root of a.size. Can be too conservative for small datasets, but is quite good diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py index 53cdef978..e0d9f072c 100644 --- a/numpy/ma/tests/test_core.py +++ b/numpy/ma/tests/test_core.py @@ -764,25 +764,25 @@ class TestMaskedArray(TestCase): t_2d = masked_array(data = [([[1, 2], [3,4]],)], mask = [([[False, True], [True, False]],)], - dtype = [('a', '<i8', (2,2))]) + dtype = [('a', '<i4', (2,2))]) assert_(str(t_2d[0]) == "([[1, --], [--, 4]],)") assert_(repr(t_2d[0]) == "([[1, --], [--, 4]],)") t_0d = masked_array(data = [(1,2)], mask = [(True,False)], - dtype = [('a', '<i8'), ('b', '<i8')]) + dtype = [('a', '<i4'), ('b', '<i4')]) assert_(str(t_0d[0]) == "(--, 2)") assert_(repr(t_0d[0]) == "(--, 2)") t_2d = masked_array(data = [([[1, 2], [3,4]], 1)], mask = [([[False, True], [True, False]], False)], - dtype = [('a', '<i8', (2,2)), ('b', float)]) + dtype = [('a', '<i4', (2,2)), ('b', float)]) assert_(str(t_2d[0]) == "([[1, --], [--, 4]], 1.0)") assert_(repr(t_2d[0]) == "([[1, --], [--, 4]], 1.0)") t_ne = masked_array(data=[(1, (1, 1))], mask=[(True, (True, False))], - dtype = [('a', '<i8'), ('b', 'i4,i4')]) + dtype = [('a', '<i4'), ('b', 'i4,i4')]) assert_(str(t_ne[0]) == "(--, (--, 1))") assert_(repr(t_ne[0]) == "(--, (--, 1))") |