Skip to content

Commit

Permalink
Merge pull request #433 from NannyML/chore/update-dependencies
Browse files Browse the repository at this point in the history
Chore: the big bump
  • Loading branch information
nnansters authored Jan 14, 2025
2 parents c6d326e + ded92d2 commit ba5d263
Show file tree
Hide file tree
Showing 33 changed files with 5,357 additions and 4,420 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
# The type of runner that the job will run on
strategy:
matrix:
python-versions: ['3.8', '3.9', '3.10', '3.11']
python-versions: ['3.9', '3.10', '3.11', '3.12']
os: [ubuntu-20.04]
# os: [ubuntu-18.04, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:

strategy:
matrix:
python-versions: [ 3.8 ]
python-versions: [ 3.11 ]

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:

strategy:
matrix:
python-versions: [3.8]
python-versions: [3.11]

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
Expand Down
4 changes: 2 additions & 2 deletions nannyml/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import jinja2
import yaml
from pydantic import BaseModel, validator, Field
from pydantic import BaseModel, Field, field_validator

from nannyml._typing import Self
from nannyml.exceptions import IOException
Expand Down Expand Up @@ -71,7 +71,7 @@ class CalculatorConfig(BaseModel):
store: Optional[StoreConfig] = Field(default=None)
params: Dict[str, Any]

@validator('params')
@field_validator('params')
def _parse_thresholds(cls, value: Dict[str, Any]):
"""Parse thresholds in params and convert them to :class:`Threshold`'s"""
# Some calculators expect `thresholds` parameter as dict
Expand Down
6 changes: 5 additions & 1 deletion nannyml/drift/ranker.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,11 @@ def rank(
filtered_values = values[~(feature_nan | perf_nan)]
filtered_perf_change = abs_perf_change[~(feature_nan | perf_nan)]

tmp1 = pearsonr(filtered_values.ravel(), filtered_perf_change)
tmp1 = (
pearsonr(filtered_values.ravel(), filtered_perf_change)
if len(filtered_values) > 1
else (np.nan, np.nan)
)
spearmanr1.append(tmp1[0])
spearmanr2.append(tmp1[1])

Expand Down
4 changes: 2 additions & 2 deletions nannyml/drift/univariate/calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,10 +441,10 @@ def _calculate_for_column(
logger.error(
f"an unexpected exception occurred during calculation of method '{method.display_name}': " f"{exc}"
)
result['value'] = np.NaN
result['value'] = np.nan
result['upper_threshold'] = method.upper_threshold_value
result['lower_threshold'] = method.lower_threshold_value
result['alert'] = np.NaN
result['alert'] = np.nan
finally:
return result

Expand Down
6 changes: 4 additions & 2 deletions nannyml/drift/univariate/methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,9 @@ def _fit(self, reference_data: pd.Series, timestamps: Optional[pd.Series] = None
reference_data = _remove_nans(reference_data)
len_reference = len(reference_data)

bins = np.histogram_bin_edges(reference_data, bins='doane')
# Explicit conversion to float because of
# https://github.com/numpy/numpy/commit/c63969c6e1d58e791632aacfb88ecae465d6dcfc
bins = np.histogram_bin_edges(reference_data.astype("float64"), bins='doane')
reference_proba_in_bins = np.histogram(reference_data, bins=bins)[0] / len_reference
self._bins = bins
self._reference_proba_in_bins = reference_proba_in_bins
Expand Down Expand Up @@ -731,7 +733,7 @@ def _fit(self, reference_data: pd.Series, timestamps: Optional[pd.Series] = None
reference_data = _remove_nans(reference_data)
len_reference = len(reference_data)

bins = np.histogram_bin_edges(reference_data, bins='doane')
bins = np.histogram_bin_edges(reference_data.astype("float64"), bins='doane')
reference_proba_in_bins = np.histogram(reference_data, bins=bins)[0] / len_reference
self._bins = bins
self._reference_proba_in_bins = reference_proba_in_bins
Expand Down
6 changes: 3 additions & 3 deletions nannyml/performance_calculation/metrics/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,11 @@ def get_chunk_record(self, chunk_data: pd.DataFrame) -> Dict:
self._logger.error(
f"an unexpected exception occurred during calculation of method '{self.display_name}': " f"{exc}"
)
chunk_record[f'{column_name}_sampling_error'] = np.NaN
chunk_record[f'{column_name}'] = np.NaN
chunk_record[f'{column_name}_sampling_error'] = np.nan
chunk_record[f'{column_name}'] = np.nan
chunk_record[f'{column_name}_upper_threshold'] = self.upper_threshold_value
chunk_record[f'{column_name}_lower_threshold'] = self.lower_threshold_value
chunk_record[f'{column_name}_alert'] = np.NaN
chunk_record[f'{column_name}_alert'] = np.nan
finally:
return chunk_record

Expand Down
Loading

0 comments on commit ba5d263

Please sign in to comment.