gboeing / osmnx-examples

Gallery of OSMnx tutorials, usage examples, and feature demonstations.
https://osmnx.readthedocs.io
MIT License
1.54k stars 522 forks source link

count_and_merge to return array of floats not ints #14

Closed MellerYaniv closed 6 years ago

MellerYaniv commented 6 years ago

if floats are not enforced frequency in polar_plot will be an array of zeros

niryuu commented 6 years ago

This might be important, because in some case I faced that charts are not rendered with Integer value

gboeing commented 6 years ago

Is this a Python 2.x only problem?

niryuu commented 6 years ago

I guess so. I used Python 2.7 because my 3.7 environment is broken. On python 2.7, decimals are discarded when we use / division between int and int. So frequency = count / count.sum() returns 0 in Python 2 for almost case because it is normalized to 0.0 < frequency < 1.0. (I got array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) for actual data) On Python 3, results of / are converted from int to float automatically so this issue won't occur.

gboeing commented 6 years ago

Thanks folks. As Python 2 support ends next year, for the sake of not introducing code clutter I'm going to leave the example notebooks Python 3 only compatible for now.