Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR documents and partially resolves a "buffer dtype mismatch" error that can show up in Windows.
Issue
When I set up the Pandana unit tests to run in a
windows-latest
GitHub Actions environment, I got the following error:Here's the full log: https://github.com/UDST/pandana/runs/1465674701
Diagnosis
The
cyaccess()
constructor raising the error takes NumPy data and passes it to C++ functions. A NumPyint
is normally passed as a C++long
, but there seem to be inconsistencies in Windows and in this case it's being passed as along long
instead.(My understanding is that the inconsistency is on the C++ side -- a NumPy
int
and a C++long
are usually both 64 bits, but in an environment where along
is only 32 bits, theint
is treated as along long
.)Solution
This PR fixes the tests without changing anything in Pandana. In the problematic unit test, we now cast the data to
np.int_
, which is a primitive dtype that's treated as along
on all platforms. (Read more here.) This approach should work in other downstream code as well.It looks like a more thorough solution would be to change the C++ dtypes in Pandana from
long
toint64_t
, which will always align with a 64-bit NumPy int. (See prior link and examples here and here). But that might require changes in a lot of places, so I'd rather not do it unless there's evidence that this is a widespread issue.