Skip to content

Commit

Permalink
fix int to int64 issue in read_strategies
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorb1 committed Oct 22, 2023
1 parent d06a051 commit 6066f34
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/otoole/results/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ def read_model(self, file_path: Union[str, TextIO]) -> pd.DataFrame:
df["INDEX"] = df["INDEX"].map(lambda x: x.split("]")[0])
df = (
df[["ID", "NUM", "NAME", "INDEX"]]
.astype({"ID": str, "NUM": int, "NAME": str, "INDEX": str})
.astype({"ID": str, "NUM": "int64", "NAME": str, "INDEX": str})
.reset_index(drop=True)
)

Expand Down Expand Up @@ -425,7 +425,7 @@ def read_solution(
data = (
data[["ID", "NUM", "STATUS", "PRIM", "DUAL"]]
.astype(
{"ID": str, "NUM": int, "STATUS": str, "PRIM": float, "DUAL": float}
{"ID": str, "NUM": "int64", "STATUS": str, "PRIM": float, "DUAL": float}
)
.reset_index(drop=True)
)
Expand Down
16 changes: 8 additions & 8 deletions tests/test_read_strategies.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def test_solution_to_dataframe(self, user_config):
],
columns=["REGION", "TECHNOLOGY", "YEAR", "VALUE"],
)
.astype({"REGION": str, "TECHNOLOGY": str, "YEAR": int, "VALUE": float})
.astype({"REGION": str, "TECHNOLOGY": str, "YEAR": "int64", "VALUE": float})
.set_index(["REGION", "TECHNOLOGY", "YEAR"])
)

Expand All @@ -135,8 +135,8 @@ def test_solution_to_dataframe(self, user_config):
"REGION": str,
"TIMESLICE": str,
"TECHNOLOGY": str,
"MODE_OF_OPERATION": int,
"YEAR": int,
"MODE_OF_OPERATION": "int64",
"YEAR": "int64",
"VALUE": float,
}
)
Expand Down Expand Up @@ -202,7 +202,7 @@ def test_solution_to_dataframe(self, user_config):
],
columns=["REGION", "YEAR", "VALUE"],
)
.astype({"YEAR": int, "VALUE": float})
.astype({"YEAR": "int64", "VALUE": float})
.set_index(["REGION", "YEAR"])
)

Expand All @@ -225,7 +225,7 @@ def test_solution_to_dataframe(self, user_config):
"VALUE",
],
)
.astype({"YEAR": int, "VALUE": float, "MODE_OF_OPERATION": int})
.astype({"YEAR": "int64", "VALUE": float, "MODE_OF_OPERATION": "int64"})
.set_index(
["REGION", "TIMESLICE", "TECHNOLOGY", "MODE_OF_OPERATION", "YEAR"]
)
Expand Down Expand Up @@ -623,7 +623,7 @@ def test_read_model(self, user_config):
["j", 1028, "RateOfActivity", "SIMPLICITY,IN,BACKSTOP1,1,2014"],
],
columns=["ID", "NUM", "NAME", "INDEX"],
)
).astype({"ID": str, "NUM": "int64", "NAME": str, "INDEX": str})

pd.testing.assert_frame_equal(actual, expected)

Expand Down Expand Up @@ -726,7 +726,7 @@ def test_remove_empty_lines(self, user_config):
],
columns=["REGION", "FUEL", "YEAR", "VALUE"],
)
.astype({"REGION": str, "FUEL": str, "YEAR": int, "VALUE": float})
.astype({"REGION": str, "FUEL": str, "YEAR": "int64", "VALUE": float})
.set_index(["REGION", "FUEL", "YEAR"])
}

Expand Down Expand Up @@ -757,7 +757,7 @@ def test_change_types(self, user_config):
],
columns=["REGION", "FUEL", "YEAR", "VALUE"],
)
.astype({"REGION": str, "FUEL": str, "YEAR": int, "VALUE": float})
.astype({"REGION": str, "FUEL": str, "YEAR": "int64", "VALUE": float})
.set_index(["REGION", "FUEL", "YEAR"])
}

Expand Down

0 comments on commit 6066f34

Please sign in to comment.