Skip to content

Commit 9d2dbe4

Browse files
Fix pep8
1 parent d39888d commit 9d2dbe4

File tree

4 files changed

+18
-11
lines changed

4 files changed

+18
-11
lines changed

frouros/datasets/base.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ def __init__(
3333
:type file_path: str
3434
"""
3535
self.url = url
36-
self.file_path: Optional[Path] = (
37-
Path(file_path)
38-
if file_path
39-
else Path(tempfile.NamedTemporaryFile(delete=False).name)
40-
)
36+
if file_path:
37+
self.file_path = Path(file_path)
38+
else:
39+
with tempfile.NamedTemporaryFile(delete=False) as temp_file:
40+
self.file_path = Path(temp_file.name)
4141

4242
@property
4343
def file_path(self) -> Optional[Path]:

frouros/detectors/data_drift/batch/statistical_test/bws.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def _statistical_test(
6161
x=X_ref,
6262
y=X,
6363
alternative=kwargs.get("alternative", "two-sided"),
64-
method=kwargs.get("method", None),
64+
method=kwargs.get("method"),
6565
)
6666
test = StatisticalResult(
6767
statistic=test.statistic,

frouros/detectors/data_drift/batch/statistical_test/chisquare.py

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

33
import collections
44
import typing
5-
from typing import Any, Optional, Set, Tuple, Union
5+
from typing import (
6+
Any,
7+
Optional,
8+
Union,
9+
)
610

711
import numpy as np
812
from scipy.stats import chi2_contingency
913

1014
from frouros.callbacks.batch.base import BaseCallbackBatch
11-
from frouros.detectors.data_drift.base import CategoricalData, UnivariateData
15+
from frouros.detectors.data_drift.base import (
16+
CategoricalData,
17+
UnivariateData,
18+
)
1219
from frouros.detectors.data_drift.batch.statistical_test.base import (
1320
BaseStatisticalTest,
1421
StatisticalResult,
@@ -82,11 +89,11 @@ def _statistical_test(
8289
def _calculate_frequencies(
8390
X_ref: np.ndarray, # noqa: N803
8491
X: np.ndarray,
85-
) -> Tuple[list[int], list[int]]:
92+
) -> tuple[list[int], list[int]]:
8693
X_ref_counter, X_counter = [ # noqa: N806
8794
*map(collections.Counter, [X_ref, X]) # noqa: N806
8895
]
89-
possible_values: Set[str] = set([*X_ref_counter.keys()] + [*X_counter.keys()]) # noqa: N806
96+
possible_values: set[str] = set([*X_ref_counter.keys()] + [*X_counter.keys()]) # noqa: N806
9097
f_exp, f_obs = {}, {}
9198
for value in possible_values:
9299
f_exp[value] = X_ref_counter.get(value, 0) # noqa: N806

frouros/utils/stats.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ def permutation( # pylint: disable=too-many-arguments,too-many-locals
269269
with Pool(processes=num_jobs) as pool:
270270
permuted_statistics = pool.starmap_async(
271271
partial(statistic, **statistical_args),
272-
iterable=tqdm(permuted_data) if verbose else permuted_data, # type: ignore
272+
iterable=tqdm(permuted_data) if verbose else permuted_data,
273273
).get()
274274

275275
return permuted_statistics, max_num_permutations

0 commit comments

Comments
 (0)