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

write_inp_section changes - don't change the Polygons header #182

Merged

Conversation

BuczynskiRafal
Copy link
Collaborator

@BuczynskiRafal BuczynskiRafal commented Jan 19, 2023

Closes #181

@BuczynskiRafal
Copy link
Collaborator Author

@aerispaha I'm not sure how to test the solution. Can I find a method in swmmio that reads the header in the inp file to compare it with the header after doing replace_inp_section?

@bemcdonnell
Copy link
Member

@BuczynskiRafal, I'm guessing you're adding this feature because of some kind of text version control issue. I think the best way to test it is to add a second INP file with [POLYGONS] and check the outputs from that. You can use a simple file parser to assert that the text found is either your [Polygons] or [POLYGONS]

@BuczynskiRafal BuczynskiRafal marked this pull request as ready for review January 28, 2023 07:29
@BuczynskiRafal
Copy link
Collaborator Author

@aerispaha @bemcdonnell Please review my PR. Thank you.

@aerispaha aerispaha self-requested a review January 29, 2023 20:48
Copy link
Member

@aerispaha aerispaha left a comment

Choose a reason for hiding this comment

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

@BuczynskiRafal thanks for this great contribution to swmmio! Overall, your bug fix seems to work great.

My only request is that we remove the new swmmio/tests/data/example_polygons.inp file from this PR, and use a test inp file that already exists in the repo. I'd also suggest we refactor the unit test as I described below for a couple reasons:

  1. this way test files aren't left behind if this test fails
  2. I'd prefer to emphasize the model.inp.<section> = <dataframe> pattern for updating models, rather than using the replace_inp_section function directly.

Let me know what you think!

swmmio/tests/data/__init__.py Outdated Show resolved Hide resolved
swmmio/tests/data/model_full_features_network_xy.inp Outdated Show resolved Hide resolved
swmmio/tests/test_version_control.py Show resolved Hide resolved
@BuczynskiRafal
Copy link
Collaborator Author

@aerispaha Thanks for the good points. I've made the changes.

Copy link
Member

@aerispaha aerispaha left a comment

Choose a reason for hiding this comment

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

This looks great, @BuczynskiRafal! I'll get this integrated into the next release asap

@aerispaha aerispaha merged commit 34f9c96 into pyswmm:master Feb 2, 2023
@BuczynskiRafal BuczynskiRafal deleted the fix_overwrite_polygons_header branch February 3, 2023 04:30
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.

Polygons header overwrite bug
3 participants