Closed mxndrwgrdnr closed 5 years ago
network.set()
method, before calling the cyaccess.initialize_access_var()
. Specifically in line 240, an astype(float)
term can be included when passing the parameters, like this:
self.net.initialize_access_var(name.encode('utf-8'),
df.node_idx.values.astype('int'),
df[name].values.astype('float'))
I like it! I could submit the PR unless anyone else has an open one they want to add this on to?
I don't see a PR about this topic. If you want to I can open one.
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!
Fixed in PR #108.
per @cvanoli the #108 PR released to pandana v0.4.2 has been confirmed to fix the issue.
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 callscyaccess.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.