pyfemtet 0.9.4__py3-none-any.whl → 1.0.0a0__py3-none-any.whl

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 pyfemtet might be problematic. Click here for more details.

Files changed (272) hide show
  1. pyfemtet/__init__.py +6 -1
  2. pyfemtet/_i18n/1. make_pot_and_update_po.bat +8 -0
  3. pyfemtet/_i18n/2. build_mo.bat +5 -0
  4. pyfemtet/_i18n/__init__.py +4 -0
  5. pyfemtet/_i18n/babel.cfg +2 -0
  6. pyfemtet/_i18n/i18n.py +37 -0
  7. pyfemtet/_i18n/locales/ja/LC_MESSAGES/messages.mo +0 -0
  8. pyfemtet/_i18n/locales/ja/LC_MESSAGES/messages.po +1020 -0
  9. pyfemtet/_i18n/locales/messages.pot +987 -0
  10. pyfemtet/{_message → _i18n}/messages.py +128 -41
  11. pyfemtet/_util/closing.py +19 -0
  12. pyfemtet/_util/dask_util.py +89 -7
  13. pyfemtet/_util/df_util.py +29 -0
  14. pyfemtet/_util/excel_macro_util.py +8 -3
  15. pyfemtet/_util/excel_parse_util.py +43 -23
  16. pyfemtet/_util/femtet_access_inspection.py +120 -0
  17. pyfemtet/{_femtet_config_util/autosave.py → _util/femtet_autosave.py} +7 -0
  18. pyfemtet/_util/femtet_exit.py +105 -0
  19. pyfemtet/_util/femtet_version.py +20 -0
  20. pyfemtet/_util/helper.py +94 -0
  21. pyfemtet/_util/process_util.py +107 -0
  22. pyfemtet/_util/str_enum.py +44 -0
  23. pyfemtet/core.py +15 -47
  24. pyfemtet/dispatch_extensions/__init__.py +8 -11
  25. pyfemtet/dispatch_extensions/_impl.py +42 -198
  26. pyfemtet/logger/__init__.py +8 -1
  27. pyfemtet/logger/_impl.py +5 -6
  28. pyfemtet/opt/__init__.py +3 -19
  29. pyfemtet/opt/exceptions.py +45 -0
  30. pyfemtet/opt/femopt.py +602 -0
  31. pyfemtet/opt/history/__init__.py +11 -0
  32. pyfemtet/opt/history/_history.py +1404 -0
  33. pyfemtet/opt/history/_hypervolume.py +169 -0
  34. pyfemtet/opt/history/_optimality.py +79 -0
  35. pyfemtet/opt/interface/__init__.py +17 -24
  36. pyfemtet/opt/interface/_base_interface.py +222 -0
  37. pyfemtet/opt/interface/_excel_interface/__init__.py +3 -0
  38. pyfemtet/opt/interface/_excel_interface/debug-excel-interface.xlsm +0 -0
  39. pyfemtet/opt/interface/_excel_interface/excel_interface.py +999 -0
  40. pyfemtet/opt/interface/_femtet_interface/__init__.py +3 -0
  41. pyfemtet/opt/interface/{_femtet_parametric.py → _femtet_interface/_femtet_parametric.py} +20 -12
  42. pyfemtet/opt/interface/{_femtet.py → _femtet_interface/femtet_interface.py} +490 -348
  43. pyfemtet/opt/interface/_femtet_with_nx_interface/__init__.py +5 -0
  44. pyfemtet/opt/interface/_femtet_with_nx_interface/femtet_with_nx_interface.py +230 -0
  45. pyfemtet/opt/interface/_femtet_with_nx_interface/model1.prt +0 -0
  46. pyfemtet/opt/interface/_femtet_with_nx_interface/model1.x_t +98 -0
  47. pyfemtet/opt/interface/{_femtet_with_nx → _femtet_with_nx_interface}/update_model.py +1 -3
  48. pyfemtet/opt/interface/_femtet_with_solidworks/__init__.py +5 -0
  49. pyfemtet/opt/interface/_femtet_with_solidworks/femtet_with_solidworks_interface.py +122 -0
  50. pyfemtet/opt/interface/_solidworks_interface/__init__.py +5 -0
  51. pyfemtet/opt/interface/_solidworks_interface/solidworks_interface.py +206 -0
  52. pyfemtet/opt/interface/_surrogate/_base.py +0 -129
  53. pyfemtet/opt/interface/_surrogate_model_interface/__init__.py +8 -0
  54. pyfemtet/opt/interface/_surrogate_model_interface/base_surrogate_interface.py +59 -0
  55. pyfemtet/opt/interface/_surrogate_model_interface/botorch_interface.py +271 -0
  56. pyfemtet/opt/interface/_surrogate_model_interface/debug-pof-botorch.reccsv +18 -0
  57. pyfemtet/opt/interface/_with_excel_settings/__init__.py +61 -0
  58. pyfemtet/opt/interface/_with_excel_settings/with_excel_settings.py +134 -0
  59. pyfemtet/opt/meta_script/YAML_Generator.xlsm +0 -0
  60. pyfemtet/opt/meta_script/__main__.py +58 -36
  61. pyfemtet/opt/optimizer/__init__.py +7 -9
  62. pyfemtet/opt/optimizer/_base_optimizer.py +876 -0
  63. pyfemtet/opt/optimizer/optuna_optimizer/__init__.py +9 -0
  64. pyfemtet/opt/optimizer/optuna_optimizer/_optuna_attribute.py +73 -0
  65. pyfemtet/opt/optimizer/optuna_optimizer/_optuna_optimizer.py +678 -0
  66. pyfemtet/opt/optimizer/optuna_optimizer/_pof_botorch/__init__.py +7 -0
  67. pyfemtet/opt/optimizer/optuna_optimizer/_pof_botorch/debug-pof-botorch.reccsv +18 -0
  68. pyfemtet/opt/optimizer/optuna_optimizer/_pof_botorch/enable_nonlinear_constraint.py +244 -0
  69. pyfemtet/opt/optimizer/optuna_optimizer/_pof_botorch/pof_botorch_sampler.py +1249 -0
  70. pyfemtet/opt/optimizer/optuna_optimizer/wat_ex14_parametric_jp.femprj +0 -0
  71. pyfemtet/opt/optimizer/scipy_optimizer/__init__.py +1 -0
  72. pyfemtet/opt/optimizer/scipy_optimizer/_scipy_optimizer.py +364 -0
  73. pyfemtet/opt/prediction/__init__.py +7 -0
  74. pyfemtet/opt/prediction/_botorch_utils.py +133 -0
  75. pyfemtet/opt/prediction/_gpytorch_modules_extension.py +142 -0
  76. pyfemtet/opt/prediction/_helper.py +155 -0
  77. pyfemtet/opt/prediction/_model.py +118 -0
  78. pyfemtet/opt/problem/problem.py +304 -0
  79. pyfemtet/opt/problem/variable_manager/__init__.py +20 -0
  80. pyfemtet/opt/problem/variable_manager/_string_as_expression.py +115 -0
  81. pyfemtet/opt/problem/variable_manager/_variable_manager.py +295 -0
  82. pyfemtet/opt/visualization/history_viewer/__main__.py +5 -0
  83. pyfemtet/opt/visualization/{_base.py → history_viewer/_base_application.py} +18 -13
  84. pyfemtet/opt/visualization/history_viewer/_common_pages.py +150 -0
  85. pyfemtet/opt/visualization/{_complex_components → history_viewer/_complex_components}/alert_region.py +10 -5
  86. pyfemtet/opt/visualization/{_complex_components → history_viewer/_complex_components}/control_femtet.py +16 -13
  87. pyfemtet/opt/visualization/{_complex_components → history_viewer/_complex_components}/main_graph.py +117 -47
  88. pyfemtet/opt/visualization/{_complex_components → history_viewer/_complex_components}/pm_graph.py +159 -138
  89. pyfemtet/opt/visualization/history_viewer/_process_monitor/_application.py +173 -0
  90. pyfemtet/opt/visualization/history_viewer/_process_monitor/_pages.py +291 -0
  91. pyfemtet/opt/visualization/{_wrapped_components → history_viewer/_wrapped_components}/dbc.py +1 -1
  92. pyfemtet/opt/visualization/{_wrapped_components → history_viewer/_wrapped_components}/dcc.py +1 -1
  93. pyfemtet/opt/visualization/{_wrapped_components → history_viewer/_wrapped_components}/html.py +1 -1
  94. pyfemtet/opt/visualization/history_viewer/result_viewer/__main__.py +5 -0
  95. pyfemtet/opt/visualization/{result_viewer/application.py → history_viewer/result_viewer/_application.py} +6 -6
  96. pyfemtet/opt/visualization/{result_viewer/pages.py → history_viewer/result_viewer/_pages.py} +106 -82
  97. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08.csv +18 -0
  98. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08.db +0 -0
  99. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8.jpg +0 -0
  100. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8.log +45 -0
  101. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8.pdt +0 -0
  102. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_1.jpg +0 -0
  103. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_1.pdt +0 -0
  104. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_10.jpg +0 -0
  105. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_10.pdt +0 -0
  106. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_11.jpg +0 -0
  107. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_11.pdt +0 -0
  108. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_12.jpg +0 -0
  109. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_12.pdt +0 -0
  110. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_13.jpg +0 -0
  111. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_13.pdt +0 -0
  112. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_14.jpg +0 -0
  113. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_14.pdt +0 -0
  114. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_15.jpg +0 -0
  115. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_15.pdt +0 -0
  116. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_16.jpg +0 -0
  117. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_16.pdt +0 -0
  118. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_17.jpg +0 -0
  119. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_17.pdt +0 -0
  120. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_18.jpg +0 -0
  121. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_18.pdt +0 -0
  122. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_19.jpg +0 -0
  123. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_19.pdt +0 -0
  124. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_2.jpg +0 -0
  125. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_2.pdt +0 -0
  126. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_20.jpg +0 -0
  127. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_20.pdt +0 -0
  128. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_3.jpg +0 -0
  129. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_3.pdt +0 -0
  130. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_4.bgr +0 -0
  131. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_4.bnd +0 -0
  132. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_4.btr +0 -0
  133. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_4.jpg +0 -0
  134. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_4.mtl +0 -0
  135. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_4.pdt +0 -0
  136. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_4.prm +0 -0
  137. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_5.jpg +0 -0
  138. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_5.pdt +0 -0
  139. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_6.jpg +0 -0
  140. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_6.pdt +0 -0
  141. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_7.jpg +0 -0
  142. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_7.pdt +0 -0
  143. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_8.jpg +0 -0
  144. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_8.pdt +0 -0
  145. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_9.jpg +0 -0
  146. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_9.pdt +0 -0
  147. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.femprj +0 -0
  148. pyfemtet/opt/visualization/plotter/main_figure_creator.py +536 -0
  149. pyfemtet/opt/visualization/plotter/pm_graph_creator.py +359 -0
  150. pyfemtet/opt/worker_status.py +120 -0
  151. {pyfemtet-0.9.4.dist-info → pyfemtet-1.0.0a0.dist-info}/METADATA +22 -24
  152. pyfemtet-1.0.0a0.dist-info/RECORD +173 -0
  153. pyfemtet-1.0.0a0.dist-info/entry_points.txt +3 -0
  154. pyfemtet/_femtet_config_util/exit.py +0 -59
  155. pyfemtet/_message/1. make_pot.bat +0 -11
  156. pyfemtet/_message/2. make_mo.bat +0 -6
  157. pyfemtet/_message/__init__.py +0 -5
  158. pyfemtet/_message/babel.cfg +0 -2
  159. pyfemtet/_message/locales/ja/LC_MESSAGES/messages.mo +0 -0
  160. pyfemtet/_message/locales/ja/LC_MESSAGES/messages.po +0 -570
  161. pyfemtet/_message/locales/messages.pot +0 -551
  162. pyfemtet/_warning.py +0 -87
  163. pyfemtet/brep/_impl.py +0 -18
  164. pyfemtet/opt/_femopt.py +0 -1007
  165. pyfemtet/opt/_femopt_core.py +0 -1169
  166. pyfemtet/opt/_test_utils/control_femtet.py +0 -39
  167. pyfemtet/opt/_test_utils/hyper_sphere.py +0 -24
  168. pyfemtet/opt/_test_utils/record_history.py +0 -130
  169. pyfemtet/opt/advanced_samples/excel_ui/(ref) original_project.femprj +0 -0
  170. pyfemtet/opt/advanced_samples/excel_ui/femtet-macro.xlsm +0 -0
  171. pyfemtet/opt/advanced_samples/excel_ui/pyfemtet-core.py +0 -291
  172. pyfemtet/opt/advanced_samples/excel_ui/test-pyfemtet-core.cmd +0 -22
  173. pyfemtet/opt/advanced_samples/restart/gal_ex13_parametric.femprj +0 -0
  174. pyfemtet/opt/advanced_samples/restart/gal_ex13_parametric_restart.py +0 -99
  175. pyfemtet/opt/advanced_samples/restart/gal_ex13_parametric_restart_jp.py +0 -102
  176. pyfemtet/opt/advanced_samples/surrogate_model/gal_ex13_create_training_data.py +0 -60
  177. pyfemtet/opt/advanced_samples/surrogate_model/gal_ex13_create_training_data_jp.py +0 -57
  178. pyfemtet/opt/advanced_samples/surrogate_model/gal_ex13_optimize_with_surrogate.py +0 -100
  179. pyfemtet/opt/advanced_samples/surrogate_model/gal_ex13_optimize_with_surrogate_jp.py +0 -90
  180. pyfemtet/opt/advanced_samples/surrogate_model/gal_ex13_parametric.femprj +0 -0
  181. pyfemtet/opt/interface/_base.py +0 -101
  182. pyfemtet/opt/interface/_excel_interface.py +0 -984
  183. pyfemtet/opt/interface/_femtet_excel.py +0 -141
  184. pyfemtet/opt/interface/_femtet_with_nx/__init__.py +0 -3
  185. pyfemtet/opt/interface/_femtet_with_nx/_interface.py +0 -178
  186. pyfemtet/opt/interface/_femtet_with_sldworks.py +0 -298
  187. pyfemtet/opt/interface/_surrogate/__init__.py +0 -5
  188. pyfemtet/opt/interface/_surrogate/_chaospy.py +0 -71
  189. pyfemtet/opt/interface/_surrogate/_singletaskgp.py +0 -71
  190. pyfemtet/opt/interface/_surrogate_excel.py +0 -102
  191. pyfemtet/opt/optimizer/_base.py +0 -376
  192. pyfemtet/opt/optimizer/_optuna/_botorch_patch/enable_nonlinear_constraint.py +0 -220
  193. pyfemtet/opt/optimizer/_optuna/_optuna.py +0 -434
  194. pyfemtet/opt/optimizer/_optuna/_pof_botorch.py +0 -1914
  195. pyfemtet/opt/optimizer/_scipy.py +0 -159
  196. pyfemtet/opt/optimizer/_scipy_scalar.py +0 -127
  197. pyfemtet/opt/optimizer/parameter.py +0 -113
  198. pyfemtet/opt/prediction/_base.py +0 -61
  199. pyfemtet/opt/prediction/single_task_gp.py +0 -119
  200. pyfemtet/opt/samples/femprj_sample/ParametricIF.femprj +0 -0
  201. pyfemtet/opt/samples/femprj_sample/ParametricIF.py +0 -29
  202. pyfemtet/opt/samples/femprj_sample/ParametricIF_test_result.reccsv +0 -13
  203. pyfemtet/opt/samples/femprj_sample/cad_ex01_NX.femprj +0 -0
  204. pyfemtet/opt/samples/femprj_sample/cad_ex01_NX.prt +0 -0
  205. pyfemtet/opt/samples/femprj_sample/cad_ex01_NX.py +0 -135
  206. pyfemtet/opt/samples/femprj_sample/cad_ex01_NX_test_result.reccsv +0 -23
  207. pyfemtet/opt/samples/femprj_sample/cad_ex01_SW.SLDPRT +0 -0
  208. pyfemtet/opt/samples/femprj_sample/cad_ex01_SW.femprj +0 -0
  209. pyfemtet/opt/samples/femprj_sample/cad_ex01_SW.py +0 -131
  210. pyfemtet/opt/samples/femprj_sample/cad_ex01_SW_test_result.reccsv +0 -23
  211. pyfemtet/opt/samples/femprj_sample/constrained_pipe.femprj +0 -0
  212. pyfemtet/opt/samples/femprj_sample/constrained_pipe.py +0 -96
  213. pyfemtet/opt/samples/femprj_sample/constrained_pipe_test_result.reccsv +0 -13
  214. pyfemtet/opt/samples/femprj_sample/gal_ex58_parametric.femprj +0 -0
  215. pyfemtet/opt/samples/femprj_sample/gal_ex58_parametric.py +0 -74
  216. pyfemtet/opt/samples/femprj_sample/gal_ex58_parametric_test_result.reccsv +0 -13
  217. pyfemtet/opt/samples/femprj_sample/gau_ex08_parametric.femprj +0 -0
  218. pyfemtet/opt/samples/femprj_sample/gau_ex08_parametric.py +0 -58
  219. pyfemtet/opt/samples/femprj_sample/gau_ex08_parametric_test_result.reccsv +0 -23
  220. pyfemtet/opt/samples/femprj_sample/gau_ex12_parametric.femprj +0 -0
  221. pyfemtet/opt/samples/femprj_sample/gau_ex12_parametric.py +0 -52
  222. pyfemtet/opt/samples/femprj_sample/her_ex40_parametric.femprj +0 -0
  223. pyfemtet/opt/samples/femprj_sample/her_ex40_parametric.py +0 -138
  224. pyfemtet/opt/samples/femprj_sample/her_ex40_parametric_test_result.reccsv +0 -18
  225. pyfemtet/opt/samples/femprj_sample/paswat_ex1_parametric.femprj +0 -0
  226. pyfemtet/opt/samples/femprj_sample/paswat_ex1_parametric.py +0 -60
  227. pyfemtet/opt/samples/femprj_sample/paswat_ex1_parametric_parallel.py +0 -61
  228. pyfemtet/opt/samples/femprj_sample/paswat_ex1_parametric_test_result.reccsv +0 -18
  229. pyfemtet/opt/samples/femprj_sample/wat_ex14_parametric.femprj +0 -0
  230. pyfemtet/opt/samples/femprj_sample/wat_ex14_parametric.py +0 -58
  231. pyfemtet/opt/samples/femprj_sample/wat_ex14_parametric_parallel.py +0 -58
  232. pyfemtet/opt/samples/femprj_sample/wat_ex14_parametric_test_result.reccsv +0 -18
  233. pyfemtet/opt/samples/femprj_sample_jp/ParametricIF_jp.femprj +0 -0
  234. pyfemtet/opt/samples/femprj_sample_jp/ParametricIF_jp.py +0 -29
  235. pyfemtet/opt/samples/femprj_sample_jp/cad_ex01_NX_jp.femprj +0 -0
  236. pyfemtet/opt/samples/femprj_sample_jp/cad_ex01_NX_jp.py +0 -129
  237. pyfemtet/opt/samples/femprj_sample_jp/cad_ex01_SW_jp.femprj +0 -0
  238. pyfemtet/opt/samples/femprj_sample_jp/cad_ex01_SW_jp.py +0 -125
  239. pyfemtet/opt/samples/femprj_sample_jp/constrained_pipe_jp.py +0 -93
  240. pyfemtet/opt/samples/femprj_sample_jp/gal_ex58_parametric_jp.femprj +0 -0
  241. pyfemtet/opt/samples/femprj_sample_jp/gal_ex58_parametric_jp.py +0 -70
  242. pyfemtet/opt/samples/femprj_sample_jp/gau_ex08_parametric_jp.femprj +0 -0
  243. pyfemtet/opt/samples/femprj_sample_jp/gau_ex08_parametric_jp.py +0 -57
  244. pyfemtet/opt/samples/femprj_sample_jp/gau_ex12_parametric_jp.py +0 -52
  245. pyfemtet/opt/samples/femprj_sample_jp/her_ex40_parametric_jp.femprj +0 -0
  246. pyfemtet/opt/samples/femprj_sample_jp/her_ex40_parametric_jp.py +0 -138
  247. pyfemtet/opt/samples/femprj_sample_jp/paswat_ex1_parametric_jp.femprj +0 -0
  248. pyfemtet/opt/samples/femprj_sample_jp/paswat_ex1_parametric_jp.py +0 -58
  249. pyfemtet/opt/samples/femprj_sample_jp/paswat_ex1_parametric_parallel_jp.py +0 -59
  250. pyfemtet/opt/samples/femprj_sample_jp/wat_ex14_parametric_jp.py +0 -56
  251. pyfemtet/opt/samples/femprj_sample_jp/wat_ex14_parametric_parallel_jp.py +0 -56
  252. pyfemtet/opt/visualization/_complex_components/main_figure_creator.py +0 -332
  253. pyfemtet/opt/visualization/_complex_components/pm_graph_creator.py +0 -201
  254. pyfemtet/opt/visualization/_process_monitor/application.py +0 -226
  255. pyfemtet/opt/visualization/_process_monitor/pages.py +0 -406
  256. pyfemtet/opt/visualization/_wrapped_components/__init__.py +0 -0
  257. pyfemtet/opt/visualization/result_viewer/__init__.py +0 -0
  258. pyfemtet-0.9.4.dist-info/RECORD +0 -158
  259. pyfemtet-0.9.4.dist-info/entry_points.txt +0 -3
  260. /pyfemtet/{_femtet_config_util → opt/problem}/__init__.py +0 -0
  261. /pyfemtet/{brep → opt/visualization/history_viewer}/__init__.py +0 -0
  262. /pyfemtet/opt/{_test_utils → visualization/history_viewer/_complex_components}/__init__.py +0 -0
  263. /pyfemtet/opt/{optimizer/_optuna → visualization/history_viewer/_process_monitor}/__init__.py +0 -0
  264. /pyfemtet/opt/{optimizer/_optuna/_botorch_patch → visualization/history_viewer/_wrapped_components}/__init__.py +0 -0
  265. /pyfemtet/opt/visualization/{_wrapped_components → history_viewer/_wrapped_components}/str_enum.py +0 -0
  266. /pyfemtet/opt/visualization/{result_viewer → history_viewer/result_viewer}/.gitignore +0 -0
  267. /pyfemtet/opt/visualization/{_complex_components → history_viewer/result_viewer}/__init__.py +0 -0
  268. /pyfemtet/opt/visualization/{_process_monitor → plotter}/__init__.py +0 -0
  269. /pyfemtet/opt/{samples/femprj_sample_jp/wat_ex14_parametric_jp.femprj → wat_ex14_parametric_jp.femprj} +0 -0
  270. {pyfemtet-0.9.4.dist-info → pyfemtet-1.0.0a0.dist-info}/LICENSE +0 -0
  271. {pyfemtet-0.9.4.dist-info → pyfemtet-1.0.0a0.dist-info}/LICENSE_THIRD_PARTY.txt +0 -0
  272. {pyfemtet-0.9.4.dist-info → pyfemtet-1.0.0a0.dist-info}/WHEEL +0 -0
@@ -0,0 +1,291 @@
1
+ from __future__ import annotations
2
+ from typing import TYPE_CHECKING
3
+
4
+ import numpy as np
5
+ import pandas as pd
6
+
7
+ from dash import Output, Input, State, callback_context, no_update, ALL
8
+ from dash.exceptions import PreventUpdate
9
+
10
+ from pyfemtet.opt.visualization.history_viewer._wrapped_components import html, dcc, dbc
11
+ from pyfemtet.opt.visualization.history_viewer._base_application import *
12
+ from pyfemtet.opt.visualization.history_viewer._complex_components.main_graph import *
13
+
14
+ from pyfemtet.opt.worker_status import *
15
+ from pyfemtet._i18n import Msg, _
16
+
17
+ if TYPE_CHECKING:
18
+ from pyfemtet.opt.visualization.history_viewer._process_monitor._application import ProcessMonitorApplication
19
+
20
+
21
+ __all__ = [
22
+ 'HomePage',
23
+ 'WorkerPage',
24
+ ]
25
+
26
+
27
+ DBC_COLUMN_STYLE_CENTER = {
28
+ 'display': 'flex',
29
+ 'justify-content': 'center',
30
+ 'align-items': 'center',
31
+ }
32
+
33
+ DBC_COLUMN_STYLE_RIGHT = {
34
+ 'display': 'flex',
35
+ 'justify-content': 'right',
36
+ 'align-items': 'right',
37
+ }
38
+
39
+
40
+ class HomePage(AbstractPage):
41
+ application: ProcessMonitorApplication
42
+
43
+ def __init__(self, title, rel_url, application: ProcessMonitorApplication):
44
+ super().__init__(title, rel_url, application)
45
+
46
+ def setup_component(self):
47
+ # main graph
48
+ # noinspection PyAttributeOutsideInit
49
+ self.main_graph: MainGraph = MainGraph()
50
+ self.add_subpage(self.main_graph)
51
+
52
+ # entire optimization status
53
+ # noinspection PyAttributeOutsideInit
54
+ self.entire_status_message = html.H4(
55
+ Msg.DEFAULT_STATUS_ALERT,
56
+ className='alert-heading',
57
+ id='optimization-entire-status-message',
58
+ )
59
+ # noinspection PyAttributeOutsideInit
60
+ self.entire_status = dbc.Alert(
61
+ children=self.entire_status_message,
62
+ id='optimization-entire-status',
63
+ color='secondary',
64
+ )
65
+
66
+ # keep axis range
67
+ button_label = _(
68
+ en_message='Keep {y_or_xy} ranges',
69
+ jp_message='{y_or_xy} 範囲を維持',
70
+ y_or_xy='Y' if len(self.application.history.obj_names) == 1 else 'XY'
71
+ )
72
+ # noinspection PyAttributeOutsideInit
73
+ self.toggle_keep_graph_range_button = dbc.Checkbox(
74
+ label=button_label,
75
+ class_name='form-switch',
76
+ id='toggle-keep-range',
77
+ value=False,
78
+ )
79
+
80
+ # interrupt button
81
+ # noinspection PyAttributeOutsideInit
82
+ self.interrupt_button = dbc.Button(
83
+ children=Msg.LABEL_INTERRUPT,
84
+ color='danger',
85
+ id='interrupt-optimization-button',
86
+ disabled=True,
87
+ )
88
+
89
+ # sync interval
90
+ # noinspection PyAttributeOutsideInit
91
+ self.interval = dcc.Interval(id='process-monitor-home-interval', interval=3000)
92
+
93
+ def setup_layout(self):
94
+ """"""
95
+ """
96
+ =======================
97
+ | | ---------------- |
98
+ | | | | |
99
+ | | | Main Graph | |
100
+ | | | | |
101
+ | | ---------------- |
102
+ | | [stop][interrupt]<---- Buttons
103
+ | | ---------------- |
104
+ | | | Status | |
105
+ | ^| ---------------- |
106
+ ==|====================
107
+ |
108
+ SideBar
109
+ """
110
+ self.layout = dbc.Container(
111
+ children=[
112
+ self.interval,
113
+ self.main_graph.layout,
114
+ self.entire_status,
115
+ dbc.Row(
116
+ children=[
117
+ dbc.Col(self.toggle_keep_graph_range_button),
118
+ dbc.Col(self.interrupt_button, style=DBC_COLUMN_STYLE_RIGHT),
119
+ ],
120
+ ),
121
+ ]
122
+ )
123
+
124
+ def setup_callback(self):
125
+ # setup callback of subpages
126
+ super().setup_callback()
127
+
128
+ app = self.application.app
129
+
130
+ # ===== Delete Loading Animation =====
131
+ @app.callback(
132
+ Output(self.main_graph.loading.id, self.main_graph.loading.Prop.target_components),
133
+ Input(self.main_graph.graph.id, 'figure'),
134
+ prevent_initial_call=True,
135
+ )
136
+ def disable_loading_animation(_):
137
+ return {}
138
+
139
+ # ===== history data to graph ======
140
+ @app.callback(
141
+ Output(self.main_graph.callback_chain_key.id, self.main_graph.callback_chain_arg_keep_range, allow_duplicate=True), # fire update graph callback
142
+ Input(self.interval.id, self.interval.Prop.n_intervals),
143
+ State(self.toggle_keep_graph_range_button.id, self.toggle_keep_graph_range_button.Prop.value),
144
+ State(self.main_graph.data_length.id, self.main_graph.data_length_prop), # check should update or not
145
+ prevent_initial_call=True,)
146
+ def update_graph(_, keep_range, current_graph_data_length):
147
+ current_graph_data_length = 0 if current_graph_data_length is None else current_graph_data_length
148
+
149
+ if callback_context.triggered_id is None:
150
+ raise PreventUpdate
151
+
152
+ # If new data does not exist, do nothing
153
+ if len(self.application.get_df()) <= current_graph_data_length:
154
+ raise PreventUpdate
155
+
156
+ # fire callback
157
+ return keep_range
158
+
159
+ # ===== show optimization state =====
160
+ @app.callback(
161
+ Output(self.entire_status.id, self.entire_status.Prop.color),
162
+ Output(self.entire_status_message.id, 'children'),
163
+ Input(self.interval.id, self.interval.Prop.n_intervals),
164
+ prevent_initial_call=False,)
165
+ def update_entire_status(*_):
166
+ # get status message
167
+ msg = str(self.application.entire_status.value)
168
+ color = self.application.get_status_color(self.application.entire_status)
169
+ return color, msg
170
+
171
+ # ===== Interrupt Optimization and Control Button Disabled =====
172
+ @app.callback(
173
+ Output(self.interrupt_button.id, self.interrupt_button.Prop.disabled),
174
+ Input(self.interrupt_button.id, self.interrupt_button.Prop.n_clicks),
175
+ prevent_initial_call=False,)
176
+ def interrupt_optimization(*_):
177
+ # If page (re)loaded,
178
+ if callback_context.triggered_id is None:
179
+ # Enable only if the entire_state < INTERRUPTING
180
+ if self.application.entire_status.value < WorkerStatus.interrupting:
181
+ return False
182
+ # Keep disable(default) if process is interrupting or terminating.
183
+ else:
184
+ raise PreventUpdate
185
+
186
+ # If the entire_state < INTERRUPTING, set INTERRUPTING
187
+ if self.application.entire_status.value < WorkerStatus.interrupting:
188
+ self.application.entire_status.value = WorkerStatus.interrupting
189
+ return True
190
+
191
+ # keep disabled
192
+ raise PreventUpdate
193
+
194
+ # ===== TEST CODE =====
195
+ if self.application.is_debug:
196
+
197
+ # # increment status
198
+ # self.layout.children.append(dbc.Button(children='local_status を進める', id='debug-button-1'))
199
+ #
200
+ # @app.callback(Output(self.interval.id, self.interval.Prop.interval),
201
+ # Input('debug-button-1', 'n_clicks'),
202
+ # prevent_initial_call=True)
203
+ # def status_change(*_):
204
+ # self.application.entire_status += 10
205
+ # for i in range(len(self.application.worker_status_list)):
206
+ # self.application.worker_status_list[i] += 10
207
+ # raise PreventUpdate
208
+
209
+ # increment data
210
+ self.layout.children.append(dbc.Button(children='local_data を増やす', id='debug-button-2'))
211
+
212
+ @app.callback(Output(self.interval.id, self.interval.Prop.interval, allow_duplicate=True),
213
+ Input('debug-button-2', 'n_clicks'),
214
+ prevent_initial_call=True)
215
+ def add_data(*_):
216
+ meta_columns = self.application.history._records.column_manager.meta_columns
217
+ df = self.application.local_data
218
+
219
+ new_row = df.iloc[-2:]
220
+ obj_index = np.where(np.array(meta_columns) == 'obj')[0]
221
+ for idx in obj_index:
222
+ new_row.iloc[:, idx] = np.random.rand(len(new_row))
223
+
224
+ df = pd.concat([df, new_row])
225
+ df.trial = np.array(range(len(df)))
226
+ logger.debug(df)
227
+
228
+ self.application.local_data = df
229
+
230
+ raise PreventUpdate
231
+
232
+
233
+ class WorkerPage(AbstractPage):
234
+ application: ProcessMonitorApplication
235
+
236
+ def __init__(self, title, rel_url, application):
237
+ super().__init__(title, rel_url, application)
238
+
239
+ def setup_component(self):
240
+ # noinspection PyAttributeOutsideInit
241
+ self.interval = dcc.Interval(id='worker-page-interval', interval=1000)
242
+
243
+ # noinspection PyAttributeOutsideInit
244
+ self.worker_status_alerts = []
245
+ for i in range(len(self.application.worker_names)):
246
+ id_worker_alert = f'worker-status-alert-{i}'
247
+ alert = dbc.Alert('worker status here', id=id_worker_alert, color='dark')
248
+ self.worker_status_alerts.append(alert)
249
+
250
+ def setup_layout(self):
251
+ rows = [self.interval]
252
+ rows.extend(
253
+ [dbc.Row([dbc.Col(html.Div(dcc.Loading(alert, id={"type": "loading", "index": i})))])
254
+ for i, alert in enumerate(self.worker_status_alerts)])
255
+
256
+ self.layout = dbc.Container(
257
+ children=rows,
258
+ fluid=True,
259
+ )
260
+
261
+ def setup_callback(self):
262
+ app = self.application.app
263
+
264
+ @app.callback(
265
+ [Output(alert.id, 'children') for alert in self.worker_status_alerts],
266
+ [Output(alert.id, 'color') for alert in self.worker_status_alerts],
267
+ Output({"type": "loading", "index": ALL}, "target_components"),
268
+ Input(self.interval.id, 'n_intervals'),
269
+ )
270
+ def update_worker_state(_):
271
+
272
+ ret = []
273
+
274
+ for worker_name, worker_address, worker_status in (
275
+ zip(
276
+ self.application.worker_names,
277
+ self.application.worker_addresses,
278
+ self.application.worker_status_list,
279
+ )):
280
+ worker_status_message = worker_status.value.str()
281
+ ret.append(f'{worker_name} ({worker_address}) is '
282
+ f'{worker_status_message}')
283
+
284
+ ret.extend(
285
+ [self.application.get_status_color(worker_status)
286
+ for worker_status in self.application.worker_status_list])
287
+ ret.append(
288
+ [({} if callback_context.triggered_id is None else no_update)
289
+ for _ in range(len(self.worker_status_alerts))])
290
+
291
+ return tuple(ret)
@@ -1,5 +1,5 @@
1
1
  # auto created module
2
- from pyfemtet.opt.visualization._wrapped_components.str_enum import StrEnum
2
+ from pyfemtet._util.str_enum import StrEnum
3
3
  # from enum import StrEnum
4
4
  import dash
5
5
  import dash_bootstrap_components
@@ -1,5 +1,5 @@
1
1
  # auto created module
2
- from pyfemtet.opt.visualization._wrapped_components.str_enum import StrEnum
2
+ from pyfemtet._util.str_enum import StrEnum
3
3
  # from enum import StrEnum
4
4
  import dash
5
5
  import dash_bootstrap_components
@@ -1,5 +1,5 @@
1
1
  # auto created module
2
- from pyfemtet.opt.visualization._wrapped_components.str_enum import StrEnum
2
+ from pyfemtet._util.str_enum import StrEnum
3
3
  # from enum import StrEnum
4
4
  import dash
5
5
  import dash_bootstrap_components
@@ -0,0 +1,5 @@
1
+ from pyfemtet.opt.visualization.history_viewer.result_viewer._application import result_viewer_main
2
+
3
+
4
+ if __name__ == '__main__':
5
+ result_viewer_main()
@@ -1,8 +1,8 @@
1
- from pyfemtet.opt.visualization._base import PyFemtetApplicationBase
2
- from pyfemtet.opt.visualization.result_viewer.pages import HomePage, PredictionModelPage
3
- from pyfemtet.opt.visualization._process_monitor.pages import OptunaVisualizerPage
1
+ from pyfemtet.opt.visualization.history_viewer._base_application import *
2
+ from pyfemtet.opt.visualization.history_viewer._common_pages import *
3
+ from pyfemtet.opt.visualization.history_viewer.result_viewer._pages import *
4
4
 
5
- from pyfemtet._message import Msg
5
+ from pyfemtet._i18n import Msg
6
6
 
7
7
 
8
8
  class ResultViewerApplication(PyFemtetApplicationBase):
@@ -36,7 +36,7 @@ def _debug():
36
36
  g_application.run(debug=True)
37
37
 
38
38
 
39
- def main():
39
+ def result_viewer_main():
40
40
  g_application = ResultViewerApplication()
41
41
 
42
42
  g_home_page = HomePage(Msg.PAGE_TITLE_RESULT)
@@ -52,4 +52,4 @@ def main():
52
52
 
53
53
 
54
54
  if __name__ == '__main__':
55
- main()
55
+ result_viewer_main()
@@ -1,26 +1,28 @@
1
- import json
2
1
  import os
3
2
  import tempfile
4
3
  import base64
5
-
6
- import numpy as np
7
- import pandas as pd
8
- import shutil
4
+ from traceback import print_exception
9
5
 
10
6
  from dash import Output, Input, State, callback_context, no_update
11
7
  from dash.exceptions import PreventUpdate
12
8
 
13
- from pyfemtet.opt.visualization._wrapped_components import dcc, dbc, html
14
- from pyfemtet.opt.visualization._base import AbstractPage # , logger
15
- from pyfemtet.opt.visualization._complex_components.main_graph import MainGraph # , FLEXBOX_STYLE_ALLOW_VERTICAL_FILL
16
- from pyfemtet.opt.visualization._complex_components.control_femtet import FemtetControl, FemtetState
17
- from pyfemtet.opt.visualization._complex_components.alert_region import AlertRegion
18
- from pyfemtet.opt.visualization._complex_components.pm_graph import PredictionModelGraph
9
+ from pyfemtet.opt.history import History
10
+
11
+ from pyfemtet.opt.visualization.history_viewer._wrapped_components import dcc, dbc, html
12
+ from pyfemtet.opt.visualization.history_viewer._base_application import *
13
+ from pyfemtet.opt.visualization.history_viewer._complex_components.main_graph import *
14
+ from pyfemtet.opt.visualization.history_viewer._complex_components.control_femtet import *
15
+ from pyfemtet.opt.visualization.history_viewer._complex_components.alert_region import *
16
+
17
+ from pyfemtet._i18n import Msg, _
18
+
19
19
 
20
- from pyfemtet.opt._femopt_core import History
20
+ __all__ = [
21
+ 'HomePage'
22
+ ]
21
23
 
22
- from pyfemtet._message import Msg
23
24
 
25
+ # TODO: テスト
24
26
 
25
27
  class HomePage(AbstractPage):
26
28
 
@@ -127,7 +129,6 @@ class HomePage(AbstractPage):
127
129
  @app.callback(
128
130
  Output(self.file_picker_button.id, self.file_picker_button.Prop.children),
129
131
  Output(self.main_graph.tabs.id, self.main_graph.tabs.Prop.active_tab, allow_duplicate=False),
130
- # Output(self.femtet_control.connect_femtet_button.id, self.femtet_control.connect_femtet_button.Prop.n_clicks), # automatically connect to femtet is now deprecated because use view-only without femtet license
131
132
  Input(self.file_picker.id, self.file_picker.Prop.contents),
132
133
  State(self.file_picker.id, self.file_picker.Prop.filename),
133
134
  State(self.main_graph.tabs.id, self.main_graph.tabs.Prop.active_tab),
@@ -154,7 +155,8 @@ class HomePage(AbstractPage):
154
155
  csv_path = os.path.join(tmp_dir_path, file_name)
155
156
  with open(csv_path, 'wb') as f:
156
157
  f.write(file_content)
157
- self.application.history = History(csv_path)
158
+ self.application.history = History()
159
+ self.application.history.load_csv(csv_path, with_finalize=True)
158
160
 
159
161
  return f'current file: {file_name}', active_tab_id
160
162
 
@@ -166,7 +168,7 @@ class HomePage(AbstractPage):
166
168
  State(self.alert_region.alert_region.id, 'children'),
167
169
  prevent_initial_call=True,
168
170
  )
169
- def open_pdt(_, selection_data, current_alerts):
171
+ def open_pdt(_1, selection_data, current_alerts):
170
172
  # open_pdt allows to open "解析結果単体" without opening any femprj.
171
173
 
172
174
  # check Femtet state
@@ -175,6 +177,7 @@ class HomePage(AbstractPage):
175
177
  msg = Msg.ERR_NO_CONNECTION_ESTABLISHED
176
178
  alerts = self.alert_region.create_alerts(msg, color='danger', current_alerts=current_alerts)
177
179
  return alerts
180
+ assert self.femtet_control.fem is not None
178
181
 
179
182
  # check selection
180
183
  if selection_data is None:
@@ -200,22 +203,37 @@ class HomePage(AbstractPage):
200
203
 
201
204
  # check pdt_path in selection_data
202
205
  pt = selection_data['points'][0]
203
- trial = pt['customdata'][0]
206
+ trial = pt['customdata'][0] # TODO: MAIN 以外のデータに対応
207
+
208
+ # construct trial_name
209
+ trial_name = History.get_trial_name(trial=trial, fidelity=None, sub_sampling=None)
204
210
 
205
211
  # get pdt path
206
- pdt_path = self.femtet_control.fem._create_pdt_path(femprj_path, model_name, trial)
212
+ pdt_path = self.femtet_control.fem._create_path(
213
+ femprj_path, model_name, trial_name, 'pdt',
214
+ )
207
215
 
208
216
  # check pdt exists
209
217
  if not os.path.exists(pdt_path):
210
- msg = ('.pdt file is not found. '
211
- 'Please check the .Results folder. '
212
- 'Note that .pdt file save mode depends on '
213
- 'the `save_pdt` argument of FemtetInterface in optimization script'
214
- '(default to `all`).')
218
+ msg = _(
219
+ en_message='.pdt file ({pdt_path}) is not found. '
220
+ 'Please check the .Results folder. '
221
+ 'Note that .pdt file save mode depends on '
222
+ 'the `save_pdt` argument of FemtetInterface in optimization script'
223
+ '(default to `all`).',
224
+ jp_message='.pdt file ({pdt_path}) is not found. '
225
+ 'Please check the .Results folder. '
226
+ 'Note that .pdt file save mode depends on '
227
+ 'the `save_pdt` argument of FemtetInterface in optimization script'
228
+ '(default to `all`).',
229
+ pdt_path=pdt_path,
230
+ )
231
+
215
232
  alerts = self.alert_region.create_alerts(msg, color='danger')
216
233
  return alerts
217
234
 
218
235
  # OpenPDT(PDTFile As String, bOpenWithGUI As Boolean)
236
+ # noinspection PyPep8Naming
219
237
  Femtet = self.femtet_control.fem.Femtet
220
238
  succeed = Femtet.OpenPDT(pdt_path, True)
221
239
 
@@ -234,7 +252,7 @@ class HomePage(AbstractPage):
234
252
  State(self.alert_region.alert_region.id, 'children'),
235
253
  prevent_initial_call=True,
236
254
  )
237
- def update_parameter(_, selection_data, current_alerts):
255
+ def update_parameter(_1, selection_data, current_alerts):
238
256
 
239
257
  # check Femtet state
240
258
  connection_state = self.femtet_control.check_femtet_state()
@@ -250,12 +268,27 @@ class HomePage(AbstractPage):
250
268
  return alerts
251
269
 
252
270
  try:
271
+ # noinspection PyPep8Naming
253
272
  Femtet = self.femtet_control.fem.Femtet
254
273
 
255
274
  # check model to open is included in current project
256
275
  if (self.femtet_control.fem.femprj_path != Femtet.Project) \
257
276
  or (self.femtet_control.fem.model_name not in Femtet.GetAnalysisModelNames_py()):
258
- msg = Msg.ERR_NO_SUCH_MODEL_IN_FEMPRJ + f' model name: {self.femtet_control.fem.model_name}'
277
+
278
+ msg = _(
279
+ en_message='Model {model_name} is not in current project. '
280
+ 'Please check opened project. '
281
+ 'For example, if you have "Analysis Results '
282
+ 'Only" open, please switch the project to '
283
+ '{prj_name}.',
284
+ jp_message='モデル {model_name} は現在のプロジェクトに含まれていません。'
285
+ '開いているプロジェクトを確認してください。例えば「解析結果単体」'
286
+ 'を開いている場合、プロジェクトを {prj_name} に切り替えてください。',
287
+ model_name=self.femtet_control.fem.model_name,
288
+ prj_name=os.path.basename(self.femtet_control.fem.femprj_path),
289
+ )
290
+
291
+
259
292
  alerts = self.alert_region.create_alerts(msg, color='danger', current_alerts=current_alerts)
260
293
  return alerts
261
294
 
@@ -270,39 +303,40 @@ class HomePage(AbstractPage):
270
303
  ...
271
304
 
272
305
  except Exception as e:
273
- msg = ('Unknown error has occurred in analysis model compatibility check. '
274
- f'exception message is: {e}')
306
+ print_exception(e)
307
+ msg = _(
308
+ en_message='Unknown error has occurred in '
309
+ 'analysis model compatibility check. '
310
+ 'Exception message: {e}',
311
+ jp_message='Unknown error has occurred in '
312
+ 'analysis model compatibility check. '
313
+ 'Exception message: {e}',
314
+ e=e
315
+ )
275
316
  alerts = self.alert_region.create_alerts(msg, color='danger', current_alerts=current_alerts)
276
317
  return alerts
277
318
 
278
319
  try:
279
320
  # get nth trial from selection data
280
321
  pt = selection_data['points'][0]
281
- trial = pt['customdata'][0]
322
+ trial = pt['customdata'][0] # FIXME: MAIN 以外のデータに対応
282
323
 
283
324
  # get parameter and update model
284
- df = self.application.history.get_df(valid_only=True)
325
+ df = self.application.get_df()
285
326
  row = df[df['trial'] == trial]
286
- meta_columns = np.array(self.application.history.meta_columns)
287
- idx = np.where(meta_columns == 'prm')[0]
327
+ prm_names = self.application.history.prm_names
328
+ prm_values = row[prm_names].values.ravel()
329
+ x = {name: value for name, value in zip(prm_names, prm_values)}
288
330
 
289
- names = np.array(row.columns)[idx]
290
- values = np.array(row.iloc[:, idx]).ravel()
291
-
292
- parameter = pd.DataFrame(
293
- dict(
294
- name=names,
295
- value=values,
296
- )
297
- )
298
-
299
- self.femtet_control.fem.update_model(parameter)
331
+ self.femtet_control.fem.update_parameter(x)
332
+ self.femtet_control.fem.update_model()
300
333
 
301
334
  Femtet.SaveProject(Femtet.Project, True)
302
335
 
303
336
  return no_update
304
337
 
305
338
  except Exception as e:
339
+ print_exception(e)
306
340
  msg = ('Unknown error has occurred in updating model. '
307
341
  f'exception message is: {e}')
308
342
  alerts = self.alert_region.create_alerts(msg, color='danger', current_alerts=current_alerts)
@@ -350,11 +384,15 @@ class HomePage(AbstractPage):
350
384
  femprj_path_history_on_history: str or None = kwargs['femprj_path']
351
385
  model_name_on_history: str or None = kwargs['model_name']
352
386
  # ├ Femtet-side
387
+ # noinspection PyPep8Naming
353
388
  Femtet = self.femtet_control.fem.Femtet
354
389
  femprj_path: str = Femtet.Project # it can be '解析結果単体.femprj'
355
390
  model_name: str = Femtet.AnalysisModelName
356
391
  # └ check
357
- is_same_femprj = (femprj_path == femprj_path_history_on_history) if femprj_path_history_on_history is not None else True
392
+ if femprj_path_history_on_history is not None:
393
+ is_same_femprj = (femprj_path == femprj_path_history_on_history)
394
+ else:
395
+ is_same_femprj = True
358
396
  is_same_model = (model_name == model_name_on_history) if model_name is not None else True
359
397
 
360
398
  # alert
@@ -631,7 +669,6 @@ class Tutorial(AbstractPage):
631
669
  @app.callback(
632
670
  Output(self.main_graph.tabs, self.main_graph.tabs.Prop.active_tab, allow_duplicate=True),
633
671
  Output(self.control_visibility_input_dummy, 'children'),
634
- # Output(self.femtet_control.connect_femtet_button, 'n_clicks', allow_duplicate=True), # automatically open femtet is now deprecated because enable to use analytical functions without using license.
635
672
  Output(alert_region, 'children', allow_duplicate=True),
636
673
  Input(self.load_sample_csv_button, 'n_clicks'),
637
674
  State(self.main_graph.tabs, self.main_graph.tabs.Prop.active_tab),
@@ -643,41 +680,44 @@ class Tutorial(AbstractPage):
643
680
  if callback_context.triggered_id is None:
644
681
  raise PreventUpdate
645
682
 
646
- # get sample file
647
- import pyfemtet
648
- package_root = os.path.dirname(pyfemtet.__file__)
649
- sample_dir = os.path.join(package_root, 'opt', 'samples', 'femprj_sample') # FIXME: locale によってパスを変える
650
- path = os.path.join(sample_dir, 'wat_ex14_parametric_test_result.reccsv')
683
+ # copy sample files
684
+ here = os.path.abspath(os.path.dirname(__file__))
685
+ sample_dir = os.path.join(here, 'tutorial_files') # TODO: locale ごとにファイルを用意する
651
686
 
652
- if not os.path.exists(path):
687
+ # get sample file
688
+ path = os.path.join(sample_dir, 'tutorial_gau_ex08.csv')
689
+ if not os.path.isfile(path):
653
690
  msg = Msg.ERR_SAMPLE_CSV_NOT_FOUND
654
691
  alerts = self.home_page.alert_region.create_alerts(msg, color='danger', current_alerts=current_alerts)
655
692
  return no_update, no_update, alerts
656
- destination_file = path.replace('wat_ex14_parametric_test_result.reccsv', 'tutorial.csv')
657
- shutil.copyfile(path, destination_file)
658
- self.application.history = History(destination_file)
693
+ self.application.history = History()
694
+ self.application.history.load_csv(path, with_finalize=True)
659
695
 
660
- source_file = path.replace('_test_result.reccsv', '.femprj')
661
- if not os.path.exists(source_file):
696
+ femprj_path = path.replace('.csv', '_parametric.femprj')
697
+ if not os.path.isfile(femprj_path):
662
698
  msg = Msg.ERR_SAMPLE_FEMPRJ_NOT_FOUND
663
699
  alerts = self.home_page.alert_region.create_alerts(msg, color='danger', current_alerts=current_alerts)
664
700
  return no_update, no_update, alerts
665
- destination_file = source_file.replace('wat_ex14_parametric', 'tutorial')
666
- shutil.copyfile(source_file, destination_file)
667
701
 
668
- source_folder = path.replace('_test_result.reccsv', '.Results')
669
- if not os.path.exists(source_file):
702
+ result_folder = femprj_path.replace('.femprj', '.Results')
703
+ if not os.path.isdir(result_folder):
670
704
  msg = Msg.ERR_FEMPRJ_RESULT_NOT_FOUND
671
705
  alerts = self.home_page.alert_region.create_alerts(msg, color='danger', current_alerts=current_alerts)
672
706
  return no_update, no_update, alerts
673
- destination_folder = source_folder.replace('wat_ex14_parametric', 'tutorial')
674
- shutil.copytree(source_folder, destination_folder, dirs_exist_ok=True)
675
707
 
676
- self.application.history.meta_columns[0] = json.dumps(
677
- dict(
678
- femprj_path=destination_file,
679
- model_name='Ex14',
680
- )
708
+ history = self.application.history
709
+
710
+ additional_data = history.additional_data
711
+ additional_data.update(dict(
712
+ femprj_path=femprj_path
713
+ ))
714
+
715
+ history.finalize(
716
+ parameters=history._records.column_manager.parameters,
717
+ obj_names=history.obj_names,
718
+ cns_names=history.cns_names,
719
+ sub_fidelity_names=history.sub_fidelity_names,
720
+ additional_data=additional_data,
681
721
  )
682
722
 
683
723
  return active_tab, 1, no_update
@@ -715,19 +755,3 @@ class Tutorial(AbstractPage):
715
755
  else:
716
756
  current_style.update(part)
717
757
  return current_style
718
-
719
-
720
- class PredictionModelPage(AbstractPage):
721
- """"""
722
-
723
- def __init__(self, title, rel_url, application):
724
- from pyfemtet.opt.visualization._process_monitor.application import ProcessMonitorApplication
725
- self.application: ProcessMonitorApplication = None
726
- super().__init__(title, rel_url, application)
727
-
728
- def setup_component(self):
729
- self.rsm_graph: PredictionModelGraph = PredictionModelGraph()
730
- self.add_subpage(self.rsm_graph)
731
-
732
- def setup_layout(self):
733
- self.layout = self.rsm_graph.layout