Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
Signed-off-by: Jinzhe Zeng <[email protected]>
  • Loading branch information
njzjz committed Sep 15, 2023
1 parent d332bfb commit f171c49
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/test_custom_data_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import numpy as np

import dpdata
from dpdata.data_type import Axis, DataType


class TestDeepmdLoadDumpComp(unittest.TestCase):
Expand Down Expand Up @@ -44,6 +45,13 @@ def test_from_deepmd_hdf5(self):
x = dpdata.LabeledSystem("data_foo.h5", fmt="deepmd/hdf5")
np.testing.assert_allclose(x.data["foo"], self.foo)

def test_duplicated_data_type(self):
dt = DataType("foo", np.ndarray, (Axis.NFRAMES, 2, 4), required=False)
n_dtypes_old = len(dpdata.LabeledSystem.DTYPES)
with self.assertWarns(UserWarning):
dpdata.LabeledSystem.register_data_type(dt)
n_dtypes_new = len(dpdata.LabeledSystem.DTYPES)
self.assertEqual(n_dtypes_old, n_dtypes_new)

class TestDeepmdLoadDumpCompAny(unittest.TestCase):
def setUp(self):
Expand Down

0 comments on commit f171c49

Please sign in to comment.