Skip to content

Commit

Permalink
rhv_txt
Browse files Browse the repository at this point in the history
  • Loading branch information
mshuaibii committed Jan 29, 2025
1 parent d513ffa commit e68a9e4
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/fairchem/core/datasets/base_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,17 +189,16 @@ def create_dataset(config: dict[str, Any], split: str) -> Subset:
raise ValueError(
f"Cannot use {subset_to} without dataset metadata key {subset_to['metadata_key']}"
)
rhv = subset_to["rhv"]
if isinstance(rhv, str):
with open(rhv) as f:
rhv = f.read().splitlines()
rhv = [int(x) for x in rhv]
if subset_to["op"] == "abs_le":
indices = indices[
np.abs(dataset.get_metadata(subset_to["metadata_key"], indices))
<= subset_to["rhv"]
]
indices = indices[np.rhv <= rhv]
elif subset_to["op"] == "in":
indices = indices[
np.isin(
dataset.get_metadata(subset_to["metadata_key"], indices),
subset_to["rhv"],
)
np.isin(dataset.get_metadata(subset_to["metadata_key"], indices), rhv)
]

# Apply dataset level transforms
Expand Down

0 comments on commit e68a9e4

Please sign in to comment.