Skip to content

Commit

Permalink
fix up datasetmetadata
Browse files Browse the repository at this point in the history
  • Loading branch information
misko committed Dec 18, 2024
1 parent 0124228 commit bffcb10
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/fairchem/core/datasets/base_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@
T_co = TypeVar("T_co", covariant=True)


class DatasetMetadata(NamedTuple):
natoms: ArrayLike | None = None
class DatasetMetadata:
def __init__(self, natoms: ArrayLike | None = None, **kwargs):
self.natoms = natoms
for key, value in kwargs.items():
setattr(self, key, value)


class UnsupportedDatasetError(ValueError):
Expand Down Expand Up @@ -106,9 +109,10 @@ def _metadata(self) -> DatasetMetadata:
metadata = DatasetMetadata(
**{
field: np.concatenate([metadata[field] for metadata in metadata_npzs])
for field in DatasetMetadata._fields
for field in metadata_npzs[0].keys()
}
)

assert np.issubdtype(
metadata.natoms.dtype, np.integer
), f"Metadata natoms must be an integer type! not {metadata.natoms.dtype}"
Expand Down

0 comments on commit bffcb10

Please sign in to comment.