UDST / urbanaccess

A tool for GTFS transit and OSM pedestrian network accessibility analysis by UrbanSim
https://udst.github.io/urbanaccess/index.html
GNU Affero General Public License v3.0
239 stars 57 forks source link

TypeError when generating plot colors #21

Closed kuanb closed 7 years ago

kuanb commented 7 years ago

Traceback:

Traceback (most recent call last):
  File "<stdin>", line 7, in <module>
  File "urbanaccess/plot.py", line 163, in col_colors
    colors = [color_list[cat] for cat in categories]
TypeError: list indices must be integers, not numpy.float64

This happens because, in col_colors, this operation (colors = [color_list[cat] for cat in categories]), requires that each cat not be a float. Yet, if you were to print the type of each prior, you would see that they can result in for loops.

Here is a quick example of what a segment of that would look like, were you to log the type of each:

<type 'numpy.float64'>
0.0
<type 'numpy.float64'>
0.0
<type 'numpy.float64'>
0.0
<type 'numpy.float64'>
0.0
<type 'numpy.float64'>
nan

...which identifies another issue! As you can see in the last logged float, it's a nan. These can't be converted to an integer, so we need to decide what to do with them. I think, at least for the purposes of binning, they should be pruned from the parent data set and removed from the binning process.

sablanchard commented 7 years ago

Thank you Kuan, good catch. Great solution. Will approve the PR if you wanted to add in the solution to https://github.com/UDST/urbanaccess/issues/20.

sablanchard commented 7 years ago

Fixed with PR #22