Skip to content

Commit

Permalink
BUG: Ongoing fixes to PR#7416
Browse files Browse the repository at this point in the history
Removed superfluous `ceil` call in automated bin width estimator.
Updated tests to reflect modified estimator.
  • Loading branch information
madphysicist committed Mar 16, 2016
1 parent 858b5b2 commit 434c4ec
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion numpy/lib/function_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def _hist_bin_sturges(x):
-------
h : An estimate of the optimal bin width for the given data.
"""
return x.ptp() / np.ceil(np.log2(x.size) + 1.0)
return x.ptp() / (np.log2(x.size) + 1.0)


def _hist_bin_rice(x):
Expand Down
2 changes: 1 addition & 1 deletion numpy/lib/tests/test_function_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1512,7 +1512,7 @@ def test_simple_range(self):
# some basic sanity checking, with some fixed data. Checking for the correct number of bins
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}}
5000: {'fd': 33, 'scott': 33, 'rice': 69, 'sturges': 27, 'auto': 33}}

for testlen, expectedResults in basic_test.items():
# create some sort of non uniform data to test with (3 peak uniform mixture)
Expand Down

0 comments on commit 434c4ec

Please sign in to comment.