pwact 0.1.20__tar.gz → 0.1.21__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.
Files changed (64) hide show
  1. {pwact-0.1.20 → pwact-0.1.21}/PKG-INFO +1 -1
  2. {pwact-0.1.20 → pwact-0.1.21}/pwact/active_learning/explore/select_image.py +59 -17
  3. {pwact-0.1.20 → pwact-0.1.21}/pwact/active_learning/user_input/cmd_infos.py +9 -0
  4. {pwact-0.1.20 → pwact-0.1.21}/pwact/main.py +29 -2
  5. {pwact-0.1.20 → pwact-0.1.21}/pwact.egg-info/PKG-INFO +1 -1
  6. {pwact-0.1.20 → pwact-0.1.21}/setup.py +1 -1
  7. {pwact-0.1.20 → pwact-0.1.21}/LICENSE +0 -0
  8. {pwact-0.1.20 → pwact-0.1.21}/README.md +0 -0
  9. {pwact-0.1.20 → pwact-0.1.21}/pwact/__init__.py +0 -0
  10. {pwact-0.1.20 → pwact-0.1.21}/pwact/active_learning/__init__.py +0 -0
  11. {pwact-0.1.20 → pwact-0.1.21}/pwact/active_learning/environment.py +0 -0
  12. {pwact-0.1.20 → pwact-0.1.21}/pwact/active_learning/explore/__init__.py +0 -0
  13. {pwact-0.1.20 → pwact-0.1.21}/pwact/active_learning/explore/run_model_md.py +0 -0
  14. {pwact-0.1.20 → pwact-0.1.21}/pwact/active_learning/init_bulk/__init__.py +0 -0
  15. {pwact-0.1.20 → pwact-0.1.21}/pwact/active_learning/init_bulk/aimd.py +0 -0
  16. {pwact-0.1.20 → pwact-0.1.21}/pwact/active_learning/init_bulk/duplicate_scale.py +0 -0
  17. {pwact-0.1.20 → pwact-0.1.21}/pwact/active_learning/init_bulk/init_bulk_run.py +0 -0
  18. {pwact-0.1.20 → pwact-0.1.21}/pwact/active_learning/init_bulk/relabel.py +0 -0
  19. {pwact-0.1.20 → pwact-0.1.21}/pwact/active_learning/init_bulk/relax.py +0 -0
  20. {pwact-0.1.20 → pwact-0.1.21}/pwact/active_learning/label/__init__.py +0 -0
  21. {pwact-0.1.20 → pwact-0.1.21}/pwact/active_learning/label/labeling.py +0 -0
  22. {pwact-0.1.20 → pwact-0.1.21}/pwact/active_learning/slurm/__init__.py +0 -0
  23. {pwact-0.1.20 → pwact-0.1.21}/pwact/active_learning/slurm/slurm.py +0 -0
  24. {pwact-0.1.20 → pwact-0.1.21}/pwact/active_learning/slurm/slurm_tool.py +0 -0
  25. {pwact-0.1.20 → pwact-0.1.21}/pwact/active_learning/test/__init__.py +0 -0
  26. {pwact-0.1.20 → pwact-0.1.21}/pwact/active_learning/test/test.py +0 -0
  27. {pwact-0.1.20 → pwact-0.1.21}/pwact/active_learning/train/__init__.py +0 -0
  28. {pwact-0.1.20 → pwact-0.1.21}/pwact/active_learning/train/dp_kpu.py +0 -0
  29. {pwact-0.1.20 → pwact-0.1.21}/pwact/active_learning/train/train_model.py +0 -0
  30. {pwact-0.1.20 → pwact-0.1.21}/pwact/active_learning/user_input/__init__.py +0 -0
  31. {pwact-0.1.20 → pwact-0.1.21}/pwact/active_learning/user_input/init_bulk_input.py +0 -0
  32. {pwact-0.1.20 → pwact-0.1.21}/pwact/active_learning/user_input/iter_input.py +0 -0
  33. {pwact-0.1.20 → pwact-0.1.21}/pwact/active_learning/user_input/resource.py +0 -0
  34. {pwact-0.1.20 → pwact-0.1.21}/pwact/active_learning/user_input/scf_param.py +0 -0
  35. {pwact-0.1.20 → pwact-0.1.21}/pwact/active_learning/user_input/train_param/__init__.py +0 -0
  36. {pwact-0.1.20 → pwact-0.1.21}/pwact/active_learning/user_input/train_param/model_param.py +0 -0
  37. {pwact-0.1.20 → pwact-0.1.21}/pwact/active_learning/user_input/train_param/nep_param.py +0 -0
  38. {pwact-0.1.20 → pwact-0.1.21}/pwact/active_learning/user_input/train_param/nn_feature_type.py +0 -0
  39. {pwact-0.1.20 → pwact-0.1.21}/pwact/active_learning/user_input/train_param/optimizer_param.py +0 -0
  40. {pwact-0.1.20 → pwact-0.1.21}/pwact/active_learning/user_input/train_param/train_param.py +0 -0
  41. {pwact-0.1.20 → pwact-0.1.21}/pwact/active_learning/user_input/train_param/work_file_param.py +0 -0
  42. {pwact-0.1.20 → pwact-0.1.21}/pwact/active_learning/user_input/workdir.py +0 -0
  43. {pwact-0.1.20 → pwact-0.1.21}/pwact/bin/__init__.py +0 -0
  44. {pwact-0.1.20 → pwact-0.1.21}/pwact/data_format/__init__.py +0 -0
  45. {pwact-0.1.20 → pwact-0.1.21}/pwact/data_format/configop.py +0 -0
  46. {pwact-0.1.20 → pwact-0.1.21}/pwact/utils/__init__.py +0 -0
  47. {pwact-0.1.20 → pwact-0.1.21}/pwact/utils/app_lib/__init__.py +0 -0
  48. {pwact-0.1.20 → pwact-0.1.21}/pwact/utils/app_lib/common.py +0 -0
  49. {pwact-0.1.20 → pwact-0.1.21}/pwact/utils/app_lib/cp2k.py +0 -0
  50. {pwact-0.1.20 → pwact-0.1.21}/pwact/utils/app_lib/cp2k_dp.py +0 -0
  51. {pwact-0.1.20 → pwact-0.1.21}/pwact/utils/app_lib/lammps.py +0 -0
  52. {pwact-0.1.20 → pwact-0.1.21}/pwact/utils/app_lib/pwmat.py +0 -0
  53. {pwact-0.1.20 → pwact-0.1.21}/pwact/utils/constant.py +0 -0
  54. {pwact-0.1.20 → pwact-0.1.21}/pwact/utils/file_operation.py +0 -0
  55. {pwact-0.1.20 → pwact-0.1.21}/pwact/utils/format_input_output.py +0 -0
  56. {pwact-0.1.20 → pwact-0.1.21}/pwact/utils/json_operation.py +0 -0
  57. {pwact-0.1.20 → pwact-0.1.21}/pwact/utils/pre_al_data_util.py +0 -0
  58. {pwact-0.1.20 → pwact-0.1.21}/pwact/utils/process_tool.py +0 -0
  59. {pwact-0.1.20 → pwact-0.1.21}/pwact/utils/slurm_script.py +0 -0
  60. {pwact-0.1.20 → pwact-0.1.21}/pwact.egg-info/SOURCES.txt +0 -0
  61. {pwact-0.1.20 → pwact-0.1.21}/pwact.egg-info/dependency_links.txt +0 -0
  62. {pwact-0.1.20 → pwact-0.1.21}/pwact.egg-info/entry_points.txt +0 -0
  63. {pwact-0.1.20 → pwact-0.1.21}/pwact.egg-info/top_level.txt +0 -0
  64. {pwact-0.1.20 → pwact-0.1.21}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pwact
3
- Version: 0.1.20
3
+ Version: 0.1.21
4
4
  Summary: PWACT is an open-source automated active learning platform based on PWMLFF for efficient data sampling.
5
5
  Home-page: https://github.com/LonxunQuantum/PWact
6
6
  Author: LonxunQuantum
@@ -118,7 +118,51 @@ def select_image(
118
118
  print("Image select result:\n {}\n\n".format(summary_info))
119
119
  return summary
120
120
 
121
-
121
+ def print_select_image(
122
+ md_dir:str,
123
+ save_dir:str,
124
+ devi_name:str,
125
+ lower:float,
126
+ higer:float
127
+ ):
128
+ #1. get model_deviation file
129
+ model_deviation_patten = "{}/{}".format(get_sub_md_sys_template_name(), devi_name)
130
+ model_devi_files = search_files(md_dir, model_deviation_patten)
131
+ model_devi_files = sorted(model_devi_files)
132
+ md_sys_dict = sort_model_devi_files(model_devi_files)
133
+
134
+ error_pd =None
135
+ accurate_pd =None
136
+ rand_candi =None
137
+ remove_candi =None
138
+
139
+ for md in md_sys_dict.keys():
140
+ sys_dict = md_sys_dict[md]
141
+ for sys_idx, sys in enumerate(sys_dict.keys()):
142
+ devi_files = sys_dict[sys]
143
+ tmp_devi_pd, _base_kpu = read_pd_files(devi_files)
144
+ if len(_base_kpu) > 0: # for kpu upper and lower
145
+ _lower = np.mean(_base_kpu)*lower
146
+ _higer = _lower * higer
147
+ else:
148
+ _lower = lower
149
+ _higer = higer
150
+ tmp_error_pd, tmp_accurate_pd, tmp_rand_candi, tmp_remove_candi = select_pd(tmp_devi_pd, _lower, _higer, 10000000)
151
+ error_pd = pd.concat([error_pd, tmp_error_pd]) if error_pd is not None else tmp_error_pd
152
+ accurate_pd = pd.concat([accurate_pd, tmp_accurate_pd]) if error_pd is not None else tmp_accurate_pd
153
+ rand_candi = pd.concat([rand_candi, tmp_rand_candi]) if error_pd is not None else tmp_rand_candi
154
+ remove_candi = pd.concat([remove_candi, tmp_remove_candi]) if error_pd is not None else tmp_remove_candi
155
+ summary_info, summary = count_info(save_dir, error_pd, accurate_pd, rand_candi, remove_candi)
156
+
157
+ # summary_info, summary = select_image(save_dir=self.select_dir,
158
+ # devi_pd=devi_pd,
159
+ # lower=self.input_param.strategy.lower_model_deiv_f,
160
+ # higer=self.input_param.strategy.upper_model_deiv_f,
161
+ # max_select=self.input_param.strategy.max_select)
162
+ print("Image select result (lower {} upper {}):\n {}\n\n".format(lower, higer, summary_info))
163
+ return summary
164
+
165
+
122
166
  def select_pd(devi_pd:DataFrame, lower:float, higer:float, max_select:float):
123
167
  accurate_pd = devi_pd[devi_pd[EXPLORE_FILE_STRUCTURE.devi_columns[0]] < lower]
124
168
  candidate_pd = devi_pd[(devi_pd[EXPLORE_FILE_STRUCTURE.devi_columns[0]] >= lower) & (devi_pd[EXPLORE_FILE_STRUCTURE.devi_columns[0]] < higer)]
@@ -169,41 +213,39 @@ def read_pd_files(model_devi_files:list[str]):
169
213
 
170
214
  def count_info(save_dir, error_pd, accurate_pd, rand_candi, remove_candi):
171
215
  #5. save select info
172
- if not os.path.exists(save_dir):
173
- os.makedirs(save_dir)
174
216
  total_num = error_pd.shape[0] + accurate_pd.shape[0] + rand_candi.shape[0] + remove_candi.shape[0]
175
217
  cand_num = rand_candi.shape[0] + remove_candi.shape[0]
176
218
  summary = "Total structures {} accurate {} rate {:.2f}% selected {} rate {:.2f}% error {} rate {:.2f}%\n"\
177
219
  .format(total_num, accurate_pd.shape[0], accurate_pd.shape[0]/total_num*100, \
178
220
  cand_num, cand_num/total_num*100, \
179
221
  error_pd.shape[0], error_pd.shape[0]/total_num*100)
180
-
181
- accurate_pd.to_csv(os.path.join(save_dir, EXPLORE_FILE_STRUCTURE.accurate))
182
222
  candi_info = ""
183
- rand_candi.to_csv(os.path.join(save_dir, EXPLORE_FILE_STRUCTURE.candidate))
184
-
185
223
  if remove_candi.shape[0] == 0:
186
224
  candi_info += "Candidate configurations: {}\n Select details in file {}\n".format(
187
225
  cand_num, EXPLORE_FILE_STRUCTURE.candidate)
188
226
  else:
189
- remove_candi.to_csv(os.path.join(save_dir, EXPLORE_FILE_STRUCTURE.candidate_delete))
190
227
  candi_info += "Candidate configurations: {}, randomly select {}, delete {}\n Select details in file {}\n Delete details in file {}.\n".format(
191
228
  cand_num, rand_candi.shape[0], remove_candi.shape[0],\
192
229
  EXPLORE_FILE_STRUCTURE.candidate, EXPLORE_FILE_STRUCTURE.candidate_delete)
193
-
194
- error_pd.to_csv(os.path.join(save_dir, EXPLORE_FILE_STRUCTURE.failed))
195
-
196
230
  summary_info = ""
197
-
198
231
  summary_info += summary
199
232
  summary_info += "\nSelect by model deviation force:\n"
200
233
  summary_info += "Accurate configurations: {}, details in file {}\n".\
201
234
  format(accurate_pd.shape[0], EXPLORE_FILE_STRUCTURE.accurate)
202
-
203
235
  summary_info += candi_info
204
-
205
236
  summary_info += "Error configurations: {}, details in file {}\n".\
206
237
  format(error_pd.shape[0], EXPLORE_FILE_STRUCTURE.failed)
207
-
208
- write_to_file(os.path.join(save_dir, EXPLORE_FILE_STRUCTURE.select_summary), summary_info, "w")
209
- return summary_info, summary
238
+
239
+ if save_dir is not None:
240
+ if not os.path.exists(save_dir):
241
+ os.makedirs(save_dir)
242
+ accurate_pd.to_csv(os.path.join(save_dir, EXPLORE_FILE_STRUCTURE.accurate))
243
+ rand_candi.to_csv(os.path.join(save_dir, EXPLORE_FILE_STRUCTURE.candidate))
244
+ if remove_candi.shape[0] > 0:
245
+ remove_candi.to_csv(os.path.join(save_dir, EXPLORE_FILE_STRUCTURE.candidate_delete))
246
+ error_pd.to_csv(os.path.join(save_dir, EXPLORE_FILE_STRUCTURE.failed))
247
+ write_to_file(os.path.join(save_dir, EXPLORE_FILE_STRUCTURE.select_summary), summary_info, "w")
248
+
249
+ return summary_info, summary
250
+
251
+
@@ -39,6 +39,8 @@ def cmd_infos(cmd_type=None):
39
39
  cmd_info = cmd_info_run_iter()
40
40
  elif cmd_type == "kill":
41
41
  cmd_info = cmd_info_kill()
42
+ elif cmd_type == "filter":
43
+ cmd_info = cmd_info_filter()
42
44
  print(cmd_info)
43
45
 
44
46
 
@@ -64,3 +66,10 @@ def cmd_info_kill():
64
66
  cmd_info += "'pwact kill init_bulk' for 'init_bulk' tasks\n"
65
67
  cmd_info += "'pwact kill run' for 'run' tasks\n\n"
66
68
  return cmd_info
69
+
70
+ def cmd_info_filter():
71
+ cmd_info = ""
72
+ cmd_info += "filter" + "\n"
73
+ cmd_info += "you could use this method to test the selection results corresponding to the upper and lower limit settings\n"
74
+ cmd_info += "example:\n"
75
+ cmd_info += "'pwact filter -i iter.0000/explore/select -l 0.01 -h 0.02 -s filter_test_result'\n\n"
@@ -23,7 +23,7 @@ from pwact.active_learning.init_bulk.init_bulk_run import init_bulk_run, scancel
23
23
  from pwact.active_learning.environment import check_envs
24
24
 
25
25
  from pwact.data_format.configop import extract_pwdata
26
- from pwact.active_learning.explore.select_image import select_image
26
+ from pwact.active_learning.explore.select_image import select_image, print_select_image
27
27
  from pwact.utils.process_tool import kill_process
28
28
  def run_iter():
29
29
  system_json = json.load(open(sys.argv[2]))
@@ -299,6 +299,26 @@ def kill_job():
299
299
 
300
300
  # for run iters jobs
301
301
 
302
+ def filter_test(input_cmds):
303
+ parser = argparse.ArgumentParser()
304
+ parser.add_argument('-i', '--md_dir', help="specify input dir such as 'iter.0000/temp_run_iter_work/explore/md'", type=str, required=True)
305
+ parser.add_argument('-l', '--lower', help="specify lower limit value", type=float, required=True)
306
+ parser.add_argument('-u', '--upper', help="specify upper limit value", type=float, required=True)
307
+ parser.add_argument('-s', '--save', action='store_true', help="if '-s' is set, save the detailed information of the selected configs to CSV files")
308
+
309
+ args = parser.parse_args(input_cmds)
310
+ if not os.path.exists(args.md_dir):
311
+ raise Exception("ERROR! The input md_dir {} not found!".format(args.md_dir))
312
+
313
+ save_dir = os.path.join(os.getcwd(), "filter_test_result") if args.save else None
314
+ summary = print_select_image(
315
+ md_dir=args.md_dir,
316
+ save_dir=save_dir,
317
+ devi_name=EXPLORE_FILE_STRUCTURE.get_devi_name(UNCERTAINTY.committee),
318
+ lower=args.lower,
319
+ higer=args.upper
320
+ )
321
+
302
322
  def main():
303
323
  environment_check()
304
324
  if len(sys.argv) == 1 or "-h".upper() == sys.argv[1].upper() or \
@@ -343,7 +363,14 @@ def main():
343
363
  cmd_infos("kill")
344
364
  else:
345
365
  kill_job()
346
-
366
+
367
+ elif "filter_test".upper() == sys.argv[1].upper() or "filter".upper() == sys.argv[1].upper():
368
+ if len(sys.argv) == 2 or "-h".upper() == sys.argv[2].upper() or \
369
+ "help".upper() == sys.argv[2].upper() or "-help".upper() == sys.argv[2].upper() or "--help".upper() == sys.argv[2].upper():
370
+ cmd_infos("filter")
371
+ else:
372
+ filter_test(sys.argv[2:])
373
+
347
374
  else:
348
375
  print("ERROR! The input cmd {} can not be recognized, please check.".format(sys.argv[1]))
349
376
  print("\n\n\nYou can enter the following command.\n\n\n")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pwact
3
- Version: 0.1.20
3
+ Version: 0.1.21
4
4
  Summary: PWACT is an open-source automated active learning platform based on PWMLFF for efficient data sampling.
5
5
  Home-page: https://github.com/LonxunQuantum/PWact
6
6
  Author: LonxunQuantum
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
5
5
 
6
6
  setuptools.setup(
7
7
  name="pwact",
8
- version="0.1.20",
8
+ version="0.1.21",
9
9
  author="LonxunQuantum",
10
10
  author_email="lonxun@pwmat.com",
11
11
  description="PWACT is an open-source automated active learning platform based on PWMLFF for efficient data sampling.",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes