pyfemtet 1.1.4__py3-none-any.whl → 1.1.5__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.
- pyfemtet/logger/_impl.py +26 -1
- pyfemtet/opt/optimizer/optuna_optimizer/_optuna_optimizer.py +40 -2
- pyfemtet/opt/problem/variable_manager/_variable_manager.py +1 -0
- pyfemtet/opt/visualization/history_viewer/_complex_components/pm_graph.py +4 -3
- {pyfemtet-1.1.4.dist-info → pyfemtet-1.1.5.dist-info}/METADATA +1 -1
- {pyfemtet-1.1.4.dist-info → pyfemtet-1.1.5.dist-info}/RECORD +10 -10
- {pyfemtet-1.1.4.dist-info → pyfemtet-1.1.5.dist-info}/WHEEL +1 -1
- {pyfemtet-1.1.4.dist-info → pyfemtet-1.1.5.dist-info}/entry_points.txt +0 -0
- {pyfemtet-1.1.4.dist-info → pyfemtet-1.1.5.dist-info}/licenses/LICENSE +0 -0
- {pyfemtet-1.1.4.dist-info → pyfemtet-1.1.5.dist-info}/licenses/LICENSE_THIRD_PARTY.txt +0 -0
pyfemtet/logger/_impl.py
CHANGED
|
@@ -81,6 +81,7 @@ def __create_formatter(colored=True):
|
|
|
81
81
|
# ===== handler config =====
|
|
82
82
|
|
|
83
83
|
STDOUT_HANDLER_NAME = 'stdout-handler'
|
|
84
|
+
STDERR_HANDLER_NAME = 'stderr-handler'
|
|
84
85
|
|
|
85
86
|
|
|
86
87
|
def __get_stdout_handler():
|
|
@@ -94,6 +95,17 @@ def __has_stdout_handler(logger):
|
|
|
94
95
|
return any([handler.get_name() != STDOUT_HANDLER_NAME for handler in logger.handlers])
|
|
95
96
|
|
|
96
97
|
|
|
98
|
+
def __get_stderr_handler():
|
|
99
|
+
stderr_handler = logging.StreamHandler(sys.stderr)
|
|
100
|
+
stderr_handler.set_name(STDERR_HANDLER_NAME)
|
|
101
|
+
stderr_handler.setFormatter(__create_formatter(colored=True))
|
|
102
|
+
return stderr_handler
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def __has_stderr_handler(logger):
|
|
106
|
+
return any([handler.get_name() != STDERR_HANDLER_NAME for handler in logger.handlers])
|
|
107
|
+
|
|
108
|
+
|
|
97
109
|
def set_stdout_output(logger, level=logging.INFO):
|
|
98
110
|
|
|
99
111
|
if not __has_stdout_handler(logger):
|
|
@@ -107,6 +119,19 @@ def remove_stdout_output(logger):
|
|
|
107
119
|
logger.removeHandler(__get_stdout_handler())
|
|
108
120
|
|
|
109
121
|
|
|
122
|
+
def set_stderr_output(logger, level=logging.INFO):
|
|
123
|
+
|
|
124
|
+
if not __has_stderr_handler(logger):
|
|
125
|
+
logger.addHandler(__get_stderr_handler())
|
|
126
|
+
|
|
127
|
+
logger.setLevel(level)
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def remove_stderr_output(logger):
|
|
131
|
+
if __has_stderr_handler(logger):
|
|
132
|
+
logger.removeHandler(__get_stderr_handler())
|
|
133
|
+
|
|
134
|
+
|
|
110
135
|
def add_file_output(logger, filepath=None, level=logging.INFO) -> str:
|
|
111
136
|
"""Add FileHandler to the logger.
|
|
112
137
|
|
|
@@ -165,7 +190,7 @@ def setup_package_root_logger(package_name):
|
|
|
165
190
|
with __lock:
|
|
166
191
|
logger = logging.getLogger(package_name)
|
|
167
192
|
logger.propagate = True
|
|
168
|
-
|
|
193
|
+
set_stderr_output(logger)
|
|
169
194
|
logger.setLevel(logging.INFO)
|
|
170
195
|
__initialized_root_packages.append(package_name)
|
|
171
196
|
else:
|
|
@@ -43,6 +43,20 @@ warnings.filterwarnings('ignore', 'Argument ``constraints_func`` is an experimen
|
|
|
43
43
|
_MESSAGE_ENQUEUED = 'Enqueued trial.'
|
|
44
44
|
|
|
45
45
|
|
|
46
|
+
def check_float_and_raise(value, check_target):
|
|
47
|
+
if isinstance(value, int | float):
|
|
48
|
+
if np.isnan(value):
|
|
49
|
+
raise ValueError(_(
|
|
50
|
+
en_message=f'{check_target} is NaN.',
|
|
51
|
+
jp_message=f'{check_target} は NaN です。',
|
|
52
|
+
))
|
|
53
|
+
else:
|
|
54
|
+
raise ValueError(_(
|
|
55
|
+
en_message=f'{check_target} should be a number, but {value} ({type(value)}) passed.',
|
|
56
|
+
jp_message=f'{check_target} は数値でなくてはなりませんが、{value} ({type(value)}) が与えられました。',
|
|
57
|
+
))
|
|
58
|
+
|
|
59
|
+
|
|
46
60
|
class MaxTrialsCallbackExcludingEnqueued(MaxTrialsCallback):
|
|
47
61
|
def __call__(self, study: Study, trial: FrozenTrial) -> None:
|
|
48
62
|
"""
|
|
@@ -167,14 +181,31 @@ class OptunaOptimizer(AbstractOptimizer):
|
|
|
167
181
|
self,
|
|
168
182
|
name: str,
|
|
169
183
|
initial_value: float,
|
|
170
|
-
lower_bound: float,
|
|
171
|
-
upper_bound: float,
|
|
184
|
+
lower_bound: float | None = None,
|
|
185
|
+
upper_bound: float | None = None,
|
|
172
186
|
step: float | None = None,
|
|
173
187
|
properties: dict[str, ...] | None = None,
|
|
174
188
|
*,
|
|
175
189
|
pass_to_fem: bool = True,
|
|
176
190
|
fix: bool = False,
|
|
177
191
|
) -> None:
|
|
192
|
+
|
|
193
|
+
if lower_bound is None or upper_bound is None:
|
|
194
|
+
properties = properties or {}
|
|
195
|
+
if properties.get('dynamic_bounds_fun') is None:
|
|
196
|
+
raise ValueError(_(
|
|
197
|
+
en_message='When using `OptunaOptimizer`, you must either specify `lower_bound` and `upper_bound`, ' \
|
|
198
|
+
'or include `dynamic_bounds_fun` (Callable[[AbstractOptimizer], float]) in `properties`.',
|
|
199
|
+
jp_message='OptunaOptimizer では、lower_bound と upper_bound を両方指定するか、' \
|
|
200
|
+
'または properties に dynamic_bounds_fun (Callable[[AbstractOptimizer], float]) ' \
|
|
201
|
+
'を含めなければなりません。'
|
|
202
|
+
))
|
|
203
|
+
else:
|
|
204
|
+
logger.warning(_(
|
|
205
|
+
en_message='`dynamic_bounds_fun` is under development. The functionally can be changed without any announcement.',
|
|
206
|
+
jp_message='dynamic_bounds_fun は開発中の機能です。機能は予告なく変更されることがあります。',
|
|
207
|
+
))
|
|
208
|
+
|
|
178
209
|
AbstractOptimizer.add_parameter(self, name, initial_value, lower_bound, upper_bound, step, properties,
|
|
179
210
|
pass_to_fem=pass_to_fem, fix=fix)
|
|
180
211
|
|
|
@@ -271,6 +302,13 @@ class OptunaOptimizer(AbstractOptimizer):
|
|
|
271
302
|
continue
|
|
272
303
|
|
|
273
304
|
if isinstance(prm, NumericParameter):
|
|
305
|
+
dynamic_bounds_fun = prm.properties.get('dynamic_bounds_fun')
|
|
306
|
+
if dynamic_bounds_fun:
|
|
307
|
+
lb, ub = dynamic_bounds_fun(self)
|
|
308
|
+
check_float_and_raise(lb, _(f'lower_bound of {prm.name}', f'{prm.name} の lower_bound'))
|
|
309
|
+
check_float_and_raise(ub, _(f'upper_bound of {prm.name}', f'{prm.name} の upper_bound'))
|
|
310
|
+
prm.lower_bound = lb
|
|
311
|
+
prm.upper_bound = ub
|
|
274
312
|
prm.value = trial.suggest_float(
|
|
275
313
|
name,
|
|
276
314
|
prm.lower_bound,
|
|
@@ -428,9 +428,10 @@ class PredictionModelGraph(AbstractPage):
|
|
|
428
428
|
self.CommandState.ready.value,
|
|
429
429
|
self.alert_region.create_alerts(
|
|
430
430
|
_(
|
|
431
|
-
en_message='Cannot draw the graph because
|
|
432
|
-
'
|
|
433
|
-
|
|
431
|
+
en_message='Cannot draw the graph because '
|
|
432
|
+
'the bounds of selected parameter '
|
|
433
|
+
'are not given.',
|
|
434
|
+
jp_message='選択された変数は上下限が与えられていないため、'
|
|
434
435
|
'グラフを描画できません。',
|
|
435
436
|
),
|
|
436
437
|
color='danger',
|
|
@@ -26,7 +26,7 @@ pyfemtet/core.py,sha256=t5tvWGrBNzCL9cP-91hbTR8q5lzULPsVeIEybeslhxQ,936
|
|
|
26
26
|
pyfemtet/dispatch_extensions/__init__.py,sha256=BzxYq3x8YdkdClq4VvH4G5HTGxu5nyAhN7xlFsnTv8c,159
|
|
27
27
|
pyfemtet/dispatch_extensions/_impl.py,sha256=Sgp350ioKcNVslXv9xRdtRjaQGRQM-BwbJYXjeildtw,11107
|
|
28
28
|
pyfemtet/logger/__init__.py,sha256=lofBrZHr0P1hsxPUiPG1SQqKxCuSBk8zGnR7vUfCHYw,516
|
|
29
|
-
pyfemtet/logger/_impl.py,sha256=
|
|
29
|
+
pyfemtet/logger/_impl.py,sha256=tR71WZbjUvnZqULzxD4Y8Vhq8eBnJhMm360-JXxB5Dc,7012
|
|
30
30
|
pyfemtet/opt/__init__.py,sha256=1LcwTddtoi8plemxkzmX0YEKiNpAZvKn9OoNQysyDLE,339
|
|
31
31
|
pyfemtet/opt/exceptions.py,sha256=M_O7jm20Y4e_QxsKF6tnEl-OrAtErUOj6hNT7eEXCO4,1327
|
|
32
32
|
pyfemtet/opt/femopt.py,sha256=Zht_H_eaTUwUcA7XFlzod0mGoJzTOZckqRK3VuwjaHM,23716
|
|
@@ -68,7 +68,7 @@ pyfemtet/opt/optimizer/_base_optimizer.py,sha256=o7XYqAJywX-gnXu2iyKXRKAhyIklZxb
|
|
|
68
68
|
pyfemtet/opt/optimizer/_trial_queue.py,sha256=Yv6JlfVCYOiCukllfxk79xU4_utmxwRA3gcCWpdyG9k,2919
|
|
69
69
|
pyfemtet/opt/optimizer/optuna_optimizer/__init__.py,sha256=u2Bwc79tkZTU5dMbhzzrPQi0RlFg22UgXc-m9K9G6wQ,242
|
|
70
70
|
pyfemtet/opt/optimizer/optuna_optimizer/_optuna_attribute.py,sha256=7eZsruVCGgMlcnf3a9Vf55FOEE-D7V777MJQajI12Cw,1842
|
|
71
|
-
pyfemtet/opt/optimizer/optuna_optimizer/_optuna_optimizer.py,sha256=
|
|
71
|
+
pyfemtet/opt/optimizer/optuna_optimizer/_optuna_optimizer.py,sha256=mlp4jnjK78lV7hiw_SYrIc8k1CuE28z9hxHSfeefTIk,35078
|
|
72
72
|
pyfemtet/opt/optimizer/optuna_optimizer/_pof_botorch/__init__.py,sha256=BFbMNvdXqV9kl1h340pW2sq0-cwNFV5dfTo6UnNnX2M,179
|
|
73
73
|
pyfemtet/opt/optimizer/optuna_optimizer/_pof_botorch/debug-pof-botorch.reccsv,sha256=K6oI9jPi_5yayhBrI9Tm1RX3PoWWKo74TOdqnaPsIy8,1746
|
|
74
74
|
pyfemtet/opt/optimizer/optuna_optimizer/_pof_botorch/enable_nonlinear_constraint.py,sha256=jq8cfkZuEkdd8Gvlr3Do4dl48bKSm9Uu7AcEy1dAf6U,9901
|
|
@@ -85,7 +85,7 @@ pyfemtet/opt/problem/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hS
|
|
|
85
85
|
pyfemtet/opt/problem/problem.py,sha256=X9mro2yVJ6Uw9ck0F0OjG-0M2ReKtuWltu-JUEFIkzQ,10025
|
|
86
86
|
pyfemtet/opt/problem/variable_manager/__init__.py,sha256=uzuraWUZfLzB3uZHIQHFL7uMxWvv7Oaf940zEozXtNY,476
|
|
87
87
|
pyfemtet/opt/problem/variable_manager/_string_as_expression.py,sha256=aTJ9W9Gs6BS0Z_OsxWByJs9dAt32opD2_9913MCggPg,3626
|
|
88
|
-
pyfemtet/opt/problem/variable_manager/_variable_manager.py,sha256=
|
|
88
|
+
pyfemtet/opt/problem/variable_manager/_variable_manager.py,sha256=jtIHFWgVP2jhA3c5uSD388VZHuShR25ZZ8SYz5-6Rro,12785
|
|
89
89
|
pyfemtet/opt/visualization/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
90
90
|
pyfemtet/opt/visualization/_create_wrapped_components.py,sha256=9AltJHr1DM6imZfpNp867rC-uAYqQ-emdgTLChKDrl8,2513
|
|
91
91
|
pyfemtet/opt/visualization/history_viewer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -97,7 +97,7 @@ pyfemtet/opt/visualization/history_viewer/_complex_components/alert_region.py,sh
|
|
|
97
97
|
pyfemtet/opt/visualization/history_viewer/_complex_components/control_femtet.py,sha256=FQUR9bYtMoj_3bvHXfzAhYMoYpbIWcDP8j7M2EwnYQM,6253
|
|
98
98
|
pyfemtet/opt/visualization/history_viewer/_complex_components/detail_graphs.py,sha256=friaHAJOG5BEUAkoy7ukpO-vUhJ0DlJFwMB2ayNJ4so,19134
|
|
99
99
|
pyfemtet/opt/visualization/history_viewer/_complex_components/main_graph.py,sha256=dMphOHbSV2R3oQvPlIQj7GwtV0phPiBwKniblxTAxMY,25978
|
|
100
|
-
pyfemtet/opt/visualization/history_viewer/_complex_components/pm_graph.py,sha256
|
|
100
|
+
pyfemtet/opt/visualization/history_viewer/_complex_components/pm_graph.py,sha256=y3FSZGIdaWcJQdbACbfIkjuAumW6pXxQ89Wkafnp4pA,29854
|
|
101
101
|
pyfemtet/opt/visualization/history_viewer/_detail_page.py,sha256=2LdCFSCcxZkAH6QMa9q6QX-KLYhVrRf-iTh7jNPrnnA,3406
|
|
102
102
|
pyfemtet/opt/visualization/history_viewer/_helper.py,sha256=276488eouQEo-haK4XXCVM1Vy8_28Vyp5g0l7zt4Sfc,1009
|
|
103
103
|
pyfemtet/opt/visualization/history_viewer/_process_monitor/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -171,9 +171,9 @@ pyfemtet/opt/visualization/plotter/parallel_plot_creator.py,sha256=VRhT0CUG1mCHD
|
|
|
171
171
|
pyfemtet/opt/visualization/plotter/pm_graph_creator.py,sha256=7EwmoJlnHwDrpw65NchiA63FIjgGTLq6vTcpTzrSnJo,11841
|
|
172
172
|
pyfemtet/opt/wat_ex14_parametric_jp.femprj,sha256=dMwQMt6yok_PbZLyxPYdmg5wJQwgQDZ4RhS76zdGLGk,177944
|
|
173
173
|
pyfemtet/opt/worker_status.py,sha256=simvPa1AkO1idmPXrF5WjYVEBx3tO7hLhbM3J1rFjdo,3824
|
|
174
|
-
pyfemtet-1.1.
|
|
175
|
-
pyfemtet-1.1.
|
|
176
|
-
pyfemtet-1.1.
|
|
177
|
-
pyfemtet-1.1.
|
|
178
|
-
pyfemtet-1.1.
|
|
179
|
-
pyfemtet-1.1.
|
|
174
|
+
pyfemtet-1.1.5.dist-info/METADATA,sha256=wWktO1slosfUsyfHUxASVT6iauIeAypOMwE2A7YvbeE,3410
|
|
175
|
+
pyfemtet-1.1.5.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
|
|
176
|
+
pyfemtet-1.1.5.dist-info/entry_points.txt,sha256=Tsb_l_8Z6pyyq2tRfuKiwfJUV3nq_cHoLS61foALtsg,134
|
|
177
|
+
pyfemtet-1.1.5.dist-info/licenses/LICENSE,sha256=LWUL5LlMGjSRTvsalS8_fFuwS4VMw18fJSNWFwDK8pc,1060
|
|
178
|
+
pyfemtet-1.1.5.dist-info/licenses/LICENSE_THIRD_PARTY.txt,sha256=8_9-cgzTpmeuCqItPZb9-lyAZcH2Qp9sZTU_hYuOZIQ,191
|
|
179
|
+
pyfemtet-1.1.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|