diff --git a/chgnet/data/dataset.py b/chgnet/data/dataset.py index a7dfc023..58ff6523 100644 --- a/chgnet/data/dataset.py +++ b/chgnet/data/dataset.py @@ -53,10 +53,11 @@ def __init__( [energies, forces, stresses, magmoms], ["energies, forces,stresses, magmoms"], ): - assert len(label) == len(structures), ( - f"Error! inconsistent number of structures and labels: " - f" len(structures)={len(structures)}, len({name})={len(label)})" - ) + if len(label) != len(structures): + raise ValueError( + f"Error! inconsistent number of structures and labels: " + f" len(structures)={len(structures)}, len({name})={len(label)})" + ) self.structures = structures self.energies = energies self.forces = forces