psevencore 2024.3.21__py2.py3-none-win_amd64.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.
Files changed (170) hide show
  1. da/__init__.py +194 -0
  2. da/p7core_2024_3_21/FindNative.py +215 -0
  3. da/p7core_2024_3_21/__init__.py +59 -0
  4. da/p7core_2024_3_21/archives.py +137 -0
  5. da/p7core_2024_3_21/batch/__init__.py +17 -0
  6. da/p7core_2024_3_21/batch/batch_manager.py +969 -0
  7. da/p7core_2024_3_21/batch/command.py +735 -0
  8. da/p7core_2024_3_21/batch/utils.py +48 -0
  9. da/p7core_2024_3_21/bin/windows-x64/generic_tools-2024.3.21-windows-x64-vc12-s.dll +4 -0
  10. da/p7core_2024_3_21/bin/windows-x64/gtmodel-2024.3.21-windows-x64-vc12-s.dll +0 -0
  11. da/p7core_2024_3_21/bin/windows-x64/vcomp120.dll +0 -0
  12. da/p7core_2024_3_21/blackbox.py +795 -0
  13. da/p7core_2024_3_21/examples/__init__.py +4 -0
  14. da/p7core_2024_3_21/examples/example_joint_usage.py +232 -0
  15. da/p7core_2024_3_21/examples/gtapprox/EvaluateGTModel.java +199 -0
  16. da/p7core_2024_3_21/examples/gtapprox/__init__.py +4 -0
  17. da/p7core_2024_3_21/examples/gtapprox/example_adaptive_doe.py +104 -0
  18. da/p7core_2024_3_21/examples/gtapprox/example_additive_gp.py +234 -0
  19. da/p7core_2024_3_21/examples/gtapprox/example_axis_rotations.py +279 -0
  20. da/p7core_2024_3_21/examples/gtapprox/example_export_to_c.py +228 -0
  21. da/p7core_2024_3_21/examples/gtapprox/example_get_validity_domain.py +322 -0
  22. da/p7core_2024_3_21/examples/gtapprox/example_gtapprox.py +74 -0
  23. da/p7core_2024_3_21/examples/gtapprox/example_gtmodel.c +200 -0
  24. da/p7core_2024_3_21/examples/gtapprox/example_internal_validation.py +89 -0
  25. da/p7core_2024_3_21/examples/gtapprox/example_memory_control.py +134 -0
  26. da/p7core_2024_3_21/examples/gtapprox/example_moa_basic.py +116 -0
  27. da/p7core_2024_3_21/examples/gtapprox/example_moa_discontinuous_func.py +161 -0
  28. da/p7core_2024_3_21/examples/gtapprox/example_output_variances.py +392 -0
  29. da/p7core_2024_3_21/examples/gtapprox/example_shap.ipynb +861 -0
  30. da/p7core_2024_3_21/examples/gtapprox/example_smart_selection.py +89 -0
  31. da/p7core_2024_3_21/examples/gtapprox/example_smart_selection_quality_level.py +66 -0
  32. da/p7core_2024_3_21/examples/gtapprox/example_tensor_approx.py +165 -0
  33. da/p7core_2024_3_21/examples/gtdf/__init__.py +4 -0
  34. da/p7core_2024_3_21/examples/gtdf/example_gtdf.py +68 -0
  35. da/p7core_2024_3_21/examples/gtdf/example_gtdf_simple.py +235 -0
  36. da/p7core_2024_3_21/examples/gtdoe/__init__.py +4 -0
  37. da/p7core_2024_3_21/examples/gtdoe/example_gtdoe.py +105 -0
  38. da/p7core_2024_3_21/examples/gtdoe/example_gtdoe_adaptive_grid.py +69 -0
  39. da/p7core_2024_3_21/examples/gtdoe/example_gtdoe_levels.py +59 -0
  40. da/p7core_2024_3_21/examples/gtdoe/example_gtdoe_montecarlo.py +107 -0
  41. da/p7core_2024_3_21/examples/gtdoe/example_gtdoe_multidim_factors.py +50 -0
  42. da/p7core_2024_3_21/examples/gtdr/__init__.py +4 -0
  43. da/p7core_2024_3_21/examples/gtdr/afl_test.csv +2 -0
  44. da/p7core_2024_3_21/examples/gtdr/airfoils.csv +199 -0
  45. da/p7core_2024_3_21/examples/gtdr/example_gtdr.py +211 -0
  46. da/p7core_2024_3_21/examples/gtdr/example_gtdr_airfoil.py +195 -0
  47. da/p7core_2024_3_21/examples/gtopt/__init__.py +4 -0
  48. da/p7core_2024_3_21/examples/gtopt/example_gtopt.py +239 -0
  49. da/p7core_2024_3_21/examples/gtopt/example_gtopt_FDS.py +107 -0
  50. da/p7core_2024_3_21/examples/gtopt/example_gtopt_MOP.py +92 -0
  51. da/p7core_2024_3_21/examples/gtopt/example_gtopt_MOSBO.py +88 -0
  52. da/p7core_2024_3_21/examples/gtopt/example_gtopt_SBO.py +88 -0
  53. da/p7core_2024_3_21/examples/gtopt/example_gtopt_SBO_reuse.py +68 -0
  54. da/p7core_2024_3_21/examples/gtopt/example_gtopt_ZDT1.py +80 -0
  55. da/p7core_2024_3_21/examples/gtopt/example_gtopt_ZDT1_batch.py +108 -0
  56. da/p7core_2024_3_21/examples/gtopt/example_gtopt_ackley_function.py +111 -0
  57. da/p7core_2024_3_21/examples/gtopt/example_gtopt_atc.py +245 -0
  58. da/p7core_2024_3_21/examples/gtopt/example_gtopt_co.py +215 -0
  59. da/p7core_2024_3_21/examples/gtopt/example_gtopt_co_parallel.py +304 -0
  60. da/p7core_2024_3_21/examples/gtopt/example_gtopt_cuter_bt1.py +108 -0
  61. da/p7core_2024_3_21/examples/gtopt/example_gtopt_dfo.py +82 -0
  62. da/p7core_2024_3_21/examples/gtopt/example_gtopt_fitting.py +81 -0
  63. da/p7core_2024_3_21/examples/gtopt/example_gtopt_generic.py +222 -0
  64. da/p7core_2024_3_21/examples/gtopt/example_gtopt_gradients.py +111 -0
  65. da/p7core_2024_3_21/examples/gtopt/example_gtopt_intermediate_result.py +75 -0
  66. da/p7core_2024_3_21/examples/gtopt/example_gtopt_mean_variance.py +138 -0
  67. da/p7core_2024_3_21/examples/gtopt/example_gtopt_mo_small_perturbations.py +147 -0
  68. da/p7core_2024_3_21/examples/gtopt/example_gtopt_nan_problem.py +117 -0
  69. da/p7core_2024_3_21/examples/gtopt/example_gtopt_rdo.py +87 -0
  70. da/p7core_2024_3_21/examples/gtopt/example_gtopt_robust_sbo.py +171 -0
  71. da/p7core_2024_3_21/examples/gtopt/example_gtopt_rosenbrock.py +138 -0
  72. da/p7core_2024_3_21/examples/gtopt/example_gtopt_rosenbrock_noisy.py +107 -0
  73. da/p7core_2024_3_21/examples/gtopt/example_gtopt_triangle.py +121 -0
  74. da/p7core_2024_3_21/examples/gtsda/TAXI2000.csv +2000 -0
  75. da/p7core_2024_3_21/examples/gtsda/__init__.py +4 -0
  76. da/p7core_2024_3_21/examples/gtsda/example_gtsda_checker_partial.py +101 -0
  77. da/p7core_2024_3_21/examples/gtsda/example_gtsda_checker_plots.py +157 -0
  78. da/p7core_2024_3_21/examples/gtsda/example_gtsda_checker_simple.py +88 -0
  79. da/p7core_2024_3_21/examples/gtsda/example_gtsda_ranker_screening.py +37 -0
  80. da/p7core_2024_3_21/examples/gtsda/example_gtsda_ranker_simple.py +105 -0
  81. da/p7core_2024_3_21/examples/gtsda/example_gtsda_ranker_sobol.py +36 -0
  82. da/p7core_2024_3_21/examples/gtsda/example_gtsda_ranker_taguchi.py +48 -0
  83. da/p7core_2024_3_21/examples/gtsda/example_gtsda_selector_simple.py +97 -0
  84. da/p7core_2024_3_21/examples/stat/__init__.py +4 -0
  85. da/p7core_2024_3_21/examples/stat/example_robust_covariance.py +95 -0
  86. da/p7core_2024_3_21/exceptions.py +110 -0
  87. da/p7core_2024_3_21/gtapprox/__init__.py +168 -0
  88. da/p7core_2024_3_21/gtapprox/build_manager.py +3318 -0
  89. da/p7core_2024_3_21/gtapprox/builder.py +3004 -0
  90. da/p7core_2024_3_21/gtapprox/cluster.py +661 -0
  91. da/p7core_2024_3_21/gtapprox/core_ic.py +777 -0
  92. da/p7core_2024_3_21/gtapprox/dependencies.py +1520 -0
  93. da/p7core_2024_3_21/gtapprox/details.py +239 -0
  94. da/p7core_2024_3_21/gtapprox/features_ic.py +339 -0
  95. da/p7core_2024_3_21/gtapprox/iterative_iv.py +196 -0
  96. da/p7core_2024_3_21/gtapprox/moa_preprocessing.py +240 -0
  97. da/p7core_2024_3_21/gtapprox/model.py +2243 -0
  98. da/p7core_2024_3_21/gtapprox/sbo_opt_problem.py +2669 -0
  99. da/p7core_2024_3_21/gtapprox/smart_selection.py +552 -0
  100. da/p7core_2024_3_21/gtapprox/smart_selection_utilities.py +513 -0
  101. da/p7core_2024_3_21/gtapprox/smoothing.py +364 -0
  102. da/p7core_2024_3_21/gtapprox/split_sample.py +1093 -0
  103. da/p7core_2024_3_21/gtapprox/technique_selection.py +2319 -0
  104. da/p7core_2024_3_21/gtapprox/tpe.py +200 -0
  105. da/p7core_2024_3_21/gtapprox/train.py +444 -0
  106. da/p7core_2024_3_21/gtapprox/utilities.py +1594 -0
  107. da/p7core_2024_3_21/gtdf/__init__.py +26 -0
  108. da/p7core_2024_3_21/gtdf/builder.py +1031 -0
  109. da/p7core_2024_3_21/gtdf/model.py +1498 -0
  110. da/p7core_2024_3_21/gtdoe/__init__.py +20 -0
  111. da/p7core_2024_3_21/gtdoe/adaptive_fill.py +148 -0
  112. da/p7core_2024_3_21/gtdoe/adaptive_lhs.py +367 -0
  113. da/p7core_2024_3_21/gtdoe/api.py +516 -0
  114. da/p7core_2024_3_21/gtdoe/fractional_factorial.py +338 -0
  115. da/p7core_2024_3_21/gtdoe/generator.py +2360 -0
  116. da/p7core_2024_3_21/gtdoe/measures.py +276 -0
  117. da/p7core_2024_3_21/gtdoe/orthogonal_array.py +780 -0
  118. da/p7core_2024_3_21/gtdoe/utils.py +50 -0
  119. da/p7core_2024_3_21/gtdr/__init__.py +133 -0
  120. da/p7core_2024_3_21/gtdr/builder.py +685 -0
  121. da/p7core_2024_3_21/gtdr/model.py +1043 -0
  122. da/p7core_2024_3_21/gtopt/__init__.py +16 -0
  123. da/p7core_2024_3_21/gtopt/api.py +1611 -0
  124. da/p7core_2024_3_21/gtopt/diagnostic.py +83 -0
  125. da/p7core_2024_3_21/gtopt/nevergrad_wrapper.py +1513 -0
  126. da/p7core_2024_3_21/gtopt/problem.py +4580 -0
  127. da/p7core_2024_3_21/gtopt/solver.py +1411 -0
  128. da/p7core_2024_3_21/gtopt/utils.py +505 -0
  129. da/p7core_2024_3_21/gtsda/__init__.py +13 -0
  130. da/p7core_2024_3_21/gtsda/analyzer.py +1079 -0
  131. da/p7core_2024_3_21/gtsda/checker.py +1295 -0
  132. da/p7core_2024_3_21/gtsda/ranker.py +1888 -0
  133. da/p7core_2024_3_21/gtsda/selector.py +998 -0
  134. da/p7core_2024_3_21/gtsda/utils.py +172 -0
  135. da/p7core_2024_3_21/include/GTModel/GTApproxModel.h +738 -0
  136. da/p7core_2024_3_21/include/GTModel/GTModelDefs.h +37 -0
  137. da/p7core_2024_3_21/include/GTModel/GTModelError.h +33 -0
  138. da/p7core_2024_3_21/java/gtmodel.jar +0 -0
  139. da/p7core_2024_3_21/java/gtmodel_jni-2024.3.21-windows-x64-vc12-s.dll +0 -0
  140. da/p7core_2024_3_21/license.py +82 -0
  141. da/p7core_2024_3_21/loggers.py +146 -0
  142. da/p7core_2024_3_21/options.py +312 -0
  143. da/p7core_2024_3_21/parameters.py +134 -0
  144. da/p7core_2024_3_21/result.py +2105 -0
  145. da/p7core_2024_3_21/shared.py +2446 -0
  146. da/p7core_2024_3_21/six.py +1007 -0
  147. da/p7core_2024_3_21/stat/__init__.py +12 -0
  148. da/p7core_2024_3_21/stat/analyzer.py +337 -0
  149. da/p7core_2024_3_21/stat/outlier_detection.py +903 -0
  150. da/p7core_2024_3_21/stat/statistics.py +442 -0
  151. da/p7core_2024_3_21/stat/tests.py +218 -0
  152. da/p7core_2024_3_21/stat/utilities.py +471 -0
  153. da/p7core_2024_3_21/status.py +121 -0
  154. da/p7core_2024_3_21/utils/__init__.py +19 -0
  155. da/p7core_2024_3_21/utils/abc.py +40 -0
  156. da/p7core_2024_3_21/utils/bbconverter.py +709 -0
  157. da/p7core_2024_3_21/utils/bit_length.py +21 -0
  158. da/p7core_2024_3_21/utils/buildinfo.py +30 -0
  159. da/p7core_2024_3_21/utils/cluster_utils.py +314 -0
  160. da/p7core_2024_3_21/utils/designs.py +849 -0
  161. da/p7core_2024_3_21/utils/distributions.py +303 -0
  162. da/p7core_2024_3_21/utils/gmm.py +555 -0
  163. da/p7core_2024_3_21/utils/k_means.py +601 -0
  164. da/p7core_2024_3_21/utils/linalg.py +280 -0
  165. da/p7core_2024_3_21/watchers.py +15 -0
  166. pSevenCore-2024.3.21.dist-info/LICENSE +928 -0
  167. pSevenCore-2024.3.21.dist-info/METADATA +1019 -0
  168. pSevenCore-2024.3.21.dist-info/RECORD +170 -0
  169. pSevenCore-2024.3.21.dist-info/WHEEL +6 -0
  170. pSevenCore-2024.3.21.dist-info/top_level.txt +1 -0
da/__init__.py ADDED
@@ -0,0 +1,194 @@
1
+ #
2
+ # coding: utf-8
3
+ # Copyright (C) pSeven SAS, 2010-present
4
+ #
5
+
6
+ """
7
+ Init script for group of projects with version support.
8
+
9
+ This '__init__' script is intended to handle namespace-like package that in general combines different
10
+ projects - subpackages. Such subprojects may reside in different directories. Moreover there can be different
11
+ versions of single project. In any case this script will initialize multi directory package, will find the most
12
+ recent versions of existing subprojects and will initialize the routine which will import latest subproject if the
13
+ version is not explicitly specified.
14
+
15
+ It is much simpler to illustrate by an example.
16
+
17
+ Consider we have the following directories located in different places and each 'group' dir is pointed by the PYTHONPATH.
18
+
19
+ - A/group/prj1_1_0_0 # project 1 version 1.0.0
20
+ /prj2_1_0_0 # project 2 version 1.0.0
21
+ /__init__.py # this '__init__.py' file
22
+ - B/group/prj1_1_0_1 # project 1 version 1.0.1
23
+ /__init__.py # this '__init__.py' file
24
+
25
+ In that case we will get desired behaviour - latest versions will be imported by default:
26
+
27
+ > from group import prj1
28
+ > print prj1
29
+ <module 'group.prj1_1_0_1' from '../B/group/prj1_1_0_1/__init__.pyc'>
30
+
31
+ > from group import prj2
32
+ > print prj2
33
+ <module 'group.prj2_1_x_x' from '../C/group/prj2_1_x_x/__init__.pyc'>
34
+
35
+ At the same time you can explicitly import some particular version:
36
+ > from group import prj1_1_0_0
37
+ > print prj1_1_0_0
38
+ <module 'group.prj1_1_0_0' from '../A/group/prj1_1_0_0/__init__.pyc'>
39
+
40
+ Typically, the 'group' in the example above is the company name or some metaproject name.
41
+
42
+ We assume that subpackages have the following naming scheme: '<package_name>_<version>',
43
+ where 'version' starts with a digit, and 'package_name' does not contain any digit with a preceding underscore.
44
+ """
45
+
46
+ # add to the package's __path__ all subdirectories of directories on sys.path named after the package
47
+ from __future__ import with_statement
48
+
49
+ __path__ = __import__("pkgutil").extend_path(__path__, __name__)
50
+
51
+ class _pSevenModuleHook(object):
52
+ class _LegacyLoader(object):
53
+ def __init__(self, module_path, module_code):
54
+ self.module_path = module_path
55
+ self.module_code = module_code
56
+
57
+ def load_module(self, fullname):
58
+ import sys
59
+
60
+ new_module = None
61
+
62
+ try:
63
+ import os
64
+ import imp
65
+
66
+ if fullname not in sys.modules:
67
+ new_module = imp.new_module(fullname)
68
+ sys.modules[fullname] = new_module
69
+
70
+ module = sys.modules.get(fullname)
71
+ module.__file__ = os.path.join(self.module_path, "__init__.py")
72
+ module.__name__ = fullname
73
+ module.__path__ = [self.module_path]
74
+ module.__loader__ = self
75
+ module.__package__ = fullname
76
+
77
+ exec(self.module_code, module.__dict__)
78
+
79
+ return module
80
+ except:
81
+ exc_value = sys.exc_info()[1]
82
+
83
+ if new_module is not None:
84
+ sys.modules.pop(fullname, None)
85
+
86
+ raise ImportError(exc_value)
87
+
88
+ def __init__(self, root_name):
89
+ self._root_name = root_name
90
+ self._modules = {}
91
+
92
+ def __repr__(self):
93
+ return "pSeven Core Package Finder"
94
+
95
+ def _append(self, fullname, dirname):
96
+ self._modules[self._root_name + "." + fullname] = dirname
97
+
98
+ def find_spec(self, fullname, path, target=None):
99
+ # The modern spec-based module finder.
100
+ origin_module = self._modules.get(fullname)
101
+ if not path or not origin_module:
102
+ return None
103
+
104
+ import os
105
+ from importlib.util import spec_from_file_location
106
+
107
+ for module_dir in path:
108
+ try:
109
+ module_path = os.path.join(module_dir, origin_module)
110
+ module_init = os.path.join(module_path, "__init__.py")
111
+ if os.path.exists(module_init):
112
+ return spec_from_file_location(name=fullname, location=module_init, submodule_search_locations=[module_path])
113
+ except:
114
+ pass
115
+
116
+ return None
117
+
118
+ def find_module(self, fullname, path):
119
+ # Good old PEP 302 module finder
120
+ if not path:
121
+ return None
122
+
123
+ origin_module = self._modules.get(fullname)
124
+ if not origin_module:
125
+ return None
126
+
127
+ try:
128
+ import os
129
+
130
+ for module_dir in path:
131
+ module_path = os.path.join(module_dir, origin_module)
132
+ try:
133
+ with open(os.path.join(module_path, "__init__.py"), "r") as fid:
134
+ module_code = fid.read(-1)
135
+ return self._LegacyLoader(module_path, module_code)
136
+ except:
137
+ pass
138
+ except:
139
+ pass
140
+
141
+ return None
142
+
143
+
144
+ def initialize_current_package():
145
+ def _optional_int(value):
146
+ try:
147
+ return int(value)
148
+ except:
149
+ pass
150
+ return value
151
+
152
+ import sys
153
+ import pkgutil
154
+ import re
155
+
156
+ versions = {}
157
+ loaders = {}
158
+ re_name = re.compile(r"^([A-Za-z0-9_]+?)_([0-9x]+.*)$")
159
+
160
+ finder = _pSevenModuleHook(__name__)
161
+
162
+ # iterate through all the subpackages located inside package directories
163
+ for _, name_with_version, _ in pkgutil.iter_modules(__path__):
164
+ try:
165
+ # skip subpackages/submodules which names do not correspond to the naming rule
166
+ match = re_name.match(name_with_version)
167
+ if match is None:
168
+ continue
169
+
170
+ version = tuple(_optional_int(_) for _ in match.group(2).split('_'))
171
+
172
+ for basename in (match.group(1), "macros"):
173
+ finder._append(basename + "_" + match.group(2), name_with_version)
174
+
175
+ # collect information about the latest version
176
+ if versions.get(basename, (0,0,0)) <= version:
177
+ versions[basename] = version
178
+ loaders[basename] = name_with_version
179
+ except:
180
+ pass
181
+
182
+ # install import hooks, which will handle the latest version as the default version
183
+ for basename in loaders:
184
+ finder._append(basename, loaders[basename])
185
+
186
+ sys.meta_path.append(finder)
187
+
188
+ initialize_current_package()
189
+
190
+ # cleanup the namespace
191
+ del initialize_current_package
192
+ del with_statement
193
+ del _pSevenModuleHook
194
+
@@ -0,0 +1,215 @@
1
+ #
2
+ # coding: utf-8
3
+ # Copyright (C) pSeven SAS, 2010-present
4
+ #
5
+
6
+ """Supplementary python functions."""
7
+
8
+ import sys
9
+ import os
10
+ import platform
11
+ import re
12
+ import ctypes
13
+
14
+ def _platformInfo():
15
+ """Get platform info."""
16
+ (sysname, nodename, release, version, machine, processor) = platform.uname()
17
+
18
+ try:
19
+ machine = 'x64' if ctypes.sizeof(ctypes.c_void_p) > 4 else 'x86'
20
+ except:
21
+ machine = 'x64' if platform.architecture()[0] == '64bit' else 'x86'
22
+
23
+ suffix = str()
24
+ if sysname == 'Linux':
25
+ suffix = 'so'
26
+ elif sysname == 'Windows':
27
+ suffix = 'dll'
28
+ else:
29
+ raise Exception('Unsupported system!')
30
+ return sysname.lower(), machine, suffix
31
+
32
+
33
+ def _searchLib(libname, libpath, platform_info=None):
34
+ """Searches specific directory for a native library with platform-dependent name.
35
+
36
+ :param libname: library basename
37
+ :param libpath: path to look in
38
+ :param platform_info: (optional) platform tuple (sysname, machine, suffix)
39
+ """
40
+ try:
41
+ sysname, machine, suffix = _platformInfo() if platform_info is None else platform_info
42
+ return sorted([os.path.join(libpath, fname) for fname in os.listdir(libpath) \
43
+ if re.match(r'^(lib)?%s-2024.3.21-%s-%s-[^-]+(-s)?(-dbg)?\.%s$' % (libname, sysname, machine, suffix), fname) != None], \
44
+ reverse=True)
45
+ except OSError:
46
+ return []
47
+
48
+
49
+ def _searchPy(libname, libpath):
50
+ """Searches specific directory for a python module.
51
+
52
+ :param libname: module name
53
+ :param libpath: path to look in
54
+ """
55
+ try:
56
+ files = os.listdir(libpath)
57
+ files = list([f for f in files if ('%s.py' % libname) == f])
58
+ except OSError:
59
+ files = []
60
+ return libpath if files else None
61
+
62
+ def _searchPyDir(dirname, libpath):
63
+ """Searches specific directory for a python package.
64
+
65
+ :param dirname: package name
66
+ :param libpath: path to look in
67
+ """
68
+ try:
69
+ entities = [os.path.join(libpath, fpath) for fpath in os.listdir(libpath) if fpath == dirname]
70
+ entities = [fpath for fpath in entities if os.path.isdir(fpath)]
71
+ except OSError:
72
+ entities = []
73
+ return libpath if entities else None
74
+
75
+
76
+ def appendModulePath(libname, prefix=None, maxLevel=4, root=None):
77
+ """Searches for a "libname" python module in any 'python' directories.
78
+
79
+ The search starts from root (from __file__ parent directory if none provided) and up + in current directory.
80
+ :param libname: module name
81
+ :param prefix: additional prefix to bin/lib directories
82
+ :param maxLevel: maximum 'steps' up the directory tree
83
+ :param root: start search from here
84
+ """
85
+ if not root:
86
+ root = os.path.dirname(os.path.realpath(__file__))
87
+
88
+ pdir = _searchPy(libname, root)
89
+ if prefix and not pdir:
90
+ searchpath = os.path.join(root, prefix)
91
+ pdir = _searchPy(libname, searchpath)
92
+
93
+ currentRoot = root
94
+ currentLevel = 0
95
+ while not pdir and (currentLevel < maxLevel):
96
+ pdir = _searchPy(libname, os.path.join(currentRoot, 'python'))
97
+ if prefix and not pdir:
98
+ searchpath = os.path.join(currentRoot, prefix)
99
+ pdir = _searchPy(libname, os.path.join(searchpath, 'python'))
100
+ try:
101
+ currentRoot = os.path.split(currentRoot)[0]
102
+ except:
103
+ break
104
+ currentLevel = currentLevel + 1
105
+ if not pdir:
106
+ raise Exception('Cannot find "%s" python module!' % libname)
107
+ sys.path.append(pdir)
108
+
109
+
110
+ def appendPackagePath(libname, prefix=None, maxLevel=4, root=None):
111
+ """Searches for a "libname" python package in any 'python' directories.
112
+
113
+ The search starts from root (from __file__ parent directory if none provided) and up + in current directory.
114
+ :param libname: module name
115
+ :param prefix: additional prefix to bin/lib directories
116
+ :param maxLevel: maximum 'steps' up the directory tree
117
+ :param root: start search from here
118
+ """
119
+ if not root:
120
+ root = os.path.dirname(os.path.realpath(__file__))
121
+ pdir = _searchPyDir(libname, root)
122
+
123
+ if prefix and not pdir:
124
+ searchpath = os.path.join(root, prefix)
125
+ pdir = _searchPyDir(libname, searchpath)
126
+
127
+ currentRoot = root
128
+ currentLevel = 0
129
+ while not pdir and (currentLevel < maxLevel):
130
+ pdir = _searchPyDir(libname, os.path.join(currentRoot, 'python'))
131
+ if prefix and not pdir:
132
+ searchpath = os.path.join(currentRoot, prefix)
133
+ pdir = _searchPyDir(libname, searchpath)
134
+ try:
135
+ currentRoot = os.path.split(currentRoot)[0]
136
+ except:
137
+ break
138
+ currentLevel = currentLevel + 1
139
+ if not pdir:
140
+ raise Exception('Cannot find "%s" python package!' % libname)
141
+ sys.path.append(pdir)
142
+
143
+
144
+ def loadNativeLib(libname, prefix=None, maxLevel=4, root=None):
145
+ """Search for a "libname" native library in any 'bin' and 'lib' directories.
146
+
147
+ The search starts from root (from __file__ parent directory if none provided) and up + in current directory.
148
+
149
+ .. note::
150
+
151
+ Requires ctypes!
152
+
153
+ :param libname: module name
154
+ :param prefix: additional prefix to bin/lib directories
155
+ :param maxLevel: maximum 'steps' up the directory tree
156
+ :param root: start search from here
157
+ """
158
+ if not root:
159
+ root = os.path.dirname(os.path.realpath(__file__))
160
+
161
+ def search_libs(root, platform_info):
162
+ libs = _searchLib(libname, root, platform_info)
163
+ if prefix and not libs:
164
+ searchpath = os.path.join(root, prefix)
165
+ libs = _searchLib(libname, searchpath)
166
+ currentRoot = root
167
+
168
+ currentLevel = 0
169
+ def scanlibpaths(searchpath):
170
+ libs = _searchLib(libname, os.path.join(searchpath, 'lib'), platform_info)
171
+ if not libs:
172
+ libs = _searchLib(libname, os.path.join(searchpath, 'bin'), platform_info)
173
+ if not libs:
174
+ libs = _searchLib(libname, os.path.join(searchpath, 'bin', sysname + '-' + machine), platform_info)
175
+ return libs
176
+
177
+ while not libs and (currentLevel < maxLevel):
178
+ libs = scanlibpaths(currentRoot)
179
+ if not libs and prefix:
180
+ libs = scanlibpaths(os.path.join(currentRoot, prefix))
181
+ try:
182
+ currentRoot = os.path.split(currentRoot)[0]
183
+ except:
184
+ break
185
+ currentLevel = currentLevel + 1
186
+ return libs
187
+
188
+ sysname, machine, suffix = _platformInfo()
189
+ libs = search_libs(root, (sysname, machine, suffix))
190
+
191
+ if not libs:
192
+ raise Exception('Cannot find "%s" native library!' % libname)
193
+
194
+ library = None
195
+
196
+ try:
197
+ origCwd = os.getcwdu()
198
+ except AttributeError:
199
+ origCwd = os.getcwd()
200
+
201
+ for lib in libs:
202
+ try:
203
+ os.chdir(os.path.dirname(lib))
204
+ try:
205
+ library = ctypes.CDLL(lib)
206
+ if library:
207
+ message = 'Loaded "%s" library at path "%s"' % (libname, lib)
208
+ break
209
+ except:
210
+ pass
211
+ finally:
212
+ os.chdir(origCwd)
213
+ if not library:
214
+ message = 'No loaded "%s" library' % libname
215
+ return library, message
@@ -0,0 +1,59 @@
1
+ #
2
+ # coding: utf-8
3
+ # Copyright (C) pSeven SAS, 2010-present
4
+ #
5
+
6
+ """pSeven Core package."""
7
+
8
+ __version__ = "2024.3.21"
9
+
10
+ import numpy
11
+ import ctypes as _ctypes
12
+ import atexit as _atexit
13
+
14
+ def _distutils_loose_version(vstring):
15
+ import re
16
+ vlist = []
17
+ for c in re.split(r'(\d+ | [a-z]+ | \.)', str(vstring), flags=re.VERBOSE):
18
+ if c and c != '.':
19
+ try:
20
+ c = int(c)
21
+ except:
22
+ pass
23
+ vlist.append(c)
24
+ return tuple(vlist)
25
+
26
+ if _distutils_loose_version(numpy.version.version) < (1,6,0):
27
+ raise Exception('The detected version of numpy is %s. NumPy version 1.6.0 or newer is required to run pSeven Core.' % (numpy.version.version))
28
+
29
+ from . import FindNative as _FindNative
30
+ _FindNative._library, _FindNative._library_welcome_message = _FindNative.loadNativeLib('generic_tools')
31
+ if not _FindNative._library:
32
+ raise RuntimeError('Failed to load "generic_tools" backend library.')
33
+
34
+ _ctypes.CFUNCTYPE(_ctypes.c_void_p)(("GTWarmUp", _FindNative._library))()
35
+
36
+ _shutdown = _ctypes.CFUNCTYPE(_ctypes.c_void_p)(("GTShutDown", _FindNative._library))
37
+ _atexit.register(_shutdown)
38
+
39
+ from . import shared as _shared
40
+ from .options import Options
41
+ from .license import License
42
+ from .parameters import Parameters
43
+ from .exceptions import Exception, GTException, XTException, InvalidOptionsError, InvalidOptionNameError,\
44
+ InvalidOptionValueError, InvalidProblemError, FeatureNotAvailableError, InfeasibleProblemError,\
45
+ UnsupportedProblemError, NanInfError, InternalError, OutOfMemoryError, UserTerminated, WrongUsageError,\
46
+ LicenseError, IllegalStateError, InapplicableTechniqueException, ExceptionWrapper, BBPrepareException,\
47
+ UserEvaluateException, WatcherException, LoggerException
48
+ from . import gtapprox
49
+ from . import gtdf
50
+ from . import gtdoe
51
+ from . import gtdr
52
+ from . import gtsda
53
+ from . import gtopt
54
+ from . import stat
55
+ from .result import Result
56
+
57
+ _NONE = _shared._NONE
58
+
59
+ __all__ = ['gtapprox', 'gtdf', 'gtdoe', 'gtdr', 'gtsda', 'gtopt', 'stat']
@@ -0,0 +1,137 @@
1
+ #
2
+ # coding: utf-8
3
+ # Copyright (C) pSeven SAS, 2010-present
4
+ #
5
+
6
+ from __future__ import with_statement
7
+ from __future__ import division
8
+
9
+ import sys as _sys
10
+ import os as _os
11
+ import time as _time
12
+ import contextlib as _contextlib
13
+ import zipfile as _zipfile
14
+ import tarfile as _tarfile
15
+ import codecs as _codecs
16
+
17
+ from . import shared as _shared
18
+
19
+
20
+ @_contextlib.contextmanager
21
+ def _with_zipfile(file, *args, **kwargs):
22
+ obj = _zipfile.ZipFile(file, *args, **kwargs)
23
+ try:
24
+ yield obj
25
+ finally:
26
+ obj.close()
27
+
28
+ @_contextlib.contextmanager
29
+ def _with_tarfile(file, *args, **kwargs):
30
+ obj = _tarfile.open(file, *args, **kwargs)
31
+ try:
32
+ yield obj
33
+ finally:
34
+ obj.close()
35
+
36
+ def _detect_tar_mode(filename):
37
+ tar_codes = ((".tar", "w"), (".tgz", "w:gz"), (".tar.gz", "w:gz"), (".taz", "w:gz"), (".tbz", "w:bz2"), (".tbz2", "w:bz2"), (".tar.bz2", "w:bz2"))
38
+ for tar_ext, tar_mode in tar_codes:
39
+ ext_pos = -len(tar_ext)
40
+ if filename[ext_pos:].lower() == tar_ext:
41
+ return filename[:ext_pos], tar_mode
42
+ return filename, None
43
+
44
+ class _BasicArchveWriter(object):
45
+ def __init__(self, file_obj):
46
+ self.pending_error = None
47
+ self.file_obj = file_obj
48
+
49
+ def process_exception(self):
50
+ if self.pending_error is None:
51
+ self.pending_error = _sys.exc_info()
52
+
53
+ def flush_callback_exceptions(self, succeeded, model_error):
54
+ if self.pending_error is not None:
55
+ exc_type, exc_val, exc_tb = self.pending_error
56
+ if model_error is not None and model_error[1]:
57
+ exc_val = ("%s The origin of the exception is: %s" % (_shared._safestr(model_error[1]).strip(), _shared._safestr(exc_val).strip())) if exc_val else model_error[1]
58
+ _shared.reraise(exc_type, exc_val, exc_tb)
59
+
60
+ if model_error is not None and model_error[0] is not None:
61
+ raise model_error[0](model_error[1] or ("Failed to save model as zip-compressed multiply %s source files." % ExportedFormat.to_string(format)))
62
+
63
+ class _ZipArchiveWriter(_BasicArchveWriter):
64
+ def __call__(self, archname, bytes):
65
+ try:
66
+ self.file_obj.writestr(_shared._preprocess_utf8(archname), bytes, _zipfile.ZIP_DEFLATED)
67
+ return True
68
+ except:
69
+ self.process_exception()
70
+ return False
71
+
72
+ class _SequentialReader(object):
73
+ def __init__(self, data, size=None):
74
+ self.data = data
75
+ self.size = len(data) if size is None else size
76
+
77
+ def read(self, size=-1):
78
+ size = self.size if (size is None or size < 0) else min(size, self.size)
79
+ data_block = self.data[:size]
80
+ self.data = self.data[size:]
81
+ self.size -= size
82
+ return data_block
83
+
84
+ class _TarArchiveWriter(_BasicArchveWriter):
85
+ def __call__(self, archname, bytes):
86
+ try:
87
+ info = _tarfile.TarInfo(_shared._preprocess_utf8(archname))
88
+ info.size = len(bytes)
89
+ info.mode = 438 # chmod a+rw
90
+ info.mtime = _time.time()
91
+ self.file_obj.addfile(info, _SequentialReader(bytes, info.size))
92
+ return True
93
+ except:
94
+ self.process_exception()
95
+ return False
96
+
97
+ class _DirectoryWriter(_BasicArchveWriter):
98
+ def __init__(self, directory, fixed_filename):
99
+ super(_DirectoryWriter, self).__init__(None)
100
+ self.directory = directory
101
+ self.filename = fixed_filename
102
+
103
+ @staticmethod
104
+ def _create_path(dirname):
105
+ if not dirname or _os.path.exists(dirname):
106
+ return
107
+
108
+ try:
109
+ _os.makedirs(dirname)
110
+ except:
111
+ exc_type, exc_val, exc_tb = _sys.exc_info()
112
+ _shared.reraise(exc_type, ('Failed to create directory "%s": %s' % (dirname, exc_val)), exc_tb)
113
+
114
+ def __call__(self, archname, bytes):
115
+ try:
116
+ archname = _os.path.join(self.directory, _shared._preprocess_utf8(archname))
117
+
118
+ self._create_path(_os.path.split(archname)[0])
119
+ with _codecs.open(self.filename or archname, "w", encoding="utf8") as fobj:
120
+ fobj.write(_shared._preprocess_utf8(bytes))
121
+ return True
122
+ except:
123
+ self.process_exception()
124
+ return False
125
+
126
+ class _MemoryFileWriter(_BasicArchveWriter):
127
+ def __init__(self):
128
+ super(_MemoryFileWriter, self).__init__(None)
129
+ self.files = []
130
+
131
+ def __call__(self, archname, bytes):
132
+ try:
133
+ self.files.append((_shared._preprocess_utf8(archname), _shared._preprocess_utf8(bytes)))
134
+ return True
135
+ except:
136
+ self.process_exception()
137
+ return False
@@ -0,0 +1,17 @@
1
+ #
2
+ # coding: utf-8
3
+ # Copyright (C) pSeven SAS, 2010-present
4
+ #
5
+ # ssh/cluster utils
6
+
7
+ from . batch_manager import BatchJobSpecification, BatchJobStatus, SSHBatchManager
8
+ from . utils import test_ssh_connection
9
+
10
+ __all__ = ['BatchJobSpecification', 'BatchJobStatus', 'SSHBatchManager', 'test_ssh_connection']
11
+
12
+ try:
13
+ # this module is optional while it requires paramiko
14
+ from . command import SSHException, TransportException, TransportAuthenticationException, Command, LocalTransport, SSHTransport
15
+ __all__.extend(('SSHException', 'TransportException', 'TransportAuthenticationException', 'Command', 'LocalTransport', 'SSHTransport'))
16
+ except:
17
+ pass