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

Validation zhuzh-up: link attribute value checks #141

Merged
merged 14 commits into from
Sep 23, 2022

Conversation

KasiaKoz
Copy link
Collaborator

@KasiaKoz KasiaKoz commented Aug 25, 2022

Resolves #19 - Check for infinite values
Resolves #82 - Check for negative values

As a bonus this PR also adds checks for fractional values and re-organises the functions that provide the conditions for the checks - it was starting to get very crowded in the validation method.

Fixed a bug I didn't know existed - the method was not testing nested values for additional attributes, it's good that I caught that now that we're using them more!

It also improves the logging of any issues with the network, e.g.:

2022-08-25 16:32:52,084 - Checking validity of the Network
2022-08-25 16:32:52,084 - Checking validity of the Network graph
2022-08-25 16:32:52,084 - Defaulting to checking graph connectivity for modes: ['car', 'walk', 'bike']. You can change this by passing a `modes` param
2022-08-25 16:32:52,084 - Checking network connectivity for mode: car
2022-08-25 16:32:52,084 - The graph for mode: car has: 3 connected components, 1 sinks/dead_ends and 1 sources/unreachable nodes.
2022-08-25 16:32:52,084 - The graph has more than one connected component for mode car! If this is not expected, consider using the `connect_components` method to connect the components, or `retain_n_connected_subgraphs` with `n=1` to extract the largest component
2022-08-25 16:32:52,084 - Checking network connectivity for mode: walk
2022-08-25 16:32:52,084 - The graph for mode: walk has: 0 connected components, 0 sinks/dead_ends and 0 sources/unreachable nodes.
2022-08-25 16:32:52,084 - Checking network connectivity for mode: bike
2022-08-25 16:32:52,084 - The graph for mode: bike has: 0 connected components, 0 sinks/dead_ends and 0 sources/unreachable nodes.
2022-08-25 16:32:52,085 - Checking link values for `length`
2022-08-25 16:32:52,085 - 1 of links have zero values for `length`
2022-08-25 16:32:52,085 - 1 of links have fractional values for `length`
2022-08-25 16:32:52,085 - Checking link values for `capacity`
2022-08-25 16:32:52,085 - 1 of links have negative values for `capacity`
2022-08-25 16:32:52,085 - 1 of links have infinite values for `capacity`
2022-08-25 16:32:52,085 - Checking link values for `freespeed`
2022-08-25 16:32:52,085 - 1 of links have zero values for `freespeed`
2022-08-25 16:32:52,085 - 2 of links have negative values for `freespeed`
2022-08-25 16:32:52,086 - Checking link values for `modes`
2022-08-25 16:32:52,086 - Checking link values for `{'attributes': {'osm:way:id': 'text'}}`
2022-08-25 16:32:52,086 - 1 of links have zero values for `{'attributes': {'osm:way:id': 'text'}}`

Compared to:

2022-08-25 16:32:15,334 - Checking validity of the Network
2022-08-25 16:32:15,335 - Checking validity of the Network graph
2022-08-25 16:32:15,335 - Checking network connectivity for mode: car
2022-08-25 16:32:15,336 - Checking network connectivity for mode: walk
2022-08-25 16:32:15,336 - Checking network connectivity for mode: bike
2022-08-25 16:32:15,337 - 1 of links have values of 0 for `length`
2022-08-25 16:32:15,337 - 1 of links have values of 0 for `freespeed`
2022-08-25 16:32:15,337 - 1 of links have values of 0 for `id`

before.

Nb. More PRs in the validation theme coming up soon. I'm leaving updating the notebook: 6.1. Validating Network: MATSim Specific to last in the series.

@KasiaKoz KasiaKoz requested review from mfitz and ana-kop August 25, 2022 16:06
@KasiaKoz KasiaKoz changed the title Lab 1249 validation zhuzh up Validation zhuzh-up: link attribute value checks Aug 25, 2022
Copy link
Contributor

@mfitz mfitz left a comment

Choose a reason for hiding this comment

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

I've added a few minor comments - should be small changes if you agree with them.

genet/core.py Outdated Show resolved Hide resolved
genet/core.py Outdated Show resolved Hide resolved
genet/core.py Show resolved Hide resolved
genet/core.py Outdated Show resolved Hide resolved
genet/utils/dict_support.py Outdated Show resolved Hide resolved
tests/test_core_network.py Outdated Show resolved Hide resolved
tests/test_core_network.py Outdated Show resolved Hide resolved
tests/test_core_network.py Show resolved Hide resolved
tests/test_core_network.py Show resolved Hide resolved
tests/test_core_network.py Show resolved Hide resolved
@KasiaKoz KasiaKoz requested a review from mfitz September 8, 2022 16:15
@KasiaKoz
Copy link
Collaborator Author

KasiaKoz commented Sep 8, 2022

Some minor updates plus:

  • added dataclasses to represent conditions for testing network link attributes
  • added one more condition checking for None values

@KasiaKoz KasiaKoz merged commit adb9b10 into main Sep 23, 2022
@KasiaKoz KasiaKoz deleted the lab-1249-validation-zhuzh-up branch September 23, 2022 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Check attributes for negative values need check for np.inf linkspeeds
2 participants