Description
As reported in gboeing/osmnx#196, while running OSMnx's code, which directly references numpy.histogram().
It's tricky to reproduce without fully using the jupyter notebook in the example, but I'll do my best to summarise and I'm happy to test things and report back if required. I'm sorry if this issue is filed in a substandard way.
Reproducing code example:
While running the jupyter notebook above, which aims to calculate a histogram over a set of bearings extracted from Open Street Map, I have the following behaviour.
This works:
np.histogram(bearings, bins=bins, range=(bearings.min(), bearings.max()))
but this doesn't
np.histogram(bearings, bins=bins)
.
My understanding from the documentation is that the two calls should work exactly the same, so I'm puzzled.
Error message:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-7-c59ecd43a7f0> in <module>()
9 # plot each city's polar histogram
10 for ax, place in zip(axes, sorted(places.keys())):
---> 11 polar_plot(ax, bearings[place], title=place)
12
13 # add super title and save full image
<ipython-input-5-3f02bf8f385b> in polar_plot(ax, bearings, n, title)
3
4 bins = [ang * 360 / n for ang in range(0, n + 1)]
----> 5 count = count_and_merge(n, bearings)
6 _, division = np.histogram(bearings, bins=bins)
7 frequency = count / count.sum()
<ipython-input-6-c7da03125f04> in count_and_merge(n, bearings)
4 n = n * 2
5 bins = [ang * 360 / n for ang in range(0, n + 1)]
----> 6 count, _ = np.histogram(bearings, bins=bins)
7
8 # move the last bin to the front, so eg 0.01° and 359.99° will be binned together
~/anaconda3/envs/OSMNX/lib/python3.6/site-packages/numpy/lib/function_base.py in histogram(a, bins, range, normed, weights, density)
668 if not np.all(np.isfinite([first_edge, last_edge])):
669 raise ValueError(
--> 670 'range parameter must be finite.')
671 if first_edge == last_edge:
672 first_edge -= 0.5
ValueError: range parameter must be finite.
Numpy/Python version information:
!pip list returns
numpy 1.14.5
conda list returns
numpy 1.14.5
numpy 1.13.1 py36_0
'import sys, numpy; print(numpy.version, sys.version)' returns
1.14.5 3.6.5 | packaged by conda-forge | (default, Apr 6 2018, 13:44:09)
[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)]