diff options
author | Ralf Gommers <ralf.gommers@googlemail.com> | 2011-03-23 21:12:19 +0100 |
---|---|---|
committer | Ralf Gommers <ralf.gommers@googlemail.com> | 2011-03-27 11:43:55 +0200 |
commit | 2af2e60fb488dfe251112d139446da61d44e77ab (patch) | |
tree | 13710fec949e75ffbfcdb0c0974ff368df2a9c6b /numpy/lib/tests/test_function_base.py | |
parent | 87e12c1dfc90fae5d0a2576add0c1879df815740 (diff) | |
download | numpy-2af2e60fb488dfe251112d139446da61d44e77ab.tar.gz |
ENH: Make all histogram functions work with empty input.
Diffstat (limited to 'numpy/lib/tests/test_function_base.py')
-rw-r--r-- | numpy/lib/tests/test_function_base.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index 13930c79e..cf8429a84 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -565,8 +565,6 @@ class TestHistogram(TestCase): area = sum(a * diff(b)) assert_almost_equal(area, 1) - warnings.filterwarnings('ignore', - message="\s*This release of NumPy fixes a normalization bug") # Check with non-constant bin widths v = np.arange(10) bins = [0,1,3,6,10] @@ -656,6 +654,11 @@ class TestHistogram(TestCase): assert_almost_equal(a, [.2, .1, .1, .075]) warnings.filters.pop(0) + def test_empty(self): + a, b = histogram([], bins=([0,1])) + assert_array_equal(a, array([0])) + assert_array_equal(b, array([0, 1])) + class TestHistogramdd(TestCase): def test_simple(self): @@ -729,6 +732,10 @@ class TestHistogramdd(TestCase): hist, edges = histogramdd(x, bins=2) assert_array_equal(edges[0], array([-0.5, 0. , 0.5])) + def test_empty(self): + a, b = histogramdd([[], []], bins=([0,1], [0,1])) + assert_array_max_ulp(a, array([ 0., 0.])) + class TestUnique(TestCase): def test_simple(self): |