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

Require variables and constraints to be specified separately in IncidenceGraphInterface.remove_nodes #3212

Merged
merged 9 commits into from
Apr 9, 2024

Conversation

Robbybp
Copy link
Contributor

@Robbybp Robbybp commented Mar 26, 2024

Fixes

If invalid components (those not contained in the incidence graph, including random objects like lists and tuples), were provided to remove_nodes, we would silently do nothing instead of raising an error.

Summary/Motivation:

The above behavior was present because we weren't calling self._validate_input in remove_nodes. Updating to call self._validate_input would still silently continue if a bad component was provided, and would give a non-helpful error message if a random object was provided.

Changes proposed in this PR:

  • Update _validate_input to give a helpful error message if something that is not in the cached var/con ComponentMaps is provided
  • Call _validate_input in remove_nodes
  • Require that variables and constraints are specified separately. This allows us to raise helpful error messages in _validate_input. The alternative would probably be to have some more complicated, custom error-checking code in remove_nodes directly. I'm considering this breaking change because (a) it makes the method consistent with all the other methods on IncidenceGraphInterface and (b) I don't think many people are using this method.

Legal Acknowledgement

By contributing to this software project, I have read the contribution guide and agree to the following terms and conditions for my contribution:

  1. I agree my contributions are submitted under the BSD license.
  2. I represent I am authorized to make the contributions and grant the license. If my employer has rights to intellectual property that includes these contributions, I represent that I have received permission to make contributions and grant the required license on behalf of that employer.

…ve_nodes`; update to raise error on invalid components
Copy link

codecov bot commented Mar 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.39%. Comparing base (c68ce66) to head (24d3baf).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3212      +/-   ##
==========================================
- Coverage   88.40%   88.39%   -0.01%     
==========================================
  Files         847      847              
  Lines       95285    95309      +24     
==========================================
+ Hits        84232    84252      +20     
- Misses      11053    11057       +4     
Flag Coverage Δ
linux 86.34% <100.00%> (+<0.01%) ⬆️
osx 76.19% <100.00%> (+<0.01%) ⬆️
other 86.53% <100.00%> (-0.01%) ⬇️
win 83.83% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@blnicho blnicho self-requested a review April 2, 2024 18:53
@mrmundt mrmundt self-requested a review April 9, 2024 18:50
@mrmundt mrmundt merged commit 5716566 into Pyomo:main Apr 9, 2024
33 checks passed
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.

4 participants