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

fix(raw): replace NaN values by 'NaN' inside output matrices #2278

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,11 @@ def parse_dataframe(
date, body = self.date_serializer.extract_date(df)

matrix = rename_unnamed(body).astype(float)
matrix = matrix.where(pd.notna(matrix), None)
matrix.index = date
matrix.columns = body.columns
return matrix
# replace NaN values by "NaN" for the front-end
final_matrix = matrix.fillna("NaN")
final_matrix.index = date
final_matrix.columns = body.columns
return final_matrix

def parse(
self,
Expand Down
3 changes: 0 additions & 3 deletions tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#
# This file is part of the Antares project.

import math
import time
import uuid
from datetime import datetime, timedelta, timezone
Expand Down Expand Up @@ -79,8 +78,6 @@ def assert_study(a: SUB_JSON, b: SUB_JSON) -> None:
_assert_list(cast(List[float], a.tolist()), b)
elif isinstance(a, list) and isinstance(b, np.ndarray):
_assert_list(a, cast(List[float], b.tolist()))
elif isinstance(a, float) and math.isnan(a):
assert math.isnan(b)
else:
_assert_others(a, b)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def test_get_study_data(self, client: TestClient, user_access_token: str, intern
if study_type == "raw":
res = client.get(raw_url, params={"path": "output/20201014-1427eco/economy/mc-all/areas/de/id-monthly"})
assert res.status_code == 200
assert np.isnan(res.json()["data"][0]).any()
assert "NaN" in res.json()["data"][0]

# Iterate over all possible combinations of path and depth
for path, depth in itertools.product([None, "", "/"], [0, 1, 2]):
Expand Down
14 changes: 6 additions & 8 deletions tests/storage/integration/data/set_id_annual.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
#
# This file is part of the Antares project.

import math

set_id_annual = {
"columns": [
("OP. COST", "Euro", "min"),
Expand Down Expand Up @@ -253,14 +251,14 @@
1.0,
1.0,
1.0,
math.nan,
math.nan,
"NaN",
"NaN",
1.0,
1.0,
math.nan,
math.nan,
math.nan,
math.nan,
"NaN",
"NaN",
"NaN",
"NaN",
1.0,
1.0,
1.0,
Expand Down
Loading
Loading