From 06b606f3fa1ecac532a3e4a65fb31489dd26f34a Mon Sep 17 00:00:00 2001 From: Phil Elson Date: Fri, 6 Aug 2021 10:01:31 +0200 Subject: [PATCH] Remove the unused _is_interval_between_state_changes method. --- cara/models.py | 10 +--------- cara/tests/models/test_concentration_model.py | 20 +------------------ 2 files changed, 2 insertions(+), 28 deletions(-) diff --git a/cara/models.py b/cara/models.py index 6a7a1531..9d202391 100644 --- a/cara/models.py +++ b/cara/models.py @@ -784,7 +784,7 @@ class ConcentrationModel: """ times = self.state_change_times() - t_index = np.searchsorted(times, time) + t_index: int = np.searchsorted(times, time) # type: ignore # Search sorted gives us the index to insert the given time. Instead we # want to get the index of the most recent time, so reduce the index by # one unless we are already at 0. @@ -804,14 +804,6 @@ class ConcentrationModel: f"state change time ({change_time})" ) - def _is_interval_between_state_changes(self, start: float, stop: float) -> bool: - """ - Check that the times start and stop are in-between two state - changes of the concentration model (to ensure sure that all - model parameters stay constant between start and stop). - """ - return (self.last_state_change(stop) <= start) - @method_cache def _concentration_cached(self, time: float) -> _VectorisedFloat: # A cached version of the concentration method. Use this method if you diff --git a/cara/tests/models/test_concentration_model.py b/cara/tests/models/test_concentration_model.py index 5e246533..b5895f21 100644 --- a/cara/tests/models/test_concentration_model.py +++ b/cara/tests/models/test_concentration_model.py @@ -70,7 +70,7 @@ def simple_conc_model(): @pytest.mark.parametrize( "time, expected_last_state_change", [ - [-15., 0.], # Out of range goes to the last state. + [-15., 0.], # Out of range goes to the first state. [0., 0], [1., 0], [1.05, 1.], @@ -121,24 +121,6 @@ def test_next_state_change_time_out_of_range(simple_conc_model: models.Concentra simple_conc_model._next_state_change(3.1) -@pytest.mark.parametrize( - "start, stop, is_valid", [ - [0, 1.05, False], - [0.99, 1.1, False], - [0.5, 1.01, False], - [0, 1, True], - [1.01, 1.1, True], - [0.01, 1, True], - [1.11, 1.99, True], - ] -) -def test_valid_interval( - start, stop, is_valid, - simple_conc_model: models.ConcentrationModel -): - assert simple_conc_model._is_interval_between_state_changes(start, stop) == is_valid - - def test_integrated_concentration(simple_conc_model): c1 = simple_conc_model.integrated_concentration(0, 2) c2 = simple_conc_model.integrated_concentration(0, 1)