summaryrefslogtreecommitdiff
path: root/numpy/lib/tests
diff options
context:
space:
mode:
authorKirit Thadaka <kirit.thadaka@gmail.com>2018-03-16 09:09:51 +0530
committerEric Wieser <wieser.eric@gmail.com>2018-03-15 20:39:51 -0700
commitf42e10405f2354e1776f89402ceae0ad0ab637bb (patch)
tree670b467c85c24e2fb125a0345b8e08b1fff05e2a /numpy/lib/tests
parent01541f2822d0d4b37b96f6b42e35963b132f1947 (diff)
downloadnumpy-f42e10405f2354e1776f89402ceae0ad0ab637bb.tar.gz
ENH: Add np.histogram_bin_edges (#10591)
Fixes #10183 Documentation is copied from np.histogram
Diffstat (limited to 'numpy/lib/tests')
-rw-r--r--numpy/lib/tests/test_histograms.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/numpy/lib/tests/test_histograms.py b/numpy/lib/tests/test_histograms.py
index a2c684a20..4f7af214c 100644
--- a/numpy/lib/tests/test_histograms.py
+++ b/numpy/lib/tests/test_histograms.py
@@ -2,7 +2,7 @@ from __future__ import division, absolute_import, print_function
import numpy as np
-from numpy.lib.histograms import histogram, histogramdd
+from numpy.lib.histograms import histogram, histogramdd, histogram_bin_edges
from numpy.testing import (
run_module_suite, assert_, assert_equal, assert_array_equal,
assert_almost_equal, assert_array_almost_equal, assert_raises,
@@ -346,6 +346,20 @@ class TestHistogram(object):
self.do_precision(np.single, np.longdouble)
self.do_precision(np.double, np.longdouble)
+ def test_histogram_bin_edges(self):
+ hist, e = histogram([1, 2, 3, 4], [1, 2])
+ edges = histogram_bin_edges([1, 2, 3, 4], [1, 2])
+ assert_array_equal(edges, e)
+
+ arr = np.array([0., 0., 0., 1., 2., 3., 3., 4., 5.])
+ hist, e = histogram(arr, bins=30, range=(-0.5, 5))
+ edges = histogram_bin_edges(arr, bins=30, range=(-0.5, 5))
+ assert_array_equal(edges, e)
+
+ hist, e = histogram(arr, bins='auto', range=(0, 1))
+ edges = histogram_bin_edges(arr, bins='auto', range=(0, 1))
+ assert_array_equal(edges, e)
+
class TestHistogramOptimBinNums(object):
"""