diff options
author | lzkelley <lkelley@cfa.harvard.edu> | 2015-11-15 17:25:45 -0500 |
---|---|---|
committer | lzkelley <lkelley@cfa.harvard.edu> | 2015-11-17 14:00:38 -0500 |
commit | 46d2e8356760e7549d0c80da9fe232177924183c (patch) | |
tree | 1fe484ba26adcc55b923ed3ac25defb73df26f7f /numpy/lib/tests/test_function_base.py | |
parent | cf66c68c6a560c934f4a767934573c7f85dcb4ae (diff) | |
download | numpy-46d2e8356760e7549d0c80da9fe232177924183c.tar.gz |
BUG, MAINT: check that histogram range parameters are finite, add tests to assure this. Improved some error-types.
Diffstat (limited to 'numpy/lib/tests/test_function_base.py')
-rw-r--r-- | numpy/lib/tests/test_function_base.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index cc53c2b8e..88c932692 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -1267,6 +1267,13 @@ class TestHistogram(TestCase): assert_array_equal(a, np.array([0])) assert_array_equal(b, np.array([0, 1])) + def test_finite_range(self): + # Normal ranges should be fine + vals = np.linspace(0.0, 1.0, num=100) + histogram(vals, range=[0.25,0.75]) + assert_raises(ValueError, histogram, vals, range=[np.nan,0.75]) + assert_raises(ValueError, histogram, vals, range=[0.25,np.inf]) + class TestHistogramOptimBinNums(TestCase): """ @@ -1489,6 +1496,16 @@ class TestHistogramdd(TestCase): assert_(hist[0] == 0.0) assert_(hist[1] == 0.0) + def test_finite_range(self): + vals = np.random.random((100,3)) + histogramdd(vals, range=[[0.0,1.0],[0.25,0.75],[0.25,0.5]]) + assert_raises(ValueError, histogramdd, vals, + range=[[0.0,1.0],[0.25,0.75],[0.25,np.inf]]) + assert_raises(ValueError, histogramdd, vals, + range=[[0.0,1.0],[np.nan,0.75],[0.25,0.5]]) + + + class TestUnique(TestCase): |