summaryrefslogtreecommitdiff
path: root/numpy/lib/histograms.py
diff options
context:
space:
mode:
authorMatthew Bowden <bowdenm@spu.edu>2018-10-10 10:07:03 -0700
committerMatthew Bowden <bowdenm@spu.edu>2018-10-10 10:07:03 -0700
commite4e897fa1740ee4efaa276457debda9b8707b457 (patch)
treed567d4599f91615aeb05233554aeece5d13df623 /numpy/lib/histograms.py
parentcb9add3de86a5b886e08b5b649be7e6ccdf5f927 (diff)
downloadnumpy-e4e897fa1740ee4efaa276457debda9b8707b457.tar.gz
BUG: Allow boolean subtract in histogram
Convert bool to uint at start, rather than attempt a XOR Only check type against np.bool_ Refactor warnings check
Diffstat (limited to 'numpy/lib/histograms.py')
-rw-r--r--numpy/lib/histograms.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/numpy/lib/histograms.py b/numpy/lib/histograms.py
index f03f30fb0..6a66e4a73 100644
--- a/numpy/lib/histograms.py
+++ b/numpy/lib/histograms.py
@@ -220,6 +220,14 @@ _hist_bin_selectors = {'auto': _hist_bin_auto,
def _ravel_and_check_weights(a, weights):
""" Check a and weights have matching shapes, and ravel both """
a = np.asarray(a)
+
+ # Ensure that the array is a "subtractable" dtype
+ if a.dtype == np.bool_:
+ warnings.warn("Converting input from {} to {} for compatibility."
+ .format(a.dtype, np.uint8),
+ RuntimeWarning, stacklevel=2)
+ a = a.astype(np.uint8)
+
if weights is not None:
weights = np.asarray(weights)
if weights.shape != a.shape: