Skip to content

Commit

Permalink
Change "nid" Casted Value in caliper_native_reader to np.int64 (#118)
Browse files Browse the repository at this point in the history
* Change cast value to np.int64

* Update test

* Use existing datastructure to cast

* Change type to float so we can support NaN nid values
  • Loading branch information
michaelmckinsey1 authored Apr 8, 2024
1 parent fe68b12 commit 5cccd40
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 3 additions & 1 deletion hatchet/readers/caliper_native_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,9 @@ def read(self):
with self.timer.phase("data frame"):
# merge the metrics and node dataframes on the nid column
dataframe = pd.merge(df_metrics, self.df_nodes, on="nid")
dataframe["nid"] = dataframe["nid"].astype(pd.Int64Dtype())
dataframe["nid"] = dataframe["nid"].astype(
self.__cali_type_dict["double"]
)

# set the index to be a MultiIndex
indices = ["node"]
Expand Down
7 changes: 3 additions & 4 deletions hatchet/tests/caliper.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import subprocess
import numpy as np
import pandas as pd

import pytest
import sys
Expand Down Expand Up @@ -196,7 +195,7 @@ def test_graphframe_native_lulesh_from_file(lulesh_caliper_cali):
if col in ("time (inc)", "time"):
assert gf.dataframe[col].dtype == np.float64
elif col in ("nid", "rank"):
assert gf.dataframe[col].dtype == pd.Int64Dtype()
assert gf.dataframe[col].dtype == np.float64
elif col in ("name", "node"):
assert gf.dataframe[col].dtype == object

Expand All @@ -222,7 +221,7 @@ def test_graphframe_native_lulesh_from_caliperreader(lulesh_caliper_cali):
if col in ("time (inc)", "time"):
assert gf.dataframe[col].dtype == np.float64
elif col in ("nid", "rank"):
assert gf.dataframe[col].dtype == pd.Int64Dtype()
assert gf.dataframe[col].dtype == np.float64
elif col in ("name", "node"):
assert gf.dataframe[col].dtype == object

Expand Down Expand Up @@ -882,7 +881,7 @@ def test_graphframe_timeseries_lulesh_from_file(caliper_timeseries_cali):
if col in ("time (inc)", "time"):
assert gf.dataframe[col].dtype == np.float64
elif col in ("nid", "rank"):
assert gf.dataframe[col].dtype == pd.Int64Dtype()
assert gf.dataframe[col].dtype == np.float64
elif col in ("name", "node"):
assert gf.dataframe[col].dtype == object

Expand Down

0 comments on commit 5cccd40

Please sign in to comment.