Skip to content

Commit d87c34a

Browse files
committed
rename gap/xyz to quip/gap/xyz
1 parent 8c70129 commit d87c34a

File tree

4 files changed

+31
-29
lines changed

4 files changed

+31
-29
lines changed

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,16 @@ The labels provided in the `OUTCAR`, i.e. energies, forces and virials (if any),
5151

5252
The `System` or `LabeledSystem` can be constructed from the following file formats with the `format key` in the table passed to argument `fmt`:
5353

54-
For `gap/quip xyz` files, single .xyz file may include many different configurations with different atom numbers and atom type.
54+
For `quip/gap xyz` files, single .xyz file may include many different configurations with different atom numbers and atom type.
5555

5656
The Class `dpdata.MultiSystems` can read data this kind of file.
57-
Now Class dpdata.MultiSystems Only support gap/quip xyz format file.
57+
Now Class dpdata.MultiSystems Only support quip/gap xyz format file.
5858

5959
The following commands relating to `Class dpdata.MultiSystems` may be useful.
6060
```python
6161
# load data
62-
# note that in the second case the prefix 'file_name=' and 'fmt=' can NOT be omitted
63-
xyz_multi_systems = dpdata.MultiSystems.from_file('tests/xyz/xyz_unittest.xyz','gap/xyz')
64-
xyz_multi_systems = dpdata.MultiSystems(file_name='tests/syz/xyz_unittest.xyz', fmt='gap/xyz')
62+
63+
xyz_multi_systems = dpdata.MultiSystems.from_file('tests/xyz/xyz_unittest.xyz','quip/gap/xyz')
6564

6665
# print the multi_system infomation
6766
print(xyz_multi_systems)
@@ -98,7 +97,7 @@ xyz_multi_systems.to_deepmd_raw('./my_deepmd_data/')
9897
| QE | log | False | True | LabeledSystem | 'qe/pw/scf' |
9998
| QE | log | True | False | System | 'qe/cp/traj' |
10099
| QE | log | True | True | LabeledSystem | 'qe/cp/traj' |
101-
|gap/quip|xyz|True|True|MultiSystems|'gap/xyz'|
100+
|quip/gap|xyz|True|True|MultiSystems|'quip/gap/xyz'|
102101

103102
## Access data
104103
These properties stored in `System` and `LabeledSystem` can be accessed by operator `[]` with the key of the property supplied, for example

dpdata/system.py

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from monty.json import MSONable
2020
from monty.serialization import loadfn,dumpfn
2121
from dpdata.periodic_table import Element
22-
from dpdata.xyz.gap_xyz import GapxyzSystems
22+
from dpdata.xyz.quip_gap_xyz import QuipGapxyzSystems
2323

2424
class System (MSONable) :
2525
'''
@@ -905,7 +905,7 @@ def sort_atom_types(self):
905905
class MultiSystems:
906906
'''A set containing several systems.'''
907907

908-
def __init__(self, *systems,file_name=None, fmt=None,type_map=None):
908+
def __init__(self, *systems,type_map=None):
909909
"""
910910
Parameters
911911
----------
@@ -920,15 +920,6 @@ def __init__(self, *systems,file_name=None, fmt=None,type_map=None):
920920
else:
921921
self.atom_names = []
922922
self.append(*systems)
923-
if file_name is not None:
924-
if fmt is None:
925-
raise RuntimeError("must specify file format for file {}".format(file_name))
926-
elif fmt == 'gap/xyz' or 'xyz':
927-
self.from_gap_xyz_file(file_name)
928-
else:
929-
raise RuntimeError("unknown file format for file {} format {},now supported 'gap/xyz'".format(file_name, fmt))
930-
931-
932923

933924
def __getitem__(self, key):
934925
"""Returns proerty stored in System by key or by idx"""
@@ -955,8 +946,20 @@ def __add__(self, others) :
955946
raise RuntimeError("Unspported data structure")
956947

957948
@classmethod
958-
def from_file(cls,file_name,fmt,type_map=None):
959-
return cls(file_name=file_name, fmt=fmt,type_map=type_map)
949+
def from_file(cls,file_name,fmt):
950+
multi_systems = cls()
951+
multi_systems.load_systems_from_file(file_name=file_name,fmt=fmt)
952+
return multi_systems
953+
954+
def load_systems_from_file(self, file_name=None, fmt=None):
955+
if file_name is not None:
956+
if fmt is None:
957+
raise RuntimeError("must specify file format for file {}".format(file_name))
958+
elif fmt == 'quip/gap/xyz' or 'xyz':
959+
self.from_quip_gap_xyz_file(file_name)
960+
else:
961+
raise RuntimeError("unknown file format for file {} format {},now supported 'quip/gap/xyz'".format(file_name, fmt))
962+
960963

961964
def get_nframes(self) :
962965
"""Returns number of frames in all systems"""
@@ -1012,10 +1015,10 @@ def check_atom_names(self, system):
10121015
system.add_atom_names(new_in_self)
10131016
system.sort_atom_names()
10141017

1015-
def from_gap_xyz_file(self,filename):
1016-
# gap_xyz_systems = GapxyzSystems(filename)
1017-
# print(next(gap_xyz_systems))
1018-
for info_dict in GapxyzSystems(filename):
1018+
def from_quip_gap_xyz_file(self,filename):
1019+
# quip_gap_xyz_systems = QuipGapxyzSystems(filename)
1020+
# print(next(quip_gap_xyz_systems))
1021+
for info_dict in QuipGapxyzSystems(filename):
10191022
system=LabeledSystem(data=info_dict)
10201023
self.append(system)
10211024

dpdata/xyz/gap_xyz.py renamed to dpdata/xyz/quip_gap_xyz.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
import numpy as np
99
from collections import OrderedDict
1010
import re
11-
class GapxyzSystems(object):
11+
class QuipGapxyzSystems(object):
1212
"""
13-
deal with GapxyzFile
13+
deal with QuipGapxyzFile
1414
"""
1515
def __init__(self, file_name):
1616
self.file_object = open(file_name, 'r')

tests/test_gap_xyz.py renamed to tests/test_quip_gap_xyz.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44
from context import dpdata
55
from comp_sys import CompLabeledSys
66

7-
class TestGapxyz(unittest.TestCase, CompLabeledSys):
7+
class TestQuipGapxyz(unittest.TestCase, CompLabeledSys):
88
def setUp (self) :
9-
self.multi_systems = dpdata.MultiSystems.from_file('xyz/xyz_unittest.xyz','gap/xyz')
9+
self.multi_systems = dpdata.MultiSystems.from_file('xyz/xyz_unittest.xyz','quip/gap/xyz')
1010
self.system_1 = self.multi_systems.systems['B1C9']
1111
self.system_2 = dpdata.LabeledSystem('xyz/B1C9', fmt='deepmd')
1212
self.places = 6
1313
self.e_places = 6
1414
self.f_places = 6
1515
self.v_places = 4
1616

17-
class TestGapxyz2(unittest.TestCase, CompLabeledSys):
17+
class TestQuipGapxyz2(unittest.TestCase, CompLabeledSys):
1818
def setUp (self) :
19-
self.system_temp0 = dpdata.MultiSystems(file_name='xyz/xyz_unittest.xyz', fmt='gap/xyz')
19+
self.system_temp0 = dpdata.MultiSystems.from_file(file_name='xyz/xyz_unittest.xyz', fmt='quip/gap/xyz')
2020
self.system_1 = self.system_temp0.systems['B5C7']
2121
self.system_temp1 = dpdata.LabeledSystem('xyz/B1C9', fmt='deepmd')
2222
self.system_temp2 = dpdata.LabeledSystem('xyz/B5C7', fmt='deepmd')

0 commit comments

Comments
 (0)