From 2af2e60fb488dfe251112d139446da61d44e77ab Mon Sep 17 00:00:00 2001 From: Ralf Gommers Date: Wed, 23 Mar 2011 21:12:19 +0100 Subject: ENH: Make all histogram functions work with empty input. --- numpy/lib/tests/test_function_base.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'numpy/lib/tests/test_function_base.py') 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): -- cgit v1.2.1