diff --git a/pybamm/experiment/experiment.py b/pybamm/experiment/experiment.py index 71e674e329..ff79440547 100644 --- a/pybamm/experiment/experiment.py +++ b/pybamm/experiment/experiment.py @@ -1,7 +1,3 @@ -# -# Experiment class -# - from __future__ import annotations import pybamm from .step._steps_util import ( @@ -84,6 +80,8 @@ def __init__( processed_step = pybamm.step.string(step) elif isinstance(step, pybamm.step._Step): processed_step = step + else: + raise TypeError("Operating conditions must be a Step object or string.") if processed_step.period is None: processed_step.period = self.period @@ -125,7 +123,8 @@ def copy(self): def __repr__(self): return f"pybamm.Experiment({self!s})" - def read_termination(self, termination): + @staticmethod + def read_termination(termination): """ Read the termination reason. If this condition is hit, the experiment will stop. """ @@ -184,7 +183,8 @@ def search_tag(self, tag): return cycles - def _set_next_start_time(self, operating_conditions): + @staticmethod + def _set_next_start_time(operating_conditions): if all(isinstance(i, str) for i in operating_conditions): return operating_conditions @@ -194,7 +194,7 @@ def _set_next_start_time(self, operating_conditions): for op in reversed(operating_conditions): if isinstance(op, str): op = pybamm.step.string(op) - elif not isinstance(op, pybamm.step._Step): + if not isinstance(op, pybamm.step._Step): raise TypeError( "Operating conditions should be strings or _Step objects" )