diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2018-10-11 14:03:45 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-11 14:03:45 -0500 |
commit | 2ae00145aa77a08cb1c504152fb8d910e0b3c346 (patch) | |
tree | e163f59c6ece2f2435f3196092a6313102f1db0c /numpy/lib/histograms.py | |
parent | eb2bd11870731ea19a0eee72e616c7deb00f6c54 (diff) | |
parent | 4141e24fc201f8cf76180ca69eaa2d89eafaee58 (diff) | |
download | numpy-2ae00145aa77a08cb1c504152fb8d910e0b3c346.tar.gz |
Merge pull request #12116 from shoyer/array-function-numpy-lib
ENH: __array_function__ support for np.lib, part 1/2
Diffstat (limited to 'numpy/lib/histograms.py')
-rw-r--r-- | numpy/lib/histograms.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/numpy/lib/histograms.py b/numpy/lib/histograms.py index 6a66e4a73..1ff25b81f 100644 --- a/numpy/lib/histograms.py +++ b/numpy/lib/histograms.py @@ -8,6 +8,7 @@ import warnings import numpy as np from numpy.compat.py3k import basestring +from numpy.core.overrides import array_function_dispatch __all__ = ['histogram', 'histogramdd', 'histogram_bin_edges'] @@ -400,6 +401,11 @@ def _search_sorted_inclusive(a, v): )) +def _histogram_bin_edges_dispatcher(a, bins=None, range=None, weights=None): + return (a, bins, weights) + + +@array_function_dispatch(_histogram_bin_edges_dispatcher) def histogram_bin_edges(a, bins=10, range=None, weights=None): r""" Function to calculate only the edges of the bins used by the `histogram` function. @@ -594,6 +600,12 @@ def histogram_bin_edges(a, bins=10, range=None, weights=None): return bin_edges +def _histogram_dispatcher( + a, bins=None, range=None, normed=None, weights=None, density=None): + return (a, bins, weights) + + +@array_function_dispatch(_histogram_dispatcher) def histogram(a, bins=10, range=None, normed=None, weights=None, density=None): r""" @@ -846,6 +858,12 @@ def histogram(a, bins=10, range=None, normed=None, weights=None, return n, bin_edges +def _histogramdd_dispatcher(sample, bins=None, range=None, normed=None, + weights=None, density=None): + return (sample, bins, weights) + + +@array_function_dispatch(_histogramdd_dispatcher) def histogramdd(sample, bins=10, range=None, normed=None, weights=None, density=None): """ |