Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support strings in elements.get_node_id() #522

Merged
merged 4 commits into from
Nov 26, 2023

Conversation

jGaboardi
Copy link
Member

This PR resolves #519

@jGaboardi jGaboardi self-assigned this Nov 25, 2023
@jGaboardi jGaboardi added bug Something isn't working and removed rough edge labels Nov 25, 2023
@jGaboardi
Copy link
Member Author

Seeing now that the line isn't being hit by any tests...

Copy link

codecov bot commented Nov 25, 2023

Codecov Report

Merging #522 (5250f7a) into main (891156e) will increase coverage by 0.0%.
The diff coverage is 100.0%.

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main    #522   +/-   ##
=====================================
  Coverage   97.5%   97.5%           
=====================================
  Files         24      24           
  Lines       4115    4123    +8     
=====================================
+ Hits        4011    4020    +9     
+ Misses       104     103    -1     
Files Coverage Δ
momepy/elements.py 96.9% <100.0%> (+0.3%) ⬆️
momepy/tests/test_elements.py 100.0% <100.0%> (ø)

@martinfleis
Copy link
Member

It is technically covering a corner case that should not happen when everything is as expected.

We hit it when we don't have a street network edge attached to a building footprint, which happens only if a building is really far away from any street. But we could possibly simulate that by using momepy.get_network_id with a small min_size (that API and implementation there are bad...)

@jGaboardi
Copy link
Member Author

It is technically covering a corner case that should not happen when everything is as expected.

We hit it when we don't have a street network edge attached to a building footprint, which happens only if a building is really far away from any street. But we could possibly simulate that by using momepy.get_network_id with a small min_size (that API and implementation there are bad...)

Working on creating a synthetic test case now that simply converts some edge IDs in the bubenec streets to NaN.

@jGaboardi
Copy link
Member Author

Passing locally and hitting the offending line.


# test for NaNs within `object` nIDs column
_df_buildings = self.df_buildings.copy()
_df_buildings.loc[[0, 1], "nID"] = pd.NA
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
_df_buildings.loc[[0, 1], "nID"] = pd.NA
_df_buildings["nID"] = _df_buildings["nID"].astype(str)
_df_buildings.loc[[0, 1], "nID"] = pd.NA

Might be worth actually testing for the string ID?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Will push up a new version.

Copy link
Member

@martinfleis martinfleis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@martinfleis martinfleis merged commit a17788a into pysal:main Nov 26, 2023
9 checks passed
@jGaboardi jGaboardi deleted the gh_519_get_node_id branch November 26, 2023 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: get_node_id does not support string IDs
2 participants