pyfemtet 0.8.3__py3-none-any.whl → 0.8.4__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/__init__.py +1 -1
- pyfemtet/opt/_femopt.py +4 -5
- pyfemtet/opt/_femopt_core.py +1 -2
- pyfemtet/opt/interface/__init__.py +14 -10
- {pyfemtet-0.8.3.dist-info → pyfemtet-0.8.4.dist-info}/METADATA +1 -1
- {pyfemtet-0.8.3.dist-info → pyfemtet-0.8.4.dist-info}/RECORD +9 -10
- pyfemtet/_imports.py +0 -108
- {pyfemtet-0.8.3.dist-info → pyfemtet-0.8.4.dist-info}/LICENSE +0 -0
- {pyfemtet-0.8.3.dist-info → pyfemtet-0.8.4.dist-info}/WHEEL +0 -0
- {pyfemtet-0.8.3.dist-info → pyfemtet-0.8.4.dist-info}/entry_points.txt +0 -0
pyfemtet/__init__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.8.
|
|
1
|
+
__version__ = "0.8.4"
|
pyfemtet/opt/_femopt.py
CHANGED
|
@@ -31,7 +31,6 @@ from pyfemtet.opt._femopt_core import (
|
|
|
31
31
|
from pyfemtet._message import Msg, encoding
|
|
32
32
|
from pyfemtet.opt.optimizer.parameter import Parameter, Expression
|
|
33
33
|
from pyfemtet._warning import experimental_feature
|
|
34
|
-
from pyfemtet._imports import *
|
|
35
34
|
|
|
36
35
|
from dask import config as cfg
|
|
37
36
|
cfg.set({'distributed.scheduler.worker-ttl': None})
|
|
@@ -368,7 +367,7 @@ class FEMOpt:
|
|
|
368
367
|
# 引数の処理
|
|
369
368
|
if fun is None:
|
|
370
369
|
from pyfemtet.opt.interface import SurrogateModelInterfaceBase
|
|
371
|
-
if not
|
|
370
|
+
if not isinstance(self.fem, SurrogateModelInterfaceBase):
|
|
372
371
|
raise ValueError('`fun` argument is not specified.')
|
|
373
372
|
if args is None:
|
|
374
373
|
args = tuple()
|
|
@@ -511,13 +510,13 @@ class FEMOpt:
|
|
|
511
510
|
name = candidate
|
|
512
511
|
if using_fem is None:
|
|
513
512
|
# 自動推定機能は Femtet 特有の処理とする
|
|
514
|
-
if
|
|
513
|
+
if isinstance(self.fem, FemtetInterface):
|
|
515
514
|
using_fem = _is_access_femtet(fun)
|
|
516
515
|
else:
|
|
517
516
|
using_fem = False
|
|
518
517
|
|
|
519
518
|
# strict constraint の場合、solve 前に評価したいので Gogh へのアクセスを禁ずる
|
|
520
|
-
if strict and
|
|
519
|
+
if strict and isinstance(self.fem, FemtetInterface):
|
|
521
520
|
if _is_access_gogh(fun):
|
|
522
521
|
message = Msg.ERR_CONTAIN_GOGH_ACCESS_IN_STRICT_CONSTRAINT
|
|
523
522
|
raise Exception(message)
|
|
@@ -681,7 +680,7 @@ class FEMOpt:
|
|
|
681
680
|
|
|
682
681
|
# Femtet 特有の処理
|
|
683
682
|
metadata = None
|
|
684
|
-
if
|
|
683
|
+
if isinstance(self.fem, FemtetInterface):
|
|
685
684
|
|
|
686
685
|
# 結果 csv に記載する femprj に関する情報の作成
|
|
687
686
|
metadata = json.dumps(
|
pyfemtet/opt/_femopt_core.py
CHANGED
|
@@ -36,7 +36,6 @@ else:
|
|
|
36
36
|
# pyfemtet relative
|
|
37
37
|
from pyfemtet.opt.interface import FEMInterface, FemtetInterface
|
|
38
38
|
from pyfemtet._message import encoding, Msg
|
|
39
|
-
from pyfemtet._imports import *
|
|
40
39
|
|
|
41
40
|
# logger
|
|
42
41
|
from pyfemtet.logger import get_module_logger
|
|
@@ -324,7 +323,7 @@ class Function:
|
|
|
324
323
|
|
|
325
324
|
args = self.args
|
|
326
325
|
# Femtet 特有の処理
|
|
327
|
-
if
|
|
326
|
+
if isinstance(fem, FemtetInterface):
|
|
328
327
|
args = (fem.Femtet, *args)
|
|
329
328
|
return float(self.fun(*args, **self.kwargs))
|
|
330
329
|
|
|
@@ -1,30 +1,34 @@
|
|
|
1
|
+
import platform
|
|
1
2
|
from typing import TYPE_CHECKING
|
|
2
|
-
from pyfemtet._imports import _LazyImport, _lazy_class_factory
|
|
3
3
|
|
|
4
4
|
from pyfemtet.opt.interface._base import FEMInterface
|
|
5
5
|
from pyfemtet.opt.interface._base import NoFEM
|
|
6
6
|
|
|
7
|
-
if TYPE_CHECKING:
|
|
7
|
+
if (platform.system() == 'Windows') or TYPE_CHECKING:
|
|
8
8
|
from pyfemtet.opt.interface._femtet import FemtetInterface
|
|
9
9
|
from pyfemtet.opt.interface._femtet_with_sldworks import FemtetWithSolidworksInterface
|
|
10
10
|
from pyfemtet.opt.interface._femtet_with_nx import FemtetWithNXInterface
|
|
11
|
-
from pyfemtet.opt.interface._surrogate import PoFBoTorchInterface
|
|
12
11
|
from pyfemtet.opt.interface._excel_interface import ExcelInterface
|
|
13
12
|
|
|
14
13
|
else:
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
PoFBoTorchInterface = _lazy_class_factory(_LazyImport('pyfemtet.opt.interface._surrogate'), 'PoFBoTorchInterface')
|
|
19
|
-
ExcelInterface = _lazy_class_factory(_LazyImport('pyfemtet.opt.interface._excel_interface'), 'ExcelInterface')
|
|
14
|
+
class NotAvailableForWindows:
|
|
15
|
+
def __init__(self, *args, **kwargs):
|
|
16
|
+
raise NotImplementedError
|
|
20
17
|
|
|
21
18
|
|
|
19
|
+
FemtetInterface = type('FemtetInterface', (NotAvailableForWindows,), {})
|
|
20
|
+
FemtetWithSolidworksInterface = type('FemtetWithSolidworksInterface', (FemtetInterface,), {})
|
|
21
|
+
FemtetWithNXInterface = type('FemtetWithNXInterface', (FemtetInterface,), {})
|
|
22
|
+
ExcelInterface = type('FemtetInterface', (NotAvailableForWindows,), {})
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
from pyfemtet.opt.interface._surrogate import PoFBoTorchInterface
|
|
25
|
+
|
|
26
|
+
__all__ =[
|
|
24
27
|
'FEMInterface',
|
|
25
28
|
'NoFEM',
|
|
26
29
|
'FemtetInterface',
|
|
27
|
-
'FemtetWithNXInterface',
|
|
28
30
|
'FemtetWithSolidworksInterface',
|
|
31
|
+
'FemtetWithNXInterface',
|
|
32
|
+
'ExcelInterface',
|
|
29
33
|
'PoFBoTorchInterface',
|
|
30
34
|
]
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
pyfemtet/__init__.py,sha256=
|
|
1
|
+
pyfemtet/__init__.py,sha256=oR63M0ef9dMrWZnMjTb9xk69cW2iS6rluqpyJ5_0C84,21
|
|
2
2
|
pyfemtet/_femtet_config_util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
3
|
pyfemtet/_femtet_config_util/autosave.py,sha256=dNirA9XGuFehas8_Jkj2BW9GOzMbPyhnt1WHcH_ObSU,2070
|
|
4
4
|
pyfemtet/_femtet_config_util/exit.py,sha256=0BWID-tjOkmZwmgPFkcJMkWW39voccz5ARIBWvZbHaw,1877
|
|
5
|
-
pyfemtet/_imports.py,sha256=sO_YNotNCG6IeoA0ge34YnH7q6q_qx2VFDKei3ZfvSk,3268
|
|
6
5
|
pyfemtet/_message/1. make_pot.bat,sha256=wrTA0YaL7nUfNB0cS8zljOmwq2qgyG6RMwHQbrwjvY4,476
|
|
7
6
|
pyfemtet/_message/2. make_mo.bat,sha256=6shJ3Yn4BXjDc0hhv_kiGUtVTq4oSRz8-iS4vW29rNE,155
|
|
8
7
|
pyfemtet/_message/__init__.py,sha256=gE1-XX_PzHj9BbhqPaK5VcIHuv6_Tec5qlPMC3IRiBg,100
|
|
@@ -25,8 +24,8 @@ pyfemtet/dispatch_extensions/_impl.py,sha256=yH_yeAnQ-Xi9GfjX-FQt9u3yHnrLYIteRb6
|
|
|
25
24
|
pyfemtet/logger/__init__.py,sha256=UOJ9n_U2xwdTrp0Xgg-N6geySxNzKqTBQlXsaH0kW_w,420
|
|
26
25
|
pyfemtet/logger/_impl.py,sha256=rsAd0HpmveOaLS39ucp3U2OcDhQMWjC5fnVGhbJtWVw,6375
|
|
27
26
|
pyfemtet/opt/__init__.py,sha256=wRR8LbEhb5I6MUgmnCgjB6-tqHlOVxDIo7yPkq0QbBs,758
|
|
28
|
-
pyfemtet/opt/_femopt.py,sha256=
|
|
29
|
-
pyfemtet/opt/_femopt_core.py,sha256=
|
|
27
|
+
pyfemtet/opt/_femopt.py,sha256=vqLUGMMHn0lp0bRE_FEV0sOoUcVAbohy9_8OLYw3ZrU,39217
|
|
28
|
+
pyfemtet/opt/_femopt_core.py,sha256=mA2wQ5h_mmbTQ9ilhDHLUyN-jsWFDpJE2r5guUWlS10,38083
|
|
30
29
|
pyfemtet/opt/_test_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
31
30
|
pyfemtet/opt/_test_utils/control_femtet.py,sha256=8oAl9y5V2n8Nnsgx_ebcZVzwFt1eI3swkdiKg6pg3-M,1085
|
|
32
31
|
pyfemtet/opt/_test_utils/hyper_sphere.py,sha256=nQhw8EIY0DwvcTqrbKhkxiITLZifr4-nG77E-_6ggmA,700
|
|
@@ -40,7 +39,7 @@ pyfemtet/opt/advanced_samples/surrogate_model/gal_ex13_create_training_data_jp.p
|
|
|
40
39
|
pyfemtet/opt/advanced_samples/surrogate_model/gal_ex13_optimize_with_surrogate.py,sha256=s0b31wuN3iXjb78dt0ro0ZjxHa8uLIH94jRfEuj1EVY,3090
|
|
41
40
|
pyfemtet/opt/advanced_samples/surrogate_model/gal_ex13_optimize_with_surrogate_jp.py,sha256=OAOpHKyMMo1StSqNMqx4saYDn4hiGOKDypyK6uhTILQ,3215
|
|
42
41
|
pyfemtet/opt/advanced_samples/surrogate_model/gal_ex13_parametric.femprj,sha256=iIHH1X-wWBqEYj4cFJXco73LCJXSrYBsSKOD0HxYu60,87599
|
|
43
|
-
pyfemtet/opt/interface/__init__.py,sha256=
|
|
42
|
+
pyfemtet/opt/interface/__init__.py,sha256=dkQ8PoIzYJVRtckNN2VgL7FEwci9RbYM3owOvqnPm80,1219
|
|
44
43
|
pyfemtet/opt/interface/_base.py,sha256=y0uQ5jdsWbgt5odyqPin7NXcK_IbUwPDcrrkV_JhpRw,2722
|
|
45
44
|
pyfemtet/opt/interface/_excel_interface.py,sha256=s103vePTPXXYiPwGdAEUFgtpvGXtu1nSljDtP4HsmcY,40355
|
|
46
45
|
pyfemtet/opt/interface/_femtet.py,sha256=teALmp66aJ_rrmtEOjCGDG1jGLTZr2AmvMFmuuXRQkw,34634
|
|
@@ -138,8 +137,8 @@ pyfemtet/opt/visualization/result_viewer/.gitignore,sha256=ryvb4aqbbsHireHWlPQfx
|
|
|
138
137
|
pyfemtet/opt/visualization/result_viewer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
139
138
|
pyfemtet/opt/visualization/result_viewer/application.py,sha256=WcHBx_J5eNLKSaprpk9BGifwhO04oN8FiNGYTWorrXA,1691
|
|
140
139
|
pyfemtet/opt/visualization/result_viewer/pages.py,sha256=zcsRmVpVK7xbmOpnKkSypNPsRyHcV3ingfNmuqln6nw,32171
|
|
141
|
-
pyfemtet-0.8.
|
|
142
|
-
pyfemtet-0.8.
|
|
143
|
-
pyfemtet-0.8.
|
|
144
|
-
pyfemtet-0.8.
|
|
145
|
-
pyfemtet-0.8.
|
|
140
|
+
pyfemtet-0.8.4.dist-info/LICENSE,sha256=sVQBhyoglGJUu65-BP3iR6ujORI6YgEU2Qm-V4fGlOA,1485
|
|
141
|
+
pyfemtet-0.8.4.dist-info/METADATA,sha256=gm8_jNbFddbgs4cCz1XchxJDMSfcTlBn-GHxCu0ikrE,3509
|
|
142
|
+
pyfemtet-0.8.4.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
|
|
143
|
+
pyfemtet-0.8.4.dist-info/entry_points.txt,sha256=ZfYqRaoiPtuWqFi2_msccyrVF0LurMn-IHlYamAegZo,104
|
|
144
|
+
pyfemtet-0.8.4.dist-info/RECORD,,
|
pyfemtet/_imports.py
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import types
|
|
2
|
-
import importlib
|
|
3
|
-
from typing import TYPE_CHECKING, Any
|
|
4
|
-
from abc import ABCMeta
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
__all__ = [
|
|
8
|
-
'isinstance_wrapper',
|
|
9
|
-
'_LazyImport',
|
|
10
|
-
'_lazy_class_factory',
|
|
11
|
-
]
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
class _MetaClass(ABCMeta):
|
|
15
|
-
__original_cls__: type
|
|
16
|
-
|
|
17
|
-
def __repr__(self):
|
|
18
|
-
if hasattr(self, '__original_cls__'):
|
|
19
|
-
return f'<LazyClass of {self.__original_cls__()}>'
|
|
20
|
-
else:
|
|
21
|
-
return f'<LazyClass of <unloaded class>>'
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
def _lazy_class_factory(module, cls_name):
|
|
25
|
-
class LazyClass(object, metaclass=_MetaClass):
|
|
26
|
-
# 継承を正しくコピーできていないので
|
|
27
|
-
# issubclass を使う際は注意
|
|
28
|
-
def __new__(cls, *args, **kwargs):
|
|
29
|
-
OriginalClass = cls.__original_cls__()
|
|
30
|
-
self = OriginalClass(*args, **kwargs)
|
|
31
|
-
return self
|
|
32
|
-
|
|
33
|
-
@staticmethod
|
|
34
|
-
def __original_cls__():
|
|
35
|
-
return getattr(module, cls_name)
|
|
36
|
-
|
|
37
|
-
return LazyClass
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
class _LazyImport(types.ModuleType):
|
|
41
|
-
"""Module wrapper for lazy import.
|
|
42
|
-
|
|
43
|
-
Note:
|
|
44
|
-
This module is totally derived from `optuna._imports._LazyImport`.
|
|
45
|
-
The following author has the copyright of this code.
|
|
46
|
-
|
|
47
|
-
*******************************************
|
|
48
|
-
Copyright (c) 2018 Preferred Networks, Inc.
|
|
49
|
-
*******************************************
|
|
50
|
-
|
|
51
|
-
This class wraps the specified modules and lazily imports them only when accessed.
|
|
52
|
-
Otherwise, `import optuna` is slowed down by importing all submodules and
|
|
53
|
-
dependencies even if not required.
|
|
54
|
-
Within this project's usage, importlib override this module's attribute on the first
|
|
55
|
-
access and the imported submodule is directly accessed from the second access.
|
|
56
|
-
|
|
57
|
-
Args:
|
|
58
|
-
name: Name of module to apply lazy import.
|
|
59
|
-
"""
|
|
60
|
-
|
|
61
|
-
def __init__(self, name: str) -> None:
|
|
62
|
-
super().__init__(name)
|
|
63
|
-
self._name = name
|
|
64
|
-
|
|
65
|
-
def _load(self) -> types.ModuleType:
|
|
66
|
-
module = importlib.import_module(self._name)
|
|
67
|
-
self.__dict__.update(module.__dict__)
|
|
68
|
-
return module
|
|
69
|
-
|
|
70
|
-
def __getattr__(self, item: str) -> Any:
|
|
71
|
-
return getattr(self._load(), item)
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
def isinstance_wrapper(obj: object, cls: type) -> bool:
|
|
75
|
-
if isinstance(cls, _MetaClass):
|
|
76
|
-
try:
|
|
77
|
-
cls_ = cls.__original_cls__()
|
|
78
|
-
except ModuleNotFoundError:
|
|
79
|
-
return False
|
|
80
|
-
return isinstance(obj, cls_)
|
|
81
|
-
else:
|
|
82
|
-
return isinstance(obj, cls)
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if __name__ == '__main__':
|
|
86
|
-
if TYPE_CHECKING:
|
|
87
|
-
# for type check only
|
|
88
|
-
import numpy
|
|
89
|
-
NDArray = numpy.ndarray
|
|
90
|
-
import no_module
|
|
91
|
-
else:
|
|
92
|
-
# runtime
|
|
93
|
-
numpy = _LazyImport('numpy')
|
|
94
|
-
NDArray = _lazy_class_factory(numpy, 'ndarray')
|
|
95
|
-
NDArray2 = _lazy_class_factory(numpy, 'ndarray')
|
|
96
|
-
no_module = _LazyImport('no_module')
|
|
97
|
-
NoClass = _lazy_class_factory(no_module, 'NoClass')
|
|
98
|
-
|
|
99
|
-
print('numpy is loaded:', numpy.__doc__ is not None)
|
|
100
|
-
a = NDArray(shape=[1])
|
|
101
|
-
print('numpy is loaded:', numpy.__doc__ is not None)
|
|
102
|
-
|
|
103
|
-
print(f"{isinstance(None, NoClass)=}")
|
|
104
|
-
print(f"{isinstance_wrapper(None, NoClass)=}")
|
|
105
|
-
print(f"{isinstance(a, NDArray)=}")
|
|
106
|
-
print(f"{isinstance_wrapper(a, NDArray)=}")
|
|
107
|
-
print(f"{isinstance_wrapper(a, NoClass)=}")
|
|
108
|
-
print(f"{isinstance_wrapper(a, NDArray2)=}")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|