diff --git a/dpdata/system.py b/dpdata/system.py index 8af8e4a5..65e0a39f 100644 --- a/dpdata/system.py +++ b/dpdata/system.py @@ -1,6 +1,7 @@ # %% import glob import os +import warning from copy import deepcopy from typing import Any, Dict, Optional, Tuple, Union @@ -963,7 +964,13 @@ def register_data_type(cls, *data_type: Tuple[DataType]): *data_type : tuple[DataType] data type to be regiestered """ - cls.DTYPES = cls.DTYPES + tuple(data_type) + all_dtypes = cls.DTYPES + tuple(data_type) + dtypes_dict = {} + for dt in all_dtypes: + if dt.name in dtypes_dict: + warnings.warn(f"Data type {dt.name} is registered twice; only the newly registered one will be used.", UserWarning) + dtypes_dict[dt.name] = dt + cls.DTYPES = tuple(dtypes_dict.values()) def get_cell_perturb_matrix(cell_pert_fraction):