Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: the big bump #433

Merged
merged 18 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
logger.error(
f"an unexpected exception occurred during calculation of method '{method.display_name}': " f"{exc}"
)
result['value'] = np.NaN
result['value'] = np.nan

Check warning on line 444 in nannyml/drift/univariate/calculator.py

View check run for this annotation

Codecov / codecov/patch

nannyml/drift/univariate/calculator.py#L444

Added line #L444 was not covered by tests
result['upper_threshold'] = method.upper_threshold_value
result['lower_threshold'] = method.lower_threshold_value
result['alert'] = np.NaN
result['alert'] = np.nan

Check warning on line 447 in nannyml/drift/univariate/calculator.py

View check run for this annotation

Codecov / codecov/patch

nannyml/drift/univariate/calculator.py#L447

Added line #L447 was not covered by tests
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