From f171c491c48c09031d0d78fb1f04c010bfbe8084 Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Fri, 15 Sep 2023 17:15:30 -0400 Subject: [PATCH] add test Signed-off-by: Jinzhe Zeng --- tests/test_custom_data_type.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/test_custom_data_type.py b/tests/test_custom_data_type.py index 5a0e2bab..42d51abf 100644 --- a/tests/test_custom_data_type.py +++ b/tests/test_custom_data_type.py @@ -4,6 +4,7 @@ import numpy as np import dpdata +from dpdata.data_type import Axis, DataType class TestDeepmdLoadDumpComp(unittest.TestCase): @@ -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):