Skip to content

Commit

Permalink
[Bug]: pybamm.Simulation.set_parameters and `pybamm.Simulation.set_…
Browse files Browse the repository at this point in the history
…up_and_parameterise_experiment` made private in `simulation.py` (#4489)

* Fix: Add deprecated warning for `set_up_and_parameterise_model_for_experiment` in simulation

* Add deprecated warning for `set_parameters` in simulation

* Docs: Add deprecated message in unreleased section

* style: pre-commit fixes

* Docs: Move deprecated to Breaking changes section

* Fix: Make set_up_and_parameterise_experiment private

* Fix: Make set_paramters func private

* Refactor: Add deprecation warning message in set_parameters() func

* Refactor: Add deprecation warning in `set_up_and_parameterise_experiment` func

* Fix some typos

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Eric G. Kratz <[email protected]>
Co-authored-by: kratman <[email protected]>
  • Loading branch information
4 people authored Nov 19, 2024
1 parent 6dfa38e commit e17b549
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

## Breaking changes

- Deprecated `pybamm.Simulation.set_parameters` and `pybamm.Simulation. set_up_and_parameterise_experiment` functions in `pybamm.simulation.py`. ([#3752](https://github.com/pybamm-team/PyBaMM/pull/3752))
- Removed all instances of `param = self.param` and now directly access `self.param` across the codebase. This change simplifies parameter references and enhances readability. ([#4484](https://github.com/pybamm-team/PyBaMM/pull/4494))
- Removed the deprecation warning for the chemistry argument in
ParameterValues ([#4466](https://github.com/pybamm-team/PyBaMM/pull/4466))
Expand Down
15 changes: 13 additions & 2 deletions src/pybamm/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ def _set_random_seed(self):
)

def set_up_and_parameterise_experiment(self, solve_kwargs=None):
msg = "pybamm.simulation.set_up_and_parameterise_experiment is deprecated and not meant to be accessed by users."
warnings.warn(msg, DeprecationWarning, stacklevel=2)
self._set_up_and_parameterise_experiment(solve_kwargs=solve_kwargs)

def _set_up_and_parameterise_experiment(self, solve_kwargs=None):
"""
Create and parameterise the models for each step in the experiment.
Expand Down Expand Up @@ -254,10 +259,16 @@ def set_up_and_parameterise_experiment(self, solve_kwargs=None):
)

def set_parameters(self):
msg = (
"pybamm.set_parameters is deprecated and not meant to be accessed by users."
)
warnings.warn(msg, DeprecationWarning, stacklevel=2)
self._set_parameters()

def _set_parameters(self):
"""
A method to set the parameters in the model and the associated geometry.
"""

if self._model_with_set_params:
return

Expand Down Expand Up @@ -355,7 +366,7 @@ def build_for_experiment(self, initial_soc=None, inputs=None, solve_kwargs=None)
if self.steps_to_built_models:
return
else:
self.set_up_and_parameterise_experiment(solve_kwargs)
self._set_up_and_parameterise_experiment(solve_kwargs)

# Can process geometry with default parameter values (only electrical
# parameters change between parameter values)
Expand Down

0 comments on commit e17b549

Please sign in to comment.