diff options
author | Stephan Hoyer <shoyer@google.com> | 2018-10-08 12:52:55 -0700 |
---|---|---|
committer | Stephan Hoyer <shoyer@google.com> | 2018-10-08 12:52:55 -0700 |
commit | 4141e24fc201f8cf76180ca69eaa2d89eafaee58 (patch) | |
tree | 3ee2de98a23d2972c9894332cddd9ee0969dc0ad /numpy/lib/histograms.py | |
parent | 2f4bc6f1d561230e9e295ce0d49fef5c4deb7ea0 (diff) | |
download | numpy-4141e24fc201f8cf76180ca69eaa2d89eafaee58.tar.gz |
ENH: __array_function__ for np.lib, part 1
np.lib.arraypad through np.lib.nanfunctions
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 f03f30fb0..19a77a3c9 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'] @@ -392,6 +393,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. @@ -586,6 +592,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""" @@ -838,6 +850,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): """ |