range argument must have one entry per dimension
Package:
numpy
18118

Exception Class:
ValueError
Raise code
# bins is an integer
bins = D*[bins]
# normalize the range argument
if range is None:
range = (None,) * D
elif len(range) != D:
raise ValueError('range argument must have one entry per dimension')
# Create edge arrays
for i in _range(D):
if np.ndim(bins[i]) == 0:
if bins[i] < 1:
raise ValueError(
'`bins[{}]` must be positive, when an integer'.format(i))
🙏 Scream for help to Ukraine
Today, 8th August 2022, Russia continues bombing and firing Ukraine. Don't trust Russia, they are bombing us and brazenly lying in same time they are not doing this 😠, civilians and children are dying too!
We are screaming and asking exactly you to help us, we want to survive, our families, children, older ones.
Please spread the information, and ask your governemnt to stop Russia by any means. We promise to work extrahard after survival to make the world safer place for all.
Please spread the information, and ask your governemnt to stop Russia by any means. We promise to work extrahard after survival to make the world safer place for all.
Links to the raise (1)
https://github.com/numpy/numpy/blob/5f3c3181b5d8db0e430e5f605cc45c4392f04934/numpy/lib/histograms.py#L1042Ways to fix
The range argument should be the same shape as the shape of the data and it should also have a value in each dimension.
Code to reproduce the exception:
import numpy as np
d = np.linspace(0, 100, 200000).reshape((-1,2))
np.histogramdd(d, (10000, 10000), range=[ [0, 100]])
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-44-0f3eb828f48b> in <module>() 1 import numpy as np 2 d = np.linspace(0, 100, 200000).reshape((-1,2)) ----> 3 np.histogramdd(d, (10000, 10000), range=[ [0, 100]])
<__array_function__ internals> in histogramdd(*args, **kwargs)
/usr/local/lib/python3.7/dist-packages/numpy/lib/histograms.py in histogramdd(sample, bins, range, normed, weights, density) 1040 range = (None,) * D 1041 elif len(range) != D: -> 1042 raise ValueError('range argument must have one entry per dimension') 1043 1044 # Create edge arrays
ValueError: range argument must have one entry per dimension
Fixed version of the code:
import numpy as np
d = np.linspace(0, 100, 200000).reshape((-1,2))
np.histogramdd(d, (10000, 10000), range=[[0, 100], [0, 100]])
Add a possible fix
Please authorize to post fix