From f49371a6697bc92e7d71a9ac0a66238332634bb3 Mon Sep 17 00:00:00 2001 From: Mathieu Dupont <108517594+mathieudpnt@users.noreply.github.com> Date: Tue, 25 Nov 2025 16:07:18 +0100 Subject: [PATCH 1/7] test audio_utils --- tests/test_audio_utils.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/test_audio_utils.py b/tests/test_audio_utils.py index 35c3407..2a0eb27 100644 --- a/tests/test_audio_utils.py +++ b/tests/test_audio_utils.py @@ -19,8 +19,6 @@ def test_normalize_audio_default_folder(sample_audio: Path, tmp_path: Path) -> N def test_normalize_audio_custom_folder(sample_audio: Path, tmp_path: Path) -> None: out_folder = tmp_path / "output" - out_folder.mkdir() - normalize_audio(sample_audio, output_folder=out_folder) normalized_file = out_folder / sample_audio.name From 5332f0ae5b48159389acaec6b636c8332e6004e3 Mon Sep 17 00:00:00 2001 From: Mathieu Dupont <108517594+mathieudpnt@users.noreply.github.com> Date: Tue, 25 Nov 2025 17:32:06 +0100 Subject: [PATCH 2/7] test core_utils --- src/post_processing/utils/core_utils.py | 50 ++++------ tests/test_core_utils.py | 126 +++++++++++++++++++++--- 2 files changed, 133 insertions(+), 43 deletions(-) diff --git a/src/post_processing/utils/core_utils.py b/src/post_processing/utils/core_utils.py index cf14302..ec4b68d 100644 --- a/src/post_processing/utils/core_utils.py +++ b/src/post_processing/utils/core_utils.py @@ -3,13 +3,14 @@ from __future__ import annotations import json -from typing import TYPE_CHECKING +from typing import TYPE_CHECKING, Any import astral import easygui import numpy as np from astral.sun import sunrise, sunset from matplotlib import pyplot as plt +from numpy import ndarray, dtype from osekit.config import TIMESTAMP_FORMAT_AUDIO_FILE from osekit.utils.timestamp_utils import strptime_from_text from pandas import ( @@ -79,11 +80,8 @@ def get_season(ts: Timestamp, *, northern: bool = True) -> tuple[str, int]: season = "summer" elif ts.month in autumn: season = "autumn" - elif ts.month in winter: - season = "winter" else: - msg = "Invalid timestamp" - raise ValueError(msg) + season = "winter" return season, ts.year - 1 if ts.month in [1, 2] else ts.year @@ -93,10 +91,7 @@ def get_sun_times( stop: Timestamp, lat: float, lon: float, -) -> ( - list[float], - list[float], -): +) -> tuple[list[float], list[float]]: """Fetch sunrise and sunset hours for dates between start and stop. Parameters @@ -171,7 +166,7 @@ def get_coordinates() -> tuple: f"'{lat}' is not a valid latitude. It must be between -90 and 90.\n" ) except ValueError: - errmsg += f"'{lat}' is not a valid entry for latitude.\n" + errmsg += f"'lat', invalid entry: '{lat}'.\n" try: lon_val = float(lon.strip()) # Convert to float for longitude @@ -349,7 +344,7 @@ def set_bar_height(ax: plt.Axes, pixel_height: int = 10) -> float: """ if not ax.has_data(): - msg = "Axe has no data" + msg = "Axe have no data" raise ValueError(msg) display_to_data = ax.transData.inverted().transform @@ -380,7 +375,7 @@ def add_recording_period( """ if not ax.has_data(): - msg = "Axe has no data" + msg = "Axe have no data" raise ValueError(msg) recorder_intervals = [ @@ -419,10 +414,6 @@ def get_count(df: DataFrame, bin_size: Timedelta | BaseOffset) -> DataFrame: "