Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bh.numpy.histogram() fails when weights is supplied as a numpy array #471

Closed
marcpaterno opened this issue Nov 14, 2020 · 2 comments · Fixed by #472
Closed

bh.numpy.histogram() fails when weights is supplied as a numpy array #471

marcpaterno opened this issue Nov 14, 2020 · 2 comments · Fixed by #472
Labels
bug Something isn't working

Comments

@marcpaterno
Copy link

When called with weights, and with weights being a numpy array, bh.numpy.histogram() fails. The error is:

~/repos/pandana/work-venv/lib/python3.9/site-packages/boost_histogram/numpy.py in histogram(a, bins, range, normed, weights, density, **kwargs)
    108
    109     # numpy 1d histogram returns integers in some cases
--> 110     if "storage" not in kwargs and not (weights or normed or density):
    111         kwargs["storage"] = _storage.Int64()
    112

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

I believe the testing of weights, normed and density should be comparing to None:

--> 110     if "storage" not in kwargs and weights is None and normed is None and density is None):
    111         kwargs["storage"] = _storage.Int64()
    112
@henryiii
Copy link
Member

Ahh, this is in numpy.py. I was quite sure I had tests for this for the regular histograms. Okay, yes, quite likely a mistake! Needs a test or two as well. Thanks!

henryiii added a commit that referenced this issue Nov 19, 2020
@henryiii
Copy link
Member

Normed and density can't be an array, and added a test. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants