Skip to content

[BUG] system cannot be appended to multi-systems if it has been dumped in mixed type format #670

@wanghan-iapcm

Description

@wanghan-iapcm

Bug summary

system cannot be apppended to multi-systems if it is dumped to a mixed type format

dpdata Version

0.2.19

Input Files, Running Commands, Error Log, etc.

does not apply

Steps to Reproduce

import dpdata
import numpy as np

system_1 = dpdata.System()
system_1.data["atom_names"] = ["foo", "bar"]
system_1.data["atom_types"] = np.array([1, 0], dtype=int)
system_1.data["atom_numbs"] = [1, 1]
system_1.data["cells"] = np.array(
    [10, 0, 0, 0, 10, 0, 0, 0, 10], dtype=float
).reshape(1, 3, 3)
system_1.data["coords"] = np.array(
    [0, 0, 0, 0, 0, 1], dtype=float
).reshape(1, 2, 3)

system_1.to('deepmd/npy/mixed', 'tmptmp')

ms = dpdata.MultiSystems()
ms.append(system_1)

the error raised is

Traceback (most recent call last):
  File "/root/Manual/Washed-restart/replicateerr/wanghan.1/test.py", line 18, in <module>
    ms.append(system_1)
  File "/opt/deepmd-kit-3.0.0/lib/python3.10/site-packages/dpdata/system.py", line 1485, in append
    self.__append(system)
  File "/opt/deepmd-kit-3.0.0/lib/python3.10/site-packages/dpdata/system.py", line 1497, in __append
    system = system.copy()
  File "/opt/deepmd-kit-3.0.0/lib/python3.10/site-packages/dpdata/system.py", line 434, in copy
    return self.__class__.from_dict({"data": deepcopy(self.data)})
  File "/opt/deepmd-kit-3.0.0/lib/python3.10/site-packages/dpdata/system.py", line 397, in from_dict
    return cls(**decoded)
  File "/opt/deepmd-kit-3.0.0/lib/python3.10/site-packages/dpdata/system.py", line 196, in __init__
    self.check_data()
  File "/opt/deepmd-kit-3.0.0/lib/python3.10/site-packages/dpdata/system.py", line 224, in check_data
    dd.check(self)
  File "/opt/deepmd-kit-3.0.0/lib/python3.10/site-packages/dpdata/data_type.py", line 120, in check
    raise DataError(
dpdata.data_type.DataError: Length of real_atom_names is 2, but expected 1

Further Information, Files, and Links

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions