From c172163b40a282d68d0483f91f834c002e6b39fa Mon Sep 17 00:00:00 2001 From: Callum Rollo Date: Thu, 31 Oct 2024 12:52:15 +0100 Subject: [PATCH] test of monotony (#51) --- glidertest/tools.py | 2 ++ tests/test_tools.py | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/glidertest/tools.py b/glidertest/tools.py index fcc8ab6..43ea62a 100644 --- a/glidertest/tools.py +++ b/glidertest/tools.py @@ -571,8 +571,10 @@ def check_monotony(da): """ if not pd.Series(da).is_monotonic_increasing: print(f'{da.name} is not always monotonically increasing') + return False else: print(f'{da.name} is always monotonically increasing') + return True def plot_profIncrease(ds: xr.DataArray, ax: plt.Axes = None, **kw: dict, ) -> tuple({plt.Figure, plt.Axes}): diff --git a/tests/test_tools.py b/tests/test_tools.py index c3e463d..72255c6 100644 --- a/tests/test_tools.py +++ b/tests/test_tools.py @@ -43,3 +43,11 @@ def test_profile_check(): ds = fetchers.load_sample_dataset() tools.check_monotony(ds.PROFILE_NUMBER) tools.plot_profIncrease(ds) + +def test_check_monotony(): + ds = fetchers.load_sample_dataset() + profile_number_monotony = tools.check_monotony(ds.PROFILE_NUMBER) + temperature_monotony = tools.check_monotony(ds.TEMP) + assert profile_number_monotony + assert not temperature_monotony + \ No newline at end of file