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

Sort ref ordering within components #623

Merged
merged 4 commits into from
Jun 28, 2024

Conversation

brynpickering
Copy link
Member

#update

Fixes #616

Summary of changes in this pull request

  • Rebuild references in the order they appear in the backend model dataset, which is the same order they are added to it (so expressions that depend on previous expressions will be built in the correct order).
  • Remove investment cost from demands in the dummy test model - this leads to a change in shadow prices which I have updated, but there's no way of knowing if the new shadow prices (or, indeed, the old ones) are correct.
  • Force verbose strings on rebuilt backend model components, if verbose strings have already been triggered.

Reviewer checklist

  • Test(s) added to cover contribution
  • Documentation updated
  • Changelog updated
  • Coverage maintained or improved

Copy link

codecov bot commented Jun 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.34%. Comparing base (872978d) to head (8879a79).
Report is 44 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #623      +/-   ##
==========================================
- Coverage   95.85%   95.34%   -0.52%     
==========================================
  Files          24       24              
  Lines        3619     3650      +31     
  Branches      788      734      -54     
==========================================
+ Hits         3469     3480      +11     
+ Misses         86       82       -4     
- Partials       64       88      +24     
Files with missing lines Coverage Δ
src/calliope/backend/backend_model.py 98.07% <100.00%> (+0.16%) ⬆️
src/calliope/backend/pyomo_backend_model.py 95.59% <100.00%> (+0.17%) ⬆️

... and 3 files with indirect coverage changes

Copy link
Contributor

@irm-codebase irm-codebase left a comment

Choose a reason for hiding this comment

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

Few comments on the tests.

caplog.set_level(logging.DEBUG)
simple_supply.backend.verbose_strings()

def _check_components(true_or_false: bool):
Copy link
Contributor

Choose a reason for hiding this comment

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

A tad verbose... I'd say the stages before update_parameter are not needed (or a separate test?).

Suggestions:

  • I'd keep the docstring to a short sentence, like "Check that parameter re-definition propagates to constraints and obj. function"
  • re-arrange so that asserts are done once, not inside for loops.
  • avoid defining functions inside the test.
  • Change 0 (which could be a default) to something rare. I like 0xDEADBEEF, a common debug integer.

@brynpickering
Copy link
Member Author

Thanks for the comments @irm-codebase - updated!

irm-codebase
irm-codebase previously approved these changes Jun 28, 2024
Copy link
Contributor

@irm-codebase irm-codebase left a comment

Choose a reason for hiding this comment

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

Great changes! Approved.

@brynpickering brynpickering merged commit 0f9f586 into main Jun 28, 2024
10 of 11 checks passed
@brynpickering brynpickering deleted the fix-parameter-update-ref-order branch June 28, 2024 11:11
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.

model.backend.update_parameter does not propagate in all equations
2 participants