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

Clean parsers #506

Merged
merged 35 commits into from
Oct 30, 2023
Merged

Clean parsers #506

merged 35 commits into from
Oct 30, 2023

Conversation

brynpickering
Copy link
Member

Refactoring of the expression and where string parsers to be easier to maintain in future.

Summary of changes in this pull request:

  • Move to an abstract base class for our parsers, so they have the ability to output an xarray dataarray or a string (for latex math), and anything downstream can expect one of those types
  • Move constraint expression setting to the expression parsing, so that we get one dataarray (of comparison expressions) instead of an lhs/rhs. Keeps the data structure in line with the other optimisation problem components.
  • Rename as_latex to as_math_string which I think is more useful a description.

Reviewer checklist:

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

sjpfenninger
sjpfenninger previously approved these changes Oct 27, 2023
Copy link
Member

@sjpfenninger sjpfenninger left a comment

Choose a reason for hiding this comment

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

Maybe also rename the TestAsLatex class

Base automatically changed from feature-custom-math-examples to main October 30, 2023 09:28
@brynpickering brynpickering dismissed sjpfenninger’s stale review October 30, 2023 09:28

The base branch was changed.

@codecov
Copy link

codecov bot commented Oct 30, 2023

Codecov Report

Merging #506 (dfc74b6) into main (45436c9) will increase coverage by 0.29%.
The diff coverage is 98.02%.

@@            Coverage Diff             @@
##             main     #506      +/-   ##
==========================================
+ Coverage   92.42%   92.72%   +0.29%     
==========================================
  Files          32       32              
  Lines        4120     4204      +84     
  Branches      969      965       -4     
==========================================
+ Hits         3808     3898      +90     
+ Misses        197      194       -3     
+ Partials      115      112       -3     
Files Coverage Δ
src/calliope/backend/backend_model.py 97.46% <100.00%> (+0.05%) ⬆️
src/calliope/backend/latex_backend_model.py 96.00% <100.00%> (-0.10%) ⬇️
src/calliope/backend/parsing.py 98.66% <100.00%> (+0.04%) ⬆️
src/calliope/backend/pyomo_backend_model.py 95.67% <100.00%> (+0.01%) ⬆️
src/calliope/core/model.py 93.71% <100.00%> (ø)
src/calliope/backend/helper_functions.py 97.81% <97.14%> (-0.39%) ⬇️
src/calliope/backend/expression_parser.py 98.00% <98.46%> (+2.56%) ⬆️
src/calliope/backend/where_parser.py 97.67% <96.61%> (-0.85%) ⬇️

@brynpickering brynpickering merged commit ea55acc into main Oct 30, 2023
9 checks passed
@brynpickering brynpickering deleted the clean-parsers branch October 30, 2023 13:03
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.

2 participants