Skip to content

Commit 22890d6

Browse files
authored
Merge branch 'dev' into dev
2 parents 395ce89 + 0f5da11 commit 22890d6

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

monai/data/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1473,7 +1473,7 @@ def convert_tables_to_dicts(
14731473
# parse row indices
14741474
rows: list[int | str] = []
14751475
if row_indices is None:
1476-
rows = slice(df.shape[0]) # type: ignore
1476+
rows = df.index.tolist()
14771477
else:
14781478
for i in row_indices:
14791479
if isinstance(i, (tuple, list)):

monai/utils/misc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ def doc_images() -> str | None:
546546

547547
@staticmethod
548548
def algo_hash() -> str | None:
549-
return os.environ.get("MONAI_ALGO_HASH", "c970bdf")
549+
return os.environ.get("MONAI_ALGO_HASH", "fd19f8a")
550550

551551
@staticmethod
552552
def trace_transform() -> str | None:

tests/data/test_csv_dataset.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,20 @@ def prepare_csv_file(data, filepath):
179179
},
180180
)
181181

182+
# test pre-loaded DataFrame subset
183+
df = pd.read_csv(filepath1)
184+
df_subset = df.iloc[[1, 3, 4]]
185+
dataset = CSVDataset(src=df_subset, col_groups={"ehr": [f"ehr_{i}" for i in range(3)]})
186+
self.assertEqual(len(dataset), 3)
187+
np.testing.assert_allclose([round(i, 4) for i in dataset[1]["ehr"]], [3.3333, 3.2353, 3.4000])
188+
189+
# test pre-loaded DataFrame subset with row_indices != None
190+
df = pd.read_csv(filepath1)
191+
df_subset = df.iloc[[1, 3, 4]]
192+
dataset = CSVDataset(src=df_subset, row_indices=[1, 3], col_groups={"ehr": [f"ehr_{i}" for i in range(3)]})
193+
self.assertEqual(len(dataset), 2)
194+
np.testing.assert_allclose([round(i, 4) for i in dataset[1]["ehr"]], [3.3333, 3.2353, 3.4000])
195+
182196
# test pre-loaded multiple DataFrames, join tables with kwargs
183197
dfs = [pd.read_csv(i) for i in filepaths]
184198
dataset = CSVDataset(src=dfs, on="subject_id")

0 commit comments

Comments
 (0)