Skip to content

Commit 56b5d5f

Browse files
committed
started adding linters
1 parent 72192c5 commit 56b5d5f

11 files changed

Lines changed: 48 additions & 17 deletions

File tree

.flake8

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[flake8]
2+
max-line-length = 79
3+
extend-ignore = E203, W503
4+
exclude = .git,__pycache__,build,dist,.venv

moddata/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
__all__ = [
44
"load_data"
5-
]
5+
]

moddata/_utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ def _load_bankchurn() -> pd.DataFrame:
3232

3333

3434
def _load_btc():
35-
path: Path = Path(kagglehub.dataset_download("prasoonkottarathil/btcinusd"))
35+
path: Path = Path(
36+
kagglehub.dataset_download("prasoonkottarathil/btcinusd"))
3637
datas: list[pd.DataFrame] = []
3738
for p in path.glob("*min.csv"):
3839
datas.append(

moddata/data/_setup_data.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from pathlib import Path
44
from typing import Final
55

6-
import numpy as np
76
import pandas as pd
87

98

@@ -32,9 +31,9 @@ def _extract_stooq_datas(file_to_ticker: dict[str, str]) -> pd.DataFrame:
3231
for file, ticker in file_to_ticker.items():
3332
datas.append(_extract_stooq_data(file=file, ticker=ticker))
3433
data: pd.DataFrame = reduce(
35-
lambda l, r: pd.merge(
36-
left=l,
37-
right=r,
34+
lambda l_, r_: pd.merge(
35+
left=l_,
36+
right=r_,
3837
left_index=True,
3938
right_index=True,
4039
how="outer"

moddata/extractor/bankchurn_extractor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from moddata import load_data
44
from moddata.src.constants import XyDataFrames
55

6+
67
class BankchurnExtractor:
78

89
def extract(self) -> XyDataFrames:

moddata/sklearn_extensions/log_standard_scaler.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ def fit(self, X: pd.DataFrame):
5757

5858
def transform(self, X: pd.DataFrame):
5959
if not isinstance(X, pd.DataFrame):
60-
raise ValueError("This transformer only accepts pd.DataFrame input!")
60+
raise ValueError(
61+
"This transformer only accepts pd.DataFrame input!"
62+
)
6163
X_log = self._log_transform(X=X)
6264
return self._standard_scaler.transform(X=X_log + self.shift)
6365

moddata/src/extractor.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@ class Extractor(Protocol):
55

66
def extract(self, *args, **kwargs):
77
pass
8-

moddata/src/pipeline.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@ class Pipeline(Protocol):
55

66
def run(self) -> Any:
77
pass
8-

moddata/src/transformer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Protocol, TypeAlias, Union
1+
from typing import Any, Protocol, TypeAlias
22

33
import pandas as pd
44

moddata/transformer/bankchurn_transformer.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,10 @@ def _get_column_transformer(
5555
if encoding_and_scaling_model_type == "tree_like":
5656
return ColumnTransformer(
5757
transformers=[
58-
("ohe_gender_encoder", self._ohe_gender_encoder(), ["gender"]),
59-
("ohe_encode_country", self._ohe_encode_country(), ["country"])
58+
("ohe_gender_encoder", self._ohe_gender_encoder(),
59+
["gender"]),
60+
("ohe_encode_country", self._ohe_encode_country(),
61+
["country"])
6062
],
6163
remainder="passthrough",
6264
force_int_remainder_cols=False,
@@ -66,10 +68,20 @@ def _get_column_transformer(
6668
elif encoding_and_scaling_model_type == "other":
6769
return ColumnTransformer(
6870
transformers=[
69-
("ohe_gender_encoder", self._ohe_gender_encoder(), ["gender"]),
70-
("ohe_encode_country", self._ohe_encode_country(), ["country"]),
71-
("credit_score_dist_scaler", self._credit_score_dist_scaler(), ["credit_score"]),
72-
("estimated_salary_scaler", self._estimated_salary_scaler(), ["estimated_salary"]),
71+
("ohe_gender_encoder", self._ohe_gender_encoder(),
72+
["gender"]),
73+
("ohe_encode_country", self._ohe_encode_country(),
74+
["country"]),
75+
(
76+
"credit_score_dist_scaler",
77+
self._credit_score_dist_scaler(),
78+
["credit_score"]
79+
),
80+
(
81+
"estimated_salary_scaler",
82+
self._estimated_salary_scaler(),
83+
["estimated_salary"]
84+
),
7385
("age_scaler", self._age_scaler(), ["age"]),
7486
("balance_scaler", self._balance_scaler(), ["balance"])
7587
],
@@ -94,7 +106,9 @@ def transform(
94106
)
95107
if self._config.encoding_and_scaling_model_type is not None:
96108
col_trfm: ColumnTransformer = self._get_column_transformer(
97-
encoding_and_scaling_model_type=self._config.encoding_and_scaling_model_type
109+
encoding_and_scaling_model_type=(
110+
self._config.encoding_and_scaling_model_type
111+
)
98112
)
99113
col_trfm.fit(X=X_train)
100114
X_train = pd.DataFrame(

0 commit comments

Comments
 (0)