Skip to content

Commit 23480f4

Browse files
Julien RousselJulien Roussel
authored andcommitted
data tests made windows compatible
1 parent 6a89a93 commit 23480f4

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

qolmat/utils/data.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,18 @@ def download_data_from_zip(
5454
List[pd.DataFrame]
5555
A list of DataFrames loaded from the CSV files within the extracted directory.
5656
"""
57-
57+
print()
58+
print("download_data_from_zip")
59+
print(datapath)
60+
print(zipname)
5861
path_zip = os.path.join(datapath, zipname)
62+
print(path_zip)
5963
path_zip_ext = path_zip + ".zip"
6064
url = os.path.join(urllink, zipname) + ".zip"
6165
os.makedirs(datapath, exist_ok=True)
6266
if not os.path.exists(path_zip_ext) and not os.path.exists(path_zip):
67+
print(url)
68+
print(path_zip_ext)
6369
request.urlretrieve(url, path_zip_ext)
6470
if not os.path.exists(path_zip):
6571
with zipfile.ZipFile(path_zip_ext, "r") as zip_ref:
@@ -176,22 +182,9 @@ def get_data(
176182
df = read_csv_local("conductors")
177183
return df
178184
elif name_data == "Titanic":
179-
# df = read_csv_local("titanic", sep=";")
180185
path = "https://gist.githubusercontent.com/fyyying/4aa5b471860321d7b47fd881898162b7/raw/"
181186
"6907bb3a38bfbb6fccf3a8b1edfb90e39714d14f/titanic_dataset.csv"
182187
df = pd.read_csv(path)
183-
# df = df.dropna(how="all")
184-
# df = df.drop(
185-
# columns=[
186-
# "pclass",
187-
# "name",
188-
# "home.dest",
189-
# "cabin",
190-
# "ticket",
191-
# "boat",
192-
# "body",
193-
# ]
194-
# )
195188
df = df[["Survived", "Sex", "Age", "SibSp", "Parch", "Fare", "Embarked"]]
196189
df["Age"] = pd.to_numeric(df["Age"], errors="coerce")
197190
df["Fare"] = pd.to_numeric(df["Fare"], errors="coerce")

tests/utils/test_utils.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@ def test_utils_utils_display_progress_bar(iteration: int, total: int, capsys) ->
1818
captured_output = StringIO()
1919
sys.stdout = captured_output
2020
utils.progress_bar(
21-
iteration, total, prefix="Progress", suffix="Complete", decimals=1, length=2, fill="█"
21+
iteration,
22+
total,
23+
prefix="Progress",
24+
suffix="Complete",
25+
decimals=1,
26+
length=2,
27+
fill="█",
2228
)
2329
captured_output.seek(0)
2430
output = captured_output.read().strip()
@@ -28,7 +34,7 @@ def test_utils_utils_display_progress_bar(iteration: int, total: int, capsys) ->
2834
assert output == output_expected
2935

3036

31-
@pytest.mark.parametrize("values, lag_max", [(pd.Series([1, 2, 3, 4, 5]), 3)])
37+
@pytest.mark.parametrize("values, lag_max", [(pd.Series([1.0, 2.0, 3.0, 4.0, 5.0]), 3)])
3238
def test_utils_utils_acf(values, lag_max):
3339
result = utils.acf(values, lag_max)
3440
result_expected = pd.Series([1.0, 1.0, 1.0])
@@ -84,7 +90,8 @@ def test_utils_utils_acf(values, lag_max):
8490

8591
@pytest.mark.parametrize("X", [X_incomplete])
8692
@pytest.mark.parametrize(
87-
"method, X_expected", [("mean", X_exp_mean), ("median", X_exp_median), ("zeros", X_exp_zeros)]
93+
"method, X_expected",
94+
[("mean", X_exp_mean), ("median", X_exp_median), ("zeros", X_exp_zeros)],
8895
)
8996
def test_utils_utils_impute_nans(X: NDArray, method: str, X_expected: NDArray):
9097
result = utils.impute_nans(M=X, method=method)

0 commit comments

Comments
 (0)