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

[Bug]: pybamm.Simulation.set_parameters and pybamm.Simulation.set_up_and_parameterise_experiment made private in simulation.py #4489

Merged

Conversation

Akhil-Sharma30
Copy link
Contributor

Description

pybamm.Simulation.set_parameters, pybamm.Simulation.set_up_and_parameterise_experiment and pybamm.Simulation.set_up_and_parameterise_model_for_experiment made private in pybamm/simulation.py
(continuation of #3752 PR)

Fixes #3751

Type of change

Please add a line in the relevant section of CHANGELOG.md to document the change (include PR #) - note reverse order of PR #s. If necessary, also add to the list of breaking changes.

  • New feature (non-breaking change which adds functionality)
  • Optimization (back-end change that speeds up the code)
  • Bug fix (non-breaking change which fixes an issue)

Key checklist:

  • No style issues: $ pre-commit run (or $ nox -s pre-commit) (see CONTRIBUTING.md for how to set this up to run automatically when committing locally, in just two lines of code)
  • All tests pass: $ python run-tests.py --all (or $ nox -s tests)
  • The documentation builds: $ python run-tests.py --doctest (or $ nox -s doctests)

You can run integration tests, unit tests, and doctests together at once, using $ python run-tests.py --quick (or $ nox -s quick).

Further checks:

  • Code is commented, particularly in hard-to-understand areas
  • Tests added that prove fix is effective or that feature works

Copy link
Contributor

@kratman kratman left a comment

Choose a reason for hiding this comment

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

I think the other question for this is what we do about the function names and tests.

Improvements:

I think that if we intend to deprecate the public functions we should:

  1. First rename all the usages to _set_parameters() and _set_up_and_parameterise_experiment()
  2. Create new functions called set_parameters() and setup_and_parametrise_experiments()
  3. The new functions should be more like this
    def set_parameters(...):
        msg = "pybamm.simulation.set_parameters() is deprecated"
        warnings,warn(msg, DeprecationWarning, stacklevel=2)
        self._set_parameters(...)
    

The renaming is done first so you make sure to catch all usages in the codebase before adding the new one.

Problems:

  • The tests use these functions, so this means that we will be accessing private members outside the class.
  • In the future I would like to turn on inspections to prevent accessing private methods. This becomes a problem if the tests need to access these methods.
  • We should find a solution to having the tests access these members.

src/pybamm/simulation.py Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
src/pybamm/simulation.py Outdated Show resolved Hide resolved
Copy link

codecov bot commented Oct 10, 2024

Codecov Report

Attention: Patch coverage is 66.66667% with 3 lines in your changes missing coverage. Please review.

Project coverage is 99.25%. Comparing base (bcdd0b5) to head (4051fb6).
Report is 3 commits behind head on develop.

Files with missing lines Patch % Lines
src/pybamm/simulation.py 66.66% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4489      +/-   ##
===========================================
- Coverage    99.26%   99.25%   -0.02%     
===========================================
  Files          302      302              
  Lines        22889    22897       +8     
===========================================
+ Hits         22721    22726       +5     
- Misses         168      171       +3     

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


🚨 Try these New Features:

kratman
kratman previously approved these changes Nov 19, 2024
@kratman
Copy link
Contributor

kratman commented Nov 19, 2024

@Akhil-Sharma30 I just fixed a couple small things, should be good for now

@kratman kratman merged commit e17b549 into pybamm-team:develop Nov 19, 2024
24 of 26 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
3 participants