UDST / pandana

Pandas Network Analysis by UrbanSim: fast accessibility metrics and shortest paths, using contraction hierarchies :world_map:
http://udst.github.io/pandana
GNU Affero General Public License v3.0
387 stars 83 forks source link

Force convert value columns to float for accessibility variables #105

Closed mxndrwgrdnr closed 5 years ago

mxndrwgrdnr commented 5 years ago

Feature request:

Currently Pandana can only perform an accessibility calculation on a network using a table where the variable being aggregated is type Float, as seen here: https://github.com/UDST/pandana/blob/master/src/cyaccess.pyx#L120-L125

It would be great if the network.set() method here, or any other method that calls cyaccess.initialize_access_var() for that matter, could first do a data type conversion for ints to floats in the case that the value column is an int.

Jobs counts, for example, will always be integers, and if they are stored as such, Pandana accessibility calculations fail. Currently we have to force ints to floats manually before using them for network calculations.

cvanoli commented 5 years ago
mxndrwgrdnr commented 5 years ago

I like it! I could submit the PR unless anyone else has an open one they want to add this on to?

cvanoli commented 5 years ago

I don't see a PR about this topic. If you want to I can open one.

smmaurer commented 5 years ago

Some more perspective on this: I was talking with @janowicz, who says there didn't used to be any problem using ints as node values. And indeed, it looks like values were automatically cast correctly back in Pandana 0.3. (This might have been unofficial, though -- the docstrings still specified floats.)

Pandana 0.3: network.py#L252-L255 Pandana 0.4.1: network.py#L240-L242

It looks like probably the C++ code was changed to use 64-bit data types, and when the Python code was adapted the casting was accidentally dropped here. Good that we're fixing it in PR #108!

smmaurer commented 5 years ago

Fixed in PR #108.

sablanchard commented 5 years ago

per @cvanoli the #108 PR released to pandana v0.4.2 has been confirmed to fix the issue.