pwdata 0.4.4__tar.gz → 0.4.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pwdata might be problematic. Click here for more details.

Files changed (68) hide show
  1. {pwdata-0.4.4 → pwdata-0.4.5}/PKG-INFO +1 -1
  2. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/check_envs.py +4 -0
  3. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/convert_files.py +13 -0
  4. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/main.py +43 -1
  5. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/test/mptraj2lmdb.py +0 -8
  6. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/test.py +33 -5
  7. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata.egg-info/PKG-INFO +1 -1
  8. {pwdata-0.4.4 → pwdata-0.4.5}/setup.py +1 -1
  9. {pwdata-0.4.4 → pwdata-0.4.5}/LICENSE +0 -0
  10. {pwdata-0.4.4 → pwdata-0.4.5}/README.md +0 -0
  11. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/__init__.py +0 -0
  12. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/atomconfig.py +0 -0
  13. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/build/__init__.py +0 -0
  14. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/build/cell.py +0 -0
  15. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/build/geometry.py +0 -0
  16. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/build/supercells.py +0 -0
  17. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/build/write_struc.py +0 -0
  18. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/calculators/__init__.py +0 -0
  19. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/calculators/const.py +0 -0
  20. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/calculators/unitconvert_lmps.py +0 -0
  21. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/calculators/units.py +0 -0
  22. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/config.py +0 -0
  23. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/cp2kdata.py +0 -0
  24. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/datasets_saver.py +0 -0
  25. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/deepmd.py +0 -0
  26. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/dump.py +0 -0
  27. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/extendedxyz.py +0 -0
  28. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/fairchem/__init__.py +0 -0
  29. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/fairchem/common/__init__.py +0 -0
  30. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/fairchem/common/registry.py +0 -0
  31. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/fairchem/common/typing.py +0 -0
  32. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/fairchem/common/utils.py +0 -0
  33. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/fairchem/datasets/__init__.py +0 -0
  34. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/fairchem/datasets/_utils.py +0 -0
  35. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/fairchem/datasets/ase_datasets.py +0 -0
  36. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/fairchem/datasets/base_dataset.py +0 -0
  37. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/fairchem/datasets/embeddings/__init__.py +0 -0
  38. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/fairchem/datasets/embeddings/atomic_radii.py +0 -0
  39. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/fairchem/datasets/embeddings/continuous_embeddings.py +0 -0
  40. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/fairchem/datasets/embeddings/khot_embeddings.py +0 -0
  41. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/fairchem/datasets/embeddings/qmof_khot_embeddings.py +0 -0
  42. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/fairchem/datasets/lmdb_database.py +0 -0
  43. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/fairchem/datasets/target_metadata_guesser.py +0 -0
  44. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/fairchem/modules/__init__.py +0 -0
  45. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/fairchem/modules/transforms.py +0 -0
  46. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/fairchem/preprocessing/__init__.py +0 -0
  47. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/image.py +0 -0
  48. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/lammpsdata.py +0 -0
  49. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/lmps.py +0 -0
  50. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/meta.py +0 -0
  51. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/movement.py +0 -0
  52. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/movement_saver.py +0 -0
  53. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/outcar.py +0 -0
  54. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/pertub/__init__.py +0 -0
  55. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/pertub/perturbation.py +0 -0
  56. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/pertub/scale.py +0 -0
  57. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/poscar.py +0 -0
  58. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/pwmlff.py +0 -0
  59. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/test/__init__.py +0 -0
  60. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/test/mdtrajs2config.py +0 -0
  61. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/utils/__init__.py +0 -0
  62. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata/utils/constant.py +0 -0
  63. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata.egg-info/SOURCES.txt +0 -0
  64. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata.egg-info/dependency_links.txt +0 -0
  65. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata.egg-info/entry_points.txt +0 -0
  66. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata.egg-info/requires.txt +0 -0
  67. {pwdata-0.4.4 → pwdata-0.4.5}/pwdata.egg-info/top_level.txt +0 -0
  68. {pwdata-0.4.4 → pwdata-0.4.5}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pwdata
3
- Version: 0.4.4
3
+ Version: 0.4.5
4
4
  Summary: pwdata is a data pre-processing tool for PWMLFF, which can be used to extract features and labels. It also provides convenient interfaces for data conversion between different software.
5
5
  Home-page: https://github.com/LonxunQuantum/pwdata
6
6
  Author: LonxunQuantum
@@ -29,6 +29,10 @@ def cmd_infos():
29
29
  info += "\tExtract various trajectory files(movement of PWmat, outcar of Vasp, lammps/dump of Lammps, cp2k-mdfile of CP2K) or data sets (deepmd/npy, deepmd/raw, extxyz, meta aselmdb) into pwmlff/npy or extxyz format, the command example:\n"
30
30
  info += "\tpwdata convert_images -i input_file1 input_file2 ... input_filen -f input_file_format -n output_format_name -o output_format\n\n"
31
31
 
32
+ info += "count or count_configs:\n"
33
+ info += "\tThis command is used to count the number of input structures, the command example:\n"
34
+ info += "\tpwdata count -i input_file1 input_file2 ... input_filen -f input_file_format\n\n"
35
+
32
36
  info += "format suppport\n"
33
37
  info += "__________________________________________________________________________________________|\n"
34
38
  info += "| Software | file | multi-Image | label | format |\n"
@@ -131,6 +131,19 @@ def do_convert_images(
131
131
  image_data = load_files(data_files, input_format, atom_types=atom_types, query=query, cpu_nums=cpu_nums)
132
132
  save_images(savepath, image_data, output_format, train_valid_ratio, data_shuffle, merge)
133
133
 
134
+
135
+ def do_count_images(
136
+ input:list[str],
137
+ input_format:str = None,
138
+ atom_types:list[str]=None,
139
+ query:str=None,
140
+ cpu_nums:int=None
141
+ ):
142
+ data_files = search_images(input, input_format)
143
+ image_data = load_files(data_files, input_format, atom_types=atom_types, query=query, cpu_nums=cpu_nums)
144
+ print("\n\n******The number of configs is {}******\n\n".format(len(image_data.images)))
145
+ return len(image_data.images)
146
+
134
147
  '''
135
148
  description:
136
149
  save the image_datas to pwmlff/npy or extxyz format
@@ -22,7 +22,7 @@ sys.path.append(os.path.dirname(os.path.abspath(__file__)))
22
22
  # from pwdata.datasets_saver import save_to_dataset, get_pw, save_to_raw, save_to_npy
23
23
  # from pwdata.build.write_struc import write_config, write_vasp, write_lammps
24
24
  import argparse
25
- from pwdata.convert_files import do_scale_cell, do_super_cell, do_perturb, do_convert_config, do_convert_images
25
+ from pwdata.convert_files import do_scale_cell, do_super_cell, do_perturb, do_convert_config, do_convert_images, do_count_images
26
26
  from pwdata.utils.constant import FORMAT, get_atomic_name_from_number
27
27
  from pwdata.check_envs import print_cmd
28
28
 
@@ -331,6 +331,17 @@ def main(cmd_list:list=None):
331
331
  run_convert_config(cmd_list[2:])
332
332
  elif "convert_configs".upper() == cmd_list[1].upper() or "cvt_configs".upper() == cmd_list[1].upper():
333
333
  run_convert_configs(cmd_list[2:])
334
+ elif "count".upper() == cmd_list[1].upper() or "count_configs".upper() == cmd_list[1].upper():
335
+ if '.json' in cmd_list[1].lower():
336
+ format = json_dict['format'] if 'format' in json_dict.keys() else None
337
+ raw_files = json_dict['raw_files']
338
+ cmd_list = ["count", "-i", cmd_list[1]]
339
+ if format is not None:
340
+ cmd_list.extend(['-f', format])
341
+ count_configs(cmd_list) # pwdata count extract.json
342
+ else:
343
+ count_configs(cmd_list[2:]) # pwdata count -i inputs -f pwmat/config
344
+
334
345
  else:
335
346
  print("\n\nERROR! Input cannot be recognized!\n\n\n")
336
347
  print_cmd()
@@ -490,5 +501,36 @@ def run_convert_configs(cmd_list:list[str]):
490
501
  merge = True if args.merge == 1 else False
491
502
  do_convert_images(input_list, args.input_format, args.savepath, args.output_format, args.train_valid_ratio, args.split_rand, args.gap, atom_types, args.query, args.cpu_nums, merge)
492
503
 
504
+
505
+ def count_configs(cmd_list:list[str]):
506
+ parser = argparse.ArgumentParser(description='This command is used to count the number of input structures\n')
507
+ parser.add_argument('-i', '--input', type=str, required=True, nargs='+', help="The directory or file path of the datas.\nYou can also use JSON file to list all file paths in 'datapath': [], such as 'pwdata/test/meta_data.json'")
508
+ parser.add_argument('-f', '--input_format', type=str, required=False, default=None, help="The input file format, if not specified, the format will be automatically inferred based on the input files. the supported format as {}".format(FORMAT.support_images_format))
509
+ parser.add_argument('-q', '--query', type=str, required=False, help='For meta data, advanced query statement, filter Mata data based on query criteria, detailed usage reference http://doc.lonxun.com/PWMLFF/Appendix-2', default=None)
510
+ parser.add_argument('-n', '--cpu_nums', type=int, default=1, required=False, help='For meta data, parallel reading of meta databases using kernel count, default to using all available cores')
511
+ parser.add_argument('-t', '--atom_types', type=str, required=False, nargs='+', help="For 'lammps/lmp', 'lammps/dump': the atom type list of lammps lmp/dump file, the order is same as lammps dump file.\nFor meta data: Query structures that only exist for that element type", default=None)
512
+
513
+ args = parser.parse_args(cmd_list)
514
+ try:
515
+ atom_types = get_atomic_name_from_number(args.atom_types)
516
+ except Exception as e:
517
+ atom_types = args.atom_types
518
+ input_list = []
519
+ for _input in args.input:
520
+ if os.path.isfile(_input) and "json" in os.path.basename(_input) and os.path.exists(_input):
521
+ input = json.load(open(_input))['datapath']
522
+ dicts = json.load(open(_input))
523
+ input = dicts['datapath'] if 'datapath' in dicts.keys() else None
524
+ if input is None:
525
+ input = dicts['raw_files'] if 'raw_files' in dicts.keys() else None
526
+ if isinstance(input, str):
527
+ input = [input]
528
+ input_list.extend(input)
529
+ else:
530
+ assert os.path.exists(_input)
531
+ input_list.append(_input)
532
+
533
+ do_count_images(input_list, args.input_format, atom_types, args.query, args.cpu_nums)
534
+
493
535
  if __name__ == "__main__":
494
536
  main()
@@ -3,8 +3,6 @@ description:
3
3
  Convert MPtraj JSON file to aselmdb format
4
4
  '''
5
5
 
6
- from pwdata import Config
7
- from pwdata.utils.constant import FORMAT
8
6
  import json
9
7
  from pwdata.fairchem.datasets.ase_datasets import LMDBDatabase
10
8
  from ase import Atoms
@@ -25,14 +23,10 @@ def MPjson2lmdb():
25
23
  db.close()
26
24
 
27
25
  def cvt_dict_2_atomrow(config:dict):
28
- # read cell
29
26
  cell = read_from_dict('matrix', config['structure']['lattice'], require=True)
30
- # read position
31
27
  atom_type_list = get_atomic_number_from_name([_['label'] for _ in config['structure']['sites']])
32
28
  position = [_['xyz'] for _ in config['structure']['sites']]
33
- # read magmom
34
29
  magmom = read_from_dict('magmom', config, require=True)
35
-
36
30
  atom = Atoms(positions=position,
37
31
  numbers=atom_type_list,
38
32
  magmoms=magmom,
@@ -43,7 +37,6 @@ def cvt_dict_2_atomrow(config:dict):
43
37
  # read stress -> xx, yy, zz, yz, xz, xy
44
38
  stress = read_from_dict('stress', config, require=True)
45
39
  atom_rows.stress = [stress[0][0],stress[1][1],stress[2][2],stress[1][2],stress[0][2],stress[0][1]]
46
- # read force and energy
47
40
  force = read_from_dict('force', config, require=True)
48
41
  energy = read_from_dict('corrected_total_energy', config, require=True)
49
42
  atom_rows.__setattr__('force', force)
@@ -57,7 +50,6 @@ def cvt_dict_2_atomrow(config:dict):
57
50
  data['ef_per_atom_relaxed'] = read_from_dict('ef_per_atom_relaxed', config, default=None)
58
51
  data['bandgap'] = read_from_dict('bandgap', config, default=None)
59
52
  data['mp_id'] = read_from_dict('mp_id', config, default=None)
60
- # atom_rows._data = data
61
53
  return atom_rows, data
62
54
 
63
55
  def read_from_dict(key:str, config:dict, default=None, require=False):
@@ -123,6 +123,33 @@ def test_convert_configs():
123
123
  res_list.append(cmd_list)
124
124
  return res_list
125
125
 
126
+
127
+ def test_count_configs():
128
+ res_list = []
129
+ configs = json.load(open("./config.json"))["convert_configs"]
130
+ for idi, config in enumerate(configs):
131
+ config_file = config["input_file"]
132
+ if isinstance(config_file, str):
133
+ config_file = [config_file]
134
+
135
+ for _ in config_file:
136
+ if not os.path.exists(_):
137
+ print("{} not exists".format(_))
138
+ if "atom_types" in config.keys():
139
+ atom_types = config["atom_types"]
140
+ else:
141
+ atom_types = None
142
+ for idj, format in enumerate([FORMAT.pwmlff_npy, FORMAT.extxyz]):
143
+ cmd_list = ["", "count"]
144
+ cmd_list.append("-i")
145
+ cmd_list.extend(config_file)
146
+ if atom_types is not None:
147
+ cmd_list.append("-t")
148
+ cmd_list.extend(atom_types)
149
+ main(cmd_list)
150
+ res_list.append(cmd_list)
151
+ return res_list
152
+
126
153
  def test_meata_data():
127
154
  res_list = []
128
155
  # res = search_images(config_file, config_format)
@@ -152,11 +179,12 @@ if __name__ == "__main__":
152
179
  # run_cmd(["", "cvt_configs", "-h"])
153
180
  os.chdir(os.path.join(os.path.dirname(os.path.dirname(__file__)), "examples"))
154
181
  cmd_list = []
155
- cmd_list.extend(test_scale_cell())
156
- cmd_list.extend(test_super_cell())
157
- cmd_list.extend(test_pertub())
158
- cmd_list.extend(test_convert_config())
159
- cmd_list.extend(test_convert_configs())
182
+ # cmd_list.extend(test_scale_cell())
183
+ # cmd_list.extend(test_super_cell())
184
+ # cmd_list.extend(test_pertub())
185
+ # cmd_list.extend(test_convert_config())
186
+ # cmd_list.extend(test_convert_configs())
187
+ cmd_list.extend(test_count_configs())
160
188
 
161
189
  for cmd in cmd_list:
162
190
  print(" ".join(cmd))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pwdata
3
- Version: 0.4.4
3
+ Version: 0.4.5
4
4
  Summary: pwdata is a data pre-processing tool for PWMLFF, which can be used to extract features and labels. It also provides convenient interfaces for data conversion between different software.
5
5
  Home-page: https://github.com/LonxunQuantum/pwdata
6
6
  Author: LonxunQuantum
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
5
5
 
6
6
  setuptools.setup(
7
7
  name="pwdata",
8
- version="0.4.4",
8
+ version="0.4.5",
9
9
  author="LonxunQuantum",
10
10
  author_email="lonxun@pwmat.com",
11
11
  description="pwdata is a data pre-processing tool for PWMLFF, which can be used to extract features and labels. It also provides convenient interfaces for data conversion between different software.",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes