-
Notifications
You must be signed in to change notification settings - Fork 3
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
Fix geometry and indexing of new/modified roadway nodes/links #310
Conversation
- make easier to find various tests, utils and roadway network - troubleshooting test_model_roadway.py
Fixed: - indexing when created new links and nodes - merge that was creating excess records b/c it should have been an inner join Also: - added missing node from small ex network - made tests quicker by using small example network instead of large network - edited tests to be flexible to network tested - Made networks and directories test fixtures for simplicity
Because we are using separate files, don't need marks.
As separate from unique_model_link_identifiers so that we can use identifiers such as osm_link_id which may not be unique because of link splitting, but are sufficient for things like specifying links for project cards.
Fixed: - Querying if "set" or "existing" or "change" is a key, not if the value of it produces a True b/c a value of 0 is a valid "set"...but produces a False. Also: - Updated roadway change tests to actually test if change is accurate.
- To better manage and run them, tests for different apply methods are separated in different files - managed lane tests now have explicit assert statements testing actual truthiness Also: - convenience method added to RoadwayNetwork to count number of managed lane links
- Added RoadwayNetwork class variables for properties to coerce - Added class function to do coercion and call it at read-in and write out Also: - fixed bug in how test was looping
various minor bug fixes
- currently failing but not fixing as part of this PR
Includes: - added validation of new links and nodes - better handling of unique IDs - better structure for geometry creation/updating Also: - corrected occurrences of in/outboundReferenceId --> in/outboundReferenceId*s* - Added a simple roadway addition test
- fixed testing data to comply with roadway network requirements - added step to make sure new nodes had correct geometry - refactored how to delete nodes and links to be more efficient rather than searching through whole network for each selection - refactored how to search for shapes that should be deleted when links are - added better testing to make sure it was 'safe' to delete nodes Also: - black
@lmz @DavidOry @i-am-sijia - This is passing the roadway tests on my machine. Def not perfect but better and more resilient. |
tests\test_utils.py fails at test_point_from_xy(): After I change the |
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.
- ran all tests locally, proposed changes necessary for tests to pass
- the returns in transitnetwork.py seem inconsistent, after introducing
net
which is a deepcopy ofself
- the roadwaynetwork.py has tons of changes, which I have not yet detailly reviewed, but the tests all passed.
- the
SCRATCH_DIR
in "test_transit.py" and "test_scenario.py" does not exist by default. It will be created after test_io.py is run which calls the pytest fixture. We need to be careful about the test dependencies when migrating to GitHub Actions.
network_wrangler/transitnetwork.py
Outdated
return updated_network | ||
q = net.feed.frequencies.trip_id.isin(freq["trip_id"]) | ||
|
||
net.loc[q, properties["property"]] = build_value |
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.
net.loc[q, properties["property"]] = build_value | |
net.feed.frequencies.loc[q, properties["property"]] = build_value |
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.
good catch!
SHAPES = os.path.join(EX_DIR, "shape.geojson") | ||
|
||
|
||
def read_ex_net(benchmark): |
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.
Where is fixture benchmark
defined?
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.
Benchmark is a keyword for pytest benchmark for timing the tests.
net = copy.deepcopy(small_net) | ||
net.links_df["my_ad_hoc_field"] = 22.5 | ||
|
||
print("Network with field...\n ", net.links_df["my_ad_hoc_field"][0:5]) |
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.
print("Network with field...\n ", net.links_df["my_ad_hoc_field"][0:5]) | |
print("Network with field...\n ", net.links_df["my_ad_hoc_field"].iloc[0:5]) |
""" | ||
net = copy.deepcopy(self) |
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.
Why do we need a deepcopy here? The same function in roadwaynetwork.py does not deepcopy.
network_wrangler/transitnetwork.py
Outdated
net.feed.shapes = shapes | ||
net.feed.stops = stops | ||
net.feed.stop_times = stop_times | ||
return net |
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.
The indentation of this return seems off, should we move it outside of the if?
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.
good catch
@@ -15,7 +15,7 @@ | |||
"roadway": "residential", | |||
"length": 80.935, | |||
"maxspeed": "", | |||
"name": "Arkwright Street,North Rivoli Street", | |||
"name": "Arkwright Street", |
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.
Why shorten the name?
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.
Just to differentiate from the larger network when I'm reading errors (this net is really not "real")
Co-authored-by: Sijia Wang <[email protected]>
…/network_wrangler into add-update-node-geometry
- did slightly different than suggestion so that would work if index value changed
- minor bug fixes
@i-am-sijia I think this is ready for you to re-review |
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.
Just one small issue. Otherwise looks good.
Co-authored-by: Sijia Wang <[email protected]>
…into add-update-node-geometry
📓 that most of the transit tests aren't passing yet and will be worked on in a separate PR |
@e-lo I added a lot of transit related codes to MTC's network wrangler: https://github.com/BayAreaMetro/network_wrangler/tree/generic_agency/network_wrangler, so that it can actually apply real transit project cards. it might be useful to include those in the transit related PR. |
@i-am-sijia I created an issue where you can add more detail if you think it would be useful: #319 |
This PR contains major refactoring of several key pieces of RoadwayNetwork to be more efficient, resilient and understandable.
Improves:
num_managed_lane_links()
method to easily test for managed lanes ([Refactor] Separate out and be more rigorous about checking for managed lane network presence #294)Fixes:
...still a lot to do and that this PR doesn't fix.