From ff6a817ece715010709086287429e82fdf4d2c8c Mon Sep 17 00:00:00 2001 From: RohitP2005 Date: Fri, 17 Jan 2025 01:21:49 +0530 Subject: [PATCH 1/2] Deprecation for deprecated fucntions --- pyproject.toml | 1 + src/pybamm/expression_tree/symbol.py | 15 ++++++++++++++- src/pybamm/simulation.py | 15 +++++++++++++-- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 745ee5d8d8..3939e2dc4f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,6 +41,7 @@ dependencies = [ "posthog", "pyyaml", "platformdirs", + "deprecation" ] [project.urls] diff --git a/src/pybamm/expression_tree/symbol.py b/src/pybamm/expression_tree/symbol.py index 3f695b768e..a4cfb42cd2 100644 --- a/src/pybamm/expression_tree/symbol.py +++ b/src/pybamm/expression_tree/symbol.py @@ -15,6 +15,7 @@ import pybamm from pybamm.util import import_optional_dependency from pybamm.expression_tree.printing.print_name import prettify_print_name +from deprecation import deprecated if TYPE_CHECKING: # pragma: no cover import casadi @@ -356,6 +357,12 @@ def domain(self, domain): ) @property + @deprecated( + deprecated_in="25.1.0", + removed_in="26.0.0", + current_version=pybamm.__version__, + details="Use `symbol.domains` instead." +) def auxiliary_domains(self): """Returns auxiliary domains.""" raise NotImplementedError( @@ -993,7 +1000,13 @@ def create_copy( """ children = self._children_for_copying(new_children) return self.__class__(self.name, children, domains=self.domains) - + + @deprecated( + deprecated_in="25.1.0", + removed_in="26.0.0", + current_version=pybamm.__version__, + details="Use `create_copy` instead." +) def new_copy( self, new_children: list[Symbol] | None = None, diff --git a/src/pybamm/simulation.py b/src/pybamm/simulation.py index 7bd1e5eea0..496745a383 100644 --- a/src/pybamm/simulation.py +++ b/src/pybamm/simulation.py @@ -8,7 +8,7 @@ from datetime import timedelta import pybamm.telemetry from pybamm.util import import_optional_dependency - +from deprecation import deprecated from pybamm.expression_tree.operations.serialise import Serialise @@ -171,6 +171,12 @@ def _set_random_seed(self): % (2**32) ) + @deprecated( + deprecated_in="25.1.0", + removed_in="26.0.0", + current_version=pybamm.__version__, + details="pybamm.simulation.set_up_and_parameterise_experiment is deprecated and not meant to be accessed by users." +) 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) @@ -253,7 +259,12 @@ def _set_up_and_parameterise_experiment(self, solve_kwargs=None): self.experiment_unique_steps_to_model["Rest for padding"] = ( parameterised_model ) - + @deprecated( + deprecated_in="25.1.0", + removed_in="26.0.0", + current_version=pybamm.__version__, + details="pybamm.set_parameters is deprecated and not meant to be accessed by users." +) def set_parameters(self): msg = ( "pybamm.set_parameters is deprecated and not meant to be accessed by users." From 7f34a0b7cc8530d68580bbd0db446e7a2c7ec828 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 16 Jan 2025 19:56:03 +0000 Subject: [PATCH 2/2] style: pre-commit fixes --- src/pybamm/expression_tree/symbol.py | 22 +++++++++++----------- src/pybamm/simulation.py | 21 +++++++++++---------- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/pybamm/expression_tree/symbol.py b/src/pybamm/expression_tree/symbol.py index a4cfb42cd2..5c25030a09 100644 --- a/src/pybamm/expression_tree/symbol.py +++ b/src/pybamm/expression_tree/symbol.py @@ -358,11 +358,11 @@ def domain(self, domain): @property @deprecated( - deprecated_in="25.1.0", - removed_in="26.0.0", - current_version=pybamm.__version__, - details="Use `symbol.domains` instead." -) + deprecated_in="25.1.0", + removed_in="26.0.0", + current_version=pybamm.__version__, + details="Use `symbol.domains` instead.", + ) def auxiliary_domains(self): """Returns auxiliary domains.""" raise NotImplementedError( @@ -1000,13 +1000,13 @@ def create_copy( """ children = self._children_for_copying(new_children) return self.__class__(self.name, children, domains=self.domains) - + @deprecated( - deprecated_in="25.1.0", - removed_in="26.0.0", - current_version=pybamm.__version__, - details="Use `create_copy` instead." -) + deprecated_in="25.1.0", + removed_in="26.0.0", + current_version=pybamm.__version__, + details="Use `create_copy` instead.", + ) def new_copy( self, new_children: list[Symbol] | None = None, diff --git a/src/pybamm/simulation.py b/src/pybamm/simulation.py index 496745a383..281c965615 100644 --- a/src/pybamm/simulation.py +++ b/src/pybamm/simulation.py @@ -172,11 +172,11 @@ def _set_random_seed(self): ) @deprecated( - deprecated_in="25.1.0", - removed_in="26.0.0", - current_version=pybamm.__version__, - details="pybamm.simulation.set_up_and_parameterise_experiment is deprecated and not meant to be accessed by users." -) + deprecated_in="25.1.0", + removed_in="26.0.0", + current_version=pybamm.__version__, + details="pybamm.simulation.set_up_and_parameterise_experiment is deprecated and not meant to be accessed by users.", + ) 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) @@ -259,12 +259,13 @@ def _set_up_and_parameterise_experiment(self, solve_kwargs=None): self.experiment_unique_steps_to_model["Rest for padding"] = ( parameterised_model ) + @deprecated( - deprecated_in="25.1.0", - removed_in="26.0.0", - current_version=pybamm.__version__, - details="pybamm.set_parameters is deprecated and not meant to be accessed by users." -) + deprecated_in="25.1.0", + removed_in="26.0.0", + current_version=pybamm.__version__, + details="pybamm.set_parameters is deprecated and not meant to be accessed by users.", + ) def set_parameters(self): msg = ( "pybamm.set_parameters is deprecated and not meant to be accessed by users."