Skip to content

Commit bc617b7

Browse files
njzjz-botOpenClaw Botpre-commit-ci[bot]
authored
refact: refactor format backends into dpdata.formats (#970)
This PR fixes the CI failures from #946 after moving implementation modules. Changes: - Keep real format backends under `dpdata.formats`. - Move the non-format MD analysis/tool modules back to `dpdata.md` instead of `dpdata.formats.md`. - Do not preserve `dpdata.lammps` / `dpdata.vasp` as top-level exports. - Add explicit package exports for the newly moved format subpackages under `dpdata.formats`. - Update direct helper imports in tests/internal code to their new locations: - `dpdata.formats.cp2k.cell.cell_to_low_triangle` - `dpdata.formats.gaussian.gjf.detect_multiplicity` - `dpdata.formats.qe.traj.convert_celldm` - `dpdata.formats.amber.md.cell_lengths_angles_to_cell` - `dpdata.md.msd.msd` - `dpdata.md.water.*` Follow-up: - Removed the legacy `dpdata.<format>` wrapper modules that were added earlier; this branch no longer keeps those old import paths alive. Local checks: - `cd tests && uv run pytest test_amber_md.py test_cell_to_low_triangle.py test_gaussian_driver.py::TestMakeGaussian::test_detect_multiplicity test_qe_cp_traj.py::TestConverCellDim test_msd.py test_water_ions.py -q` → 45 passed - `uv run pyright` → currently reports 2 pre-existing missing `_version` / `__version__` diagnostics in `dpdata/__init__.py` and `dpdata/cli.py` - `git grep -n "from dpdata\.formats\..* import \*\|legacy" -- dpdata tests` → no matches Authored by OpenClaw (model: custom-chat-jinzhezeng-group/gpt-5.5) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes * **Refactor** * Reorganized internal format handler modules into a dedicated `formats` subdirectory for improved code structure and maintainability. * Updated internal import paths throughout the codebase to reflect the new module organization structure. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: OpenClaw Bot <bot@openclaw.dev> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 6cdc360 commit bc617b7

100 files changed

Lines changed: 185 additions & 154 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

dpdata/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22

3-
from . import lammps, md, vasp
3+
from . import md
44
from .bond_order_system import BondOrderSystem
55
from .system import LabeledSystem, MultiSystems, System
66

@@ -9,11 +9,10 @@
99
except ImportError:
1010
from .__about__ import __version__
1111

12+
1213
__all__ = [
1314
"__version__",
14-
"lammps",
1515
"md",
16-
"vasp",
1716
"System",
1817
"LabeledSystem",
1918
"MultiSystems",

dpdata/bond_order_system.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77
import numpy as np
88

9-
import dpdata.rdkit.utils
10-
from dpdata.rdkit.sanitize import Sanitizer
9+
import dpdata.formats.rdkit.utils
10+
from dpdata.formats.rdkit.sanitize import Sanitizer
1111
from dpdata.system import Axis, DataType, System
1212

13-
# import dpdata.rdkit.mol2
13+
# import dpdata.formats.rdkit.mol2
1414

1515

1616
class BondOrderSystem(System):
@@ -79,7 +79,7 @@ def __init__(
7979
self.sanitizer = Sanitizer(sanitize_level, raise_errors, verbose)
8080

8181
if data:
82-
mol = dpdata.rdkit.utils.system_data_to_mol(data)
82+
mol = dpdata.formats.rdkit.utils.system_data_to_mol(data)
8383
self.from_rdkit_mol(mol)
8484
if file_name:
8585
self.from_fmt(
@@ -161,7 +161,7 @@ def __add__(self, other):
161161
# magic method "+" operation
162162
# '''
163163
# if isinstance(other, BondOrderSystem):
164-
# if dpdata.rdkit.utils.check_same_molecule(self.rdkit_mol, other.rdkit_mol):
164+
# if dpdata.formats.rdkit.utils.check_same_molecule(self.rdkit_mol, other.rdkit_mol):
165165
# self.__class__(self, data=other.data)
166166
# else:
167167
# raise RuntimeError("The two systems are not of the same topology.")
@@ -171,7 +171,7 @@ def __add__(self, other):
171171
def from_rdkit_mol(self, rdkit_mol):
172172
"""Initialize from a rdkit.Chem.rdchem.Mol object."""
173173
rdkit_mol = self.sanitizer.sanitize(rdkit_mol)
174-
self.data = dpdata.rdkit.utils.mol_to_system_data(rdkit_mol)
174+
self.data = dpdata.formats.rdkit.utils.mol_to_system_data(rdkit_mol)
175175
self.data["bond_dict"] = dict(
176176
[(f"{int(bond[0])}-{int(bond[1])}", bond[2]) for bond in self.data["bonds"]]
177177
)

dpdata/formats/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Format modules for dpdata
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from dpdata.utils import open_file
1010

11-
from ..unit import LengthConversion, PressureConversion
11+
from ...unit import LengthConversion, PressureConversion
1212
from .stru import get_frame_from_stru
1313

1414
bohr2ang = LengthConversion("bohr", "angstrom").value()
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import numpy as np
88

9-
from ..unit import LengthConversion
9+
from ...unit import LengthConversion
1010

1111
bohr2ang = LengthConversion("bohr", "angstrom").value()
1212

0 commit comments

Comments
 (0)