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

Add how to update master_compute_data.pkl to CONTRIBUTING.rst #888

Closed
dpanici opened this issue Feb 19, 2024 · 0 comments · Fixed by #922
Closed

Add how to update master_compute_data.pkl to CONTRIBUTING.rst #888

dpanici opened this issue Feb 19, 2024 · 0 comments · Fixed by #922
Assignees
Labels
documentation Add documentation or better warnings etc.

Comments

@dpanici
Copy link
Collaborator

dpanici commented Feb 19, 2024

When the outputs of the compute quantities tested by the test_compute_everything test are changed in a PR, that test will fail. The three(? maybe more) reasons this could occur are:

  • the PR was not intended to change how things are computed, but messed up something unexpected and now the compute quantities are incorrect, if you did not expect things to change in the PR then look into why these differences are happening and fix the PR
  • The PR updated the way one of the existing compute index quantities are computed (either by a redefinition or perhaps fixing an error present in master)
  • The PR added a new class parametrization (such as a new subclass of Curve like LinearCurve etc)

If the 2nd case is the reason, then you must update the master_compute_data.pkl file with the correct quantities being computed by your PR:

  • First , run the test with pytest tests -k test_compute_everything and inspect the compute quantities whose values are in error, to ensure that only the quantities you expect to be different are shown (and that the new values are indeed the correct ones, you should have a test elsewhere for that though).
  • If the values are as expected and only the expected compute quantities are different, then change the block
except AssertionError as e:
    error = True
    print(e)

with

except AssertionError as e:
    error = False
    update_master_data = True
    print(e)
  • rerun the test pytest tests -k test_compute_everything , now any compute quantity that is different between the PR and master will be updated with the PR value
  • git restore tests/test_compute_funs.py to remove the change you made to the test
  • git add tests/inputs/master_compute_data.pkl and commit to commit the new data file

If the 3rd case is the reason, then you must simply add the new parametrization to the test_compute_everything test

  • things dictionary with a sensible example instance of the class to use for the test, and
  • to the grid dictionary with a sensible default grid to use when computing the compute quantities for the new class
  • Then, rerunning the test pytest tests -k test_compute_everything will add the compute quantities for the new class and save them to the .pkl file
  • git add tests/inputs/master_compute_data.pkl and commit to commit the new data file
@dpanici dpanici added the documentation Add documentation or better warnings etc. label Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Add documentation or better warnings etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant