summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_function_base.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2016-03-16 10:35:03 -0600
committerCharles Harris <charlesr.harris@gmail.com>2016-03-16 10:35:03 -0600
commit858b5b201f82be0aa98210dc363f049939a15e31 (patch)
tree839c61a8bd82416f4b943486e16b139bec8b533a /numpy/lib/tests/test_function_base.py
parent1429c606643d1ad305e710c4a31cb6f398d04c53 (diff)
parent8869c1ace77affefff75c8a772edb2983b68a015 (diff)
downloadnumpy-858b5b201f82be0aa98210dc363f049939a15e31.tar.gz
Merge pull request #7416 from madphysicist/hist-range
BUG: Incorrect handling of range in `histogram` with automatic bins.
Diffstat (limited to 'numpy/lib/tests/test_function_base.py')
-rw-r--r--numpy/lib/tests/test_function_base.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py
index 945992fc0..20c786ad1 100644
--- a/numpy/lib/tests/test_function_base.py
+++ b/numpy/lib/tests/test_function_base.py
@@ -1432,9 +1432,9 @@ class TestHistogramOptimBinNums(TestCase):
for testlen, expectedResults in basic_test.items():
# Create some sort of non uniform data to test with
# (2 peak uniform mixture)
- x1 = np.linspace(-10, -1, testlen/5 * 2)
- x2 = np.linspace(1,10, testlen/5 * 3)
- x = np.hstack((x1, x2))
+ x1 = np.linspace(-10, -1, testlen // 5 * 2)
+ x2 = np.linspace(1, 10, testlen // 5 * 3)
+ x = np.concatenate((x1, x2))
for estimator, numbins in expectedResults.items():
a, b = np.histogram(x, estimator)
assert_equal(len(a), numbins, err_msg="For the {0} estimator "
@@ -1446,7 +1446,7 @@ class TestHistogramOptimBinNums(TestCase):
adaptive methods, especially the FD method. All bin numbers have been
precalculated.
"""
- small_dat = {1: {'fd': 1, 'scott': 1, 'rice': 2, 'sturges': 1,
+ small_dat = {1: {'fd': 1, 'scott': 1, 'rice': 1, 'sturges': 1,
'doane': 1, 'sqrt': 1},
2: {'fd': 2, 'scott': 1, 'rice': 3, 'sturges': 2,
'doane': 1, 'sqrt': 2},
@@ -1474,8 +1474,8 @@ class TestHistogramOptimBinNums(TestCase):
Primarily for Scott and FD as the SD and IQR are both 0 in this case
"""
novar_dataset = np.ones(100)
- novar_resultdict = {'fd': 1, 'scott': 1, 'rice': 10, 'sturges': 8,
- 'doane': 1, 'sqrt': 10, 'auto': 8}
+ novar_resultdict = {'fd': 1, 'scott': 1, 'rice': 1, 'sturges': 1,
+ 'doane': 1, 'sqrt': 1, 'auto': 1}
for estimator, numbins in novar_resultdict.items():
a, b = np.histogram(novar_dataset, estimator)
@@ -1510,14 +1510,14 @@ class TestHistogramOptimBinNums(TestCase):
the shouldn't change.
"""
# some basic sanity checking, with some fixed data. Checking for the correct number of bins
- basic_test = {50: {'fd': 4, 'scott': 4, 'rice': 8, 'sturges': 7, 'auto': 7},
- 500: {'fd': 8, 'scott': 8, 'rice': 16, 'sturges': 10, 'auto': 10},
- 5000: {'fd': 17, 'scott': 17, 'rice': 35, 'sturges': 14, 'auto': 17}}
+ basic_test = {50: {'fd': 8, 'scott': 8, 'rice': 15, 'sturges': 14, 'auto': 14},
+ 500: {'fd': 15, 'scott': 16, 'rice': 32, 'sturges': 20, 'auto': 20},
+ 5000: {'fd': 33, 'scott': 33, 'rice': 69, 'sturges': 28, 'auto': 33}}
for testlen, expectedResults in basic_test.items():
- # create some sort of non uniform data to test with (2 peak uniform mixture)
- x1 = np.linspace(-10, -1, testlen/5 * 2)
- x2 = np.linspace(1, 10, testlen/5 * 3)
+ # create some sort of non uniform data to test with (3 peak uniform mixture)
+ x1 = np.linspace(-10, -1, testlen // 5 * 2)
+ x2 = np.linspace(1, 10, testlen // 5 * 3)
x3 = np.linspace(-100, -50, testlen)
x = np.hstack((x1, x2, x3))
for estimator, numbins in expectedResults.items():