From 07f065cf9336cf9e6d632b1363eda91a2309ca48 Mon Sep 17 00:00:00 2001 From: mbsantiago Date: Sat, 19 Apr 2025 12:25:41 +0100 Subject: [PATCH] Rename Preprocessor to PreprocessorProtocol --- batdetect2/postprocess/types.py | 6 +++++- batdetect2/preprocess/__init__.py | 6 +++--- batdetect2/preprocess/types.py | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/batdetect2/postprocess/types.py b/batdetect2/postprocess/types.py index e3ea131..aa16d06 100644 --- a/batdetect2/postprocess/types.py +++ b/batdetect2/postprocess/types.py @@ -1,4 +1,4 @@ -from typing import Dict, NamedTuple +from typing import Dict, NamedTuple, Protocol import numpy as np @@ -15,3 +15,7 @@ class BatDetect2Prediction(NamedTuple): detection_score: float class_scores: Dict[str, float] features: np.ndarray + + +class PostprocessorProtocol(Protocol): + pass diff --git a/batdetect2/preprocess/__init__.py b/batdetect2/preprocess/__init__.py index fe791a9..f875fc8 100644 --- a/batdetect2/preprocess/__init__.py +++ b/batdetect2/preprocess/__init__.py @@ -58,7 +58,7 @@ from batdetect2.preprocess.spectrogram import ( ) from batdetect2.preprocess.types import ( AudioLoader, - Preprocessor, + PreprocessorProtocol, SpectrogramBuilder, ) @@ -110,7 +110,7 @@ class PreprocessingConfig(BaseConfig): spectrogram: SpectrogramConfig = Field(default_factory=SpectrogramConfig) -class StandardPreprocessor(Preprocessor): +class StandardPreprocessor(PreprocessorProtocol): """Standard implementation of the `Preprocessor` protocol. Orchestrates the audio loading and spectrogram generation pipeline using @@ -402,7 +402,7 @@ def load_preprocessing_config( def build_preprocessor( config: Optional[PreprocessingConfig] = None, -) -> Preprocessor: +) -> PreprocessorProtocol: """Factory function to build the standard preprocessor from configuration. Creates instances of the required `AudioLoader` and `SpectrogramBuilder` diff --git a/batdetect2/preprocess/types.py b/batdetect2/preprocess/types.py index f7346f5..301fb36 100644 --- a/batdetect2/preprocess/types.py +++ b/batdetect2/preprocess/types.py @@ -158,7 +158,7 @@ class SpectrogramBuilder(Protocol): ... -class Preprocessor(Protocol): +class PreprocessorProtocol(Protocol): """Defines a high-level interface for the complete preprocessing pipeline. A Preprocessor combines audio loading and spectrogram generation steps.