Skip to content

Commit

Permalink
Use np.nan instead of float for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-nml committed Jun 16, 2023
1 parent 887b461 commit 6282c99
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions nannyml/drift/univariate/methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ def _calculate(self, data: pd.Series):
reference_proba_in_bins = copy(self._reference_proba_in_bins)
data = _remove_missing_data(data)
if data.empty:
return float('nan')
return np.nan

Check warning on line 310 in nannyml/drift/univariate/methods.py

View check run for this annotation

Codecov / codecov/patch

nannyml/drift/univariate/methods.py#L310

Added line #L310 was not covered by tests
if self._treat_as_type == 'cont':
len_data = len(data)
data_proba_in_bins = np.histogram(data, bins=self._bins)[0] / len_data
Expand Down Expand Up @@ -391,7 +391,7 @@ def _fit(self, reference_data: pd.Series, timestamps: Optional[pd.Series] = None
def _calculate(self, data: pd.Series):
data = _remove_missing_data(data)
if data.empty:
return float('nan')
return np.nan

Check warning on line 394 in nannyml/drift/univariate/methods.py

View check run for this annotation

Codecov / codecov/patch

nannyml/drift/univariate/methods.py#L394

Added line #L394 was not covered by tests
if not self._fitted:
raise NotFittedException(
"tried to call 'calculate' on an unfitted method " f"{self.display_name}. Please run 'fit' first"
Expand Down Expand Up @@ -451,7 +451,7 @@ def _fit(self, reference_data: pd.Series, timestamps: Optional[pd.Series] = None
def _calculate(self, data: pd.Series):
data = _remove_missing_data(data)
if data.empty:
return float('nan')
return np.nan

Check warning on line 454 in nannyml/drift/univariate/methods.py

View check run for this annotation

Codecov / codecov/patch

nannyml/drift/univariate/methods.py#L454

Added line #L454 was not covered by tests
if not self._fitted:
raise NotFittedException(
"tried to call 'calculate' on an unfitted method " f"{self.display_name}. Please run 'fit' first"
Expand Down Expand Up @@ -518,7 +518,7 @@ def _calculate(self, data: pd.Series):
)
data = _remove_missing_data(data)
if data.empty:
return float('nan')
return np.nan

Check warning on line 521 in nannyml/drift/univariate/methods.py

View check run for this annotation

Codecov / codecov/patch

nannyml/drift/univariate/methods.py#L521

Added line #L521 was not covered by tests
data_labels = data.unique()
data_ratios = {label: (data == label).sum() / len(data) for label in data_labels}

Expand Down Expand Up @@ -594,7 +594,7 @@ def _calculate(self, data: pd.Series):
)
data = _remove_missing_data(data)
if data.empty:
return float('nan')
return np.nan

Check warning on line 597 in nannyml/drift/univariate/methods.py

View check run for this annotation

Codecov / codecov/patch

nannyml/drift/univariate/methods.py#L597

Added line #L597 was not covered by tests
if (
self.calculation_method == 'auto' and self._reference_size >= 10_000
) or self.calculation_method == 'estimated':
Expand Down Expand Up @@ -697,7 +697,7 @@ def _fit(self, reference_data: pd.Series, timestamps: Optional[pd.Series] = None
def _calculate(self, data: pd.Series):
data = _remove_missing_data(data)
if data.empty:
return float('nan')
return np.nan

Check warning on line 700 in nannyml/drift/univariate/methods.py

View check run for this annotation

Codecov / codecov/patch

nannyml/drift/univariate/methods.py#L700

Added line #L700 was not covered by tests
reference_proba_in_bins = copy(self._reference_proba_in_bins)
if self._treat_as_type == 'cont':
len_data = len(data)
Expand Down

0 comments on commit 6282c99

Please sign in to comment.