Skip to content

Commit 3e76c56

Browse files
author
Jaime Céspedes Sisniega
authored
Merge pull request #208 from IFCA/fix-base-classes
Fix base classes
2 parents e05939f + ac1d659 commit 3e76c56

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+406
-409
lines changed

docs/source/api_reference/utils.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
:toctree: auto_generated/
5757
:template: class.md
5858
59-
Stat
6059
IncrementalStat
6160
Mean
6261
EWMA

frouros/callbacks/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
"""Callbacks init."""
22

3-
from .base import Callback
43
from .batch import PermutationTestOnBatchData, ResetOnBatchDataDrift
54
from .streaming import History, mSPRT, WarningSamplesBuffer
65

76
__all__ = [
8-
"Callback",
97
"History",
108
"mSPRT",
119
"PermutationTestOnBatchData",

frouros/callbacks/base.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
"""Callbacks base module."""
1+
"""Base callback module."""
22

33
import abc
44
from typing import Optional
55

66

7-
class Callback(abc.ABC):
7+
class BaseCallback(abc.ABC):
88
"""Abstract class representing a callback."""
99

1010
def __init__(self, name: Optional[str] = None) -> None:
@@ -43,15 +43,15 @@ def set_detector(self, detector) -> None:
4343
self.detector = detector
4444

4545
# @property
46-
# def detector(self) -> Optional[ConceptDriftBase, DataDriftBatchBase]:
46+
# def detector(self) -> Optional[BaseConceptDrift, BaseDataDriftBatch]:
4747
# return self._detector
4848
#
4949
# @detector.setter
50-
# def detector(self, value: Optional[ConceptDriftBase, DataDriftBatchBase]) -> None:
50+
# def detector(self, value: Optional[BaseConceptDrift, BaseDataDriftBatch]) -> None:
5151
# if not isinstance(
52-
# value, (ConceptDriftBase, DataDriftBatchBase)):
52+
# value, (BaseConceptDrift, BaseDataDriftBatch)):
5353
# raise TypeError(
54-
# "value must be of type ConceptDriftBase or DataDriftBatchBase."
54+
# "value must be of type BaseConceptDrift or BaseDataDriftBatch."
5555
# )
5656
# self._detector = value
5757

frouros/callbacks/batch/base.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
"""Batch base test module."""
1+
"""Base callback batch module."""
22

33
import abc
44

5-
from frouros.callbacks.base import Callback
5+
from frouros.callbacks.base import BaseCallback
66

77

8-
class BatchCallback(Callback):
9-
"""Batch callback class."""
8+
class BaseCallbackBatch(BaseCallback):
9+
"""Callback batch class."""
1010

1111
def on_compare_start(self) -> None:
1212
"""On compare start method."""

frouros/callbacks/batch/permutation_test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
import numpy as np # type: ignore
77
from scipy.stats import norm # type: ignore
88

9-
from frouros.callbacks.batch.base import BatchCallback
9+
from frouros.callbacks.batch.base import BaseCallbackBatch
1010
from frouros.utils.stats import permutation, z_score
1111

1212

13-
class PermutationTestOnBatchData(BatchCallback):
13+
class PermutationTestOnBatchData(BaseCallbackBatch):
1414
"""Permutation test on batch data callback class."""
1515

1616
def __init__(
@@ -163,11 +163,11 @@ def on_compare_end(self, **kwargs) -> None:
163163
#
164164
# :raises TypeError: Type error exception
165165
# """
166-
# if not isinstance(detector, DataDriftBatchBase):
166+
# if not isinstance(detector, BaseDataDriftBatch):
167167
# raise TypeError(
168168
# f"callback {self.__class__.name} cannot be used with detector"
169169
# f" {detector.__class__name}. Must be used with a detector of "
170-
# f"type DataDriftBatchBase."
170+
# f"type BaseDataDriftBatch."
171171
# )
172172
# self.detector = detector
173173

frouros/callbacks/batch/reset_drift.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
from typing import Optional
44

5-
from frouros.callbacks.batch.base import BatchCallback
5+
from frouros.callbacks.batch.base import BaseCallbackBatch
66

77

8-
class ResetOnBatchDataDrift(BatchCallback):
8+
class ResetOnBatchDataDrift(BaseCallbackBatch):
99
"""Reset on batch data drift callback class."""
1010

1111
def __init__(self, alpha: float, name: Optional[str] = None) -> None:
@@ -56,11 +56,11 @@ def on_compare_end(self, **kwargs) -> None:
5656
#
5757
# :raises TypeError: Type error exception
5858
# """
59-
# if not isinstance(detector, DataDriftBatchBase):
59+
# if not isinstance(detector, BaseDataDriftBatch):
6060
# raise TypeError(
6161
# f"callback {self.__class__.name} cannot be used with detector"
6262
# f" {detector.__class__name}. Must be used with a detector of "
63-
# f"type DataDriftBatchBase."
63+
# f"type BaseDataDriftBatch."
6464
# )
6565
# self.detector = detector
6666

frouros/callbacks/streaming/base.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
"""Streaming base test module."""
1+
"""Base callback streaming module."""
22

33
import abc
4-
54
from typing import Union
65

7-
from frouros.callbacks.base import Callback
6+
from frouros.callbacks.base import BaseCallback
87

98

10-
class StreamingCallback(Callback):
11-
"""Streaming callback class."""
9+
class BaseCallbackStreaming(BaseCallback):
10+
"""Callback streaming class."""
1211

1312
def on_update_start(self, value: Union[int, float], **kwargs) -> None:
1413
"""On update start method."""

frouros/callbacks/streaming/history.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
from typing import Any, Dict, List, Optional, Union
44

5-
from frouros.callbacks.streaming.base import StreamingCallback
6-
from frouros.utils.stats import Stat
5+
from frouros.callbacks.streaming.base import BaseCallbackStreaming
6+
from frouros.utils.stats import BaseStat
77

88

9-
class History(StreamingCallback):
9+
class History(BaseCallbackStreaming):
1010
"""History callback class."""
1111

1212
def __init__(self, name: Optional[str] = None) -> None:
@@ -49,7 +49,7 @@ def on_update_end(self, value: Union[int, float], **kwargs) -> None:
4949
# add_addtional_vars is called (avoid the same computation)
5050
self.history[var].append(
5151
additional_var.get()
52-
if isinstance(additional_var, Stat)
52+
if isinstance(additional_var, BaseStat)
5353
else additional_var
5454
)
5555

@@ -64,11 +64,11 @@ def on_update_end(self, value: Union[int, float], **kwargs) -> None:
6464
#
6565
# :raises TypeError: Type error exception
6666
# """
67-
# if not isinstance(detector, ConceptDriftBase):
67+
# if not isinstance(detector, BaseConceptDrift):
6868
# raise TypeError(
6969
# f"callback {self.__class__.name} cannot be used with detector"
7070
# f" {detector.__class__name}. Must be used with a detector of "
71-
# f"type ConceptDriftBase."
71+
# f"type BaseConceptDrift."
7272
# )
7373
# self.detector = detector
7474

frouros/callbacks/streaming/msprt.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
import numpy as np # type: ignore
66

7-
from frouros.callbacks.streaming.base import StreamingCallback
7+
from frouros.callbacks.streaming.base import BaseCallbackStreaming
88
from frouros.utils.stats import CircularMean
99

1010

11-
class mSPRT(StreamingCallback): # noqa: N801 # pylint: disable=invalid-name
11+
class mSPRT(BaseCallbackStreaming): # noqa: N801 # pylint: disable=invalid-name
1212
"""mSPRT (mixing Sequentially Probability Ratio Test) callback class.
1313
1414
:References:

frouros/callbacks/streaming/warning_samples.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
import copy
44
from typing import Any, List, Optional, Union
55

6-
from frouros.callbacks.streaming.base import StreamingCallback
6+
from frouros.callbacks.streaming.base import BaseCallbackStreaming
77

88

9-
class WarningSamplesBuffer(StreamingCallback):
9+
class WarningSamplesBuffer(BaseCallbackStreaming):
1010
"""Store warning samples as a buffer callback class."""
1111

1212
def __init__(self, name: Optional[str] = None) -> None:

0 commit comments

Comments
 (0)