8000 Bugfix: Add missing case for simulations starting after the input data by zner0L · Pull Request #4 · PIK-LPJmL/pycoupler · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Bugfix: Add missing case for simulations starting after the input data #4

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

zner0L
Copy link
Collaborator
@zner0L zner0L commented Jun 23, 2025

If pycoupler is trying to run a simulation on a dataset that starts before the simulation period, but does contain it, it will fail with:

File "[…]/lib/python3.12/site-packages/pycoupler/coupler.py", line 840, in _copy_input
    str(cut_start_year),
UnboundLocalError: cannot access local variable 

This is because the case is not covered by the if statement and then cut_start_year in no set.

This pull requests fixes this and adds further explaining comments.

Copy link
codecov bot commented Jun 27, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.28%. Comparing base (323f3ac) to head (32c9d64).
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main       #4      +/-   ##
==========================================
- Coverage   81.33%   81.28%   -0.05%     
==========================================
  Files           9        9              
  Lines        1500     1507       +7     
==========================================
+ Hits         1220     1225       +5     
- Misses        280      282       +2     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator
@jnnsbrr jnnsbrr left a comment

Choose a reason for hiding this comment

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

Looks good so far, again one small test and rerun the formatting that it should be good to go. Thanks for the rearrangement, that looks much cleaner!

cut_start_year = start_year
cut_end = cut_end_year = min(meta_data.lastyear, end_year)
else:
raise ValueError("Unexpected start_year and end_year")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you please add a test here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is actually unreachable and can therefore be removed.

@zner0L zner0L requested a review from jnnsbrr July 3, 2025 10:56
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
0