diff options
Diffstat (limited to 'numpy/lib/tests/test_histograms.py')
-rw-r--r-- | numpy/lib/tests/test_histograms.py | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/numpy/lib/tests/test_histograms.py b/numpy/lib/tests/test_histograms.py index 4895a722c..fc16b7396 100644 --- a/numpy/lib/tests/test_histograms.py +++ b/numpy/lib/tests/test_histograms.py @@ -1,5 +1,3 @@ -from __future__ import division, absolute_import, print_function - import numpy as np from numpy.lib.histograms import histogram, histogramdd, histogram_bin_edges @@ -8,9 +6,10 @@ from numpy.testing import ( assert_array_almost_equal, assert_raises, assert_allclose, assert_array_max_ulp, assert_raises_regex, suppress_warnings, ) +import pytest -class TestHistogram(object): +class TestHistogram: def setup(self): pass @@ -82,7 +81,7 @@ class TestHistogram(object): a, b = histogram(v, bins, density=False) assert_array_equal(a, [1, 2, 3, 4]) - # Variale bin widths are especially useful to deal with + # Variable bin widths are especially useful to deal with # infinities. v = np.arange(10) bins = [0, 1, 3, 6, np.inf] @@ -423,7 +422,7 @@ class TestHistogram(object): assert_array_equal(edges, e) -class TestHistogramOptimBinNums(object): +class TestHistogramOptimBinNums: """ Provide test coverage when using provided estimators for optimal number of bins @@ -591,6 +590,16 @@ class TestHistogramOptimBinNums(object): msg += " with datasize of {0}".format(testlen) assert_equal(len(a), numbins, err_msg=msg) + @pytest.mark.parametrize("bins", ['auto', 'fd', 'doane', 'scott', + 'stone', 'rice', 'sturges']) + def test_signed_integer_data(self, bins): + # Regression test for gh-14379. + a = np.array([-2, 0, 127], dtype=np.int8) + hist, edges = np.histogram(a, bins=bins) + hist32, edges32 = np.histogram(a.astype(np.int32), bins=bins) + assert_array_equal(hist, hist32) + assert_array_equal(edges, edges32) + def test_simple_weighted(self): """ Check that weighted data raises a TypeError @@ -601,7 +610,7 @@ class TestHistogramOptimBinNums(object): estimator, weights=[1, 2, 3]) -class TestHistogramdd(object): +class TestHistogramdd: def test_simple(self): x = np.array([[-.5, .5, 1.5], [-.5, 1.5, 2.5], [-.5, 2.5, .5], |