-
Notifications
You must be signed in to change notification settings - Fork 1
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
River bug #177
River bug #177
Conversation
swmmanywhere/prepare_data.py
Outdated
graph = ox.graph_from_bbox( | ||
bbox = (north, south, east, west), | ||
truncate_by_edge=True, | ||
custom_filter='["waterway"]') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend adding retain_all=True
for getting rivers, since by default it will only keep the largest connected network, which is fine for streets but not necessarily for other network types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
huh, didn't realise that - thanks!
# Mock ox.graph_from_bbox | ||
with mock.patch.object(ox, 'graph_from_bbox', return_value=mock_graph): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When using pytest
, exceptions can be checked like so:
def test_no_river():
bbox = (0.0402, 51.55759, 0.09825591114207548, 51.6205)
with pytest.raises(ValueError, match="Found no graph nodes"):
_ = ox.graph_from_bbox(bbox)
G = downloaders.download_river(bbox)
assert G.size() == 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep - though that will actually run the download which the testing module aims to avoid - I will add this test with @pytest.mark.downloads
- these are separate tests to test the actual downloads.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm I'm not sure I fully understand actually - this test isn't checking an exception. The graph_from_bbox
will raise an exception inside download_river
, causing it to return an empty graph - which is what the test is checking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding of the test was that you want to first check if the ox.graph_from_bbox
indeed raises ValueError
and then run the same with downloaders.download_river
and check if it handles the exception correctly and returns an empty graph.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding getting data with osmnx
, I recommend enabling its caching. You can set it with osmnx.settings.use_cache = True
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now in issue #183
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Just agreed with @cheginit comment on using pytest
features to test exceptions.
retain all
Description
Crashes when no rivers inside the bbox. Though this is fine now that we have option to use lowest elevation point.
Now fixed and tested