Subject | Hash | Author | Date (UTC) |
---|---|---|---|
replace flatten() by reshape(-1) everywhere. The former always allocates new array | 97b35c989a5ad8e459bb60133222d50c7f78e1f0 | I am | 2023-01-15 12:04:30 |
qt_gui.qt_gui: explicitly export sample_box to console's namespace | dd2e50245157082ddb645b693a8a8c573215d50c | I am | 2023-01-15 11:42:01 |
replace everywhere np.bool by just bool (it looks like newer numpy dropped it) | ac208f89bbf0ad76d38790686041ea778a9b6376 | I am | 2023-01-15 11:31:56 |
simplex._Triangulation: implement averaged gradients() | f6608597cf490dd6cf1a6af3b7d8e6d0a72732d9 | I am | 2023-01-15 09:37:14 |
add line and two lines problems for sensitivity analysis | 0c620f7960399ed8b34e02d663772d0eb34e66f1 | I am | 2023-01-14 08:30:56 |
simplex.FullCubatureIntegration.get_sensitivities: do not normalize global gradient | c648c484a5599a00236ab70c36cdf407c24f5306 | I am | 2023-01-14 04:51:16 |
simplex: implement sensitivities | 65056319c51fd93deb76ce14e52c08869dfc04a2 | I am | 2023-01-13 11:27:46 |
mplot.maxes: prepare GRaph plot | 68774535915af3deaf6104a0bbe9b3c4d24c0cec | I am | 2023-01-12 02:43:20 |
mplot.mgraph.tri_estimation_plot: use planar vertex estimator | 1d300fa56248be9cdab5a4e5b0d4372f68fd5255 | I am | 2023-01-11 15:48:28 |
mplot.mart: implement lsf_boundary() contouring | 8642d2f0c043f4e71af1cc45b9e25da326afd3ca | I am | 2023-01-11 05:20:00 |
mplot.mart.setup_labels: make labels more adaptive | 60cd0b34a67b38df1c730dddc9e0771139818f33 | I am | 2023-01-11 04:35:47 |
simplex._SamplingTriangulation: self reference fix | 79204ff15cba7c5ca24bb5b48e2073058acf00ae | I am | 2023-01-11 03:21:34 |
testcases.testcases_2D: add pf for rastrigin | 4f3b35fe18496fcb9f59860174c876cb7a82749a | I am | 2023-01-10 23:39:45 |
dicebox.circumtri: fix initialization on ED loading. Use simple potential for space filling | c02656e588a164685c4a750ce865c4b50f716563 | I am | 2023-01-10 23:37:30 |
simplex.FullCubatureIntegration.get_failure_moments: negative probabilities fix | 27dd6bb1e5bb0eb1e28eef88e28913d1eca461da | I am | 2023-01-10 20:16:09 |
add more nD problems from literature | 2380cdbdcf17dd5e0af19506c6f7bb1e838de03b | I am | 2023-01-10 06:13:56 |
f_models: implement Norm class | 698c3216b1c8a0e2d57bfb33340a7ea8758d4e63 | I am | 2023-01-09 23:13:48 |
simplex.FullCabatureIntegration: implement get_failure_moments() | 0742ee3d3932d7c3c0b6bbe6e327c92ced04aedd | I am | 2023-01-09 19:53:55 |
simplex._Triangulation: add get_failure_moments() method | 3e362970b67a50643c1e486729efbf554cacf03f | I am | 2023-01-08 03:26:02 |
simplex: use advanced indexing instead of isin function | 568c8623ad4cfaa343df05ae880d099556037cf0 | I am | 2023-01-06 13:41:00 |
File | Lines added | Lines deleted |
---|---|---|
wellmet/convex_hull.py | 2 | 2 |
wellmet/dicebox/__circumtri.py | 1 | 1 |
wellmet/dicebox/_circumtri.py | 1 | 1 |
wellmet/dicebox/censoring.py | 6 | 6 |
wellmet/dicebox/circumtri.py | 2 | 2 |
wellmet/dicebox/goal.py | 4 | 4 |
wellmet/estimation.py | 5 | 5 |
wellmet/f_models.py | 1 | 1 |
wellmet/mplot/mart.py | 3 | 3 |
wellmet/mplot/mart3d.py | 4 | 4 |
wellmet/qt_gui/gl_plot.py | 1 | 1 |
wellmet/qt_gui/qt_plot.py | 1 | 1 |
wellmet/reader.py | 2 | 2 |
wellmet/samplebox.py | 4 | 2 |
wellmet/voronoi.py | 4 | 5 |
File wellmet/convex_hull.py changed (mode: 100644) (index 0b596c2..4fd7d7e) | |||
... | ... | class DirectHull: | |
636 | 636 | # N=ns, E - number of hyperplane equations | # N=ns, E - number of hyperplane equations |
637 | 637 | ExN = A @ x.T + np.atleast_2d(b).T | ExN = A @ x.T + np.atleast_2d(b).T |
638 | 638 | i = np.argmax(ExN, axis=0) | i = np.argmax(ExN, axis=0) |
639 | d = np.take_along_axis(ExN, np.atleast_2d(i), axis=0).flatten() | ||
639 | d = np.take_along_axis(ExN, np.atleast_2d(i), axis=0).reshape(-1) | ||
640 | 640 | return d, i | return d, i |
641 | 641 | ||
642 | 642 | def is_inside(hull, nodes): | def is_inside(hull, nodes): |
... | ... | class QHull: | |
906 | 906 | # N=ns, E - number of hyperplane equations | # N=ns, E - number of hyperplane equations |
907 | 907 | ExN = A @ x.T + np.atleast_2d(b).T | ExN = A @ x.T + np.atleast_2d(b).T |
908 | 908 | i = np.argmax(ExN, axis=0) | i = np.argmax(ExN, axis=0) |
909 | d = np.take_along_axis(ExN, np.atleast_2d(i), axis=0).flatten() | ||
909 | d = np.take_along_axis(ExN, np.atleast_2d(i), axis=0).reshape(-1) | ||
910 | 910 | return d, i | return d, i |
911 | 911 | else: | else: |
912 | 912 | return DirectHull(self.sample, self.fallback_plan, self.space).query(nodes) | return DirectHull(self.sample, self.fallback_plan, self.space).query(nodes) |
File wellmet/dicebox/__circumtri.py changed (mode: 100644) (index b4b44a3..4d820fc) | |||
... | ... | class CircumTri(_Exploration): | |
255 | 255 | #else: | #else: |
256 | 256 | ||
257 | 257 | nodes_model = getattr(nodes, bx.tri_space) | nodes_model = getattr(nodes, bx.tri_space) |
258 | dr = distance.cdist(nodes_model, [circum_center]).flatten() | ||
258 | dr = distance.cdist(nodes_model, [circum_center]).reshape(-1) | ||
259 | 259 | nodes_pdf = nodes.pdf(bx.tri_space) | nodes_pdf = nodes.pdf(bx.tri_space) |
260 | 260 | node_potentials = (r - dr) * nodes_pdf**(1/bx.nvar) | node_potentials = (r - dr) * nodes_pdf**(1/bx.nvar) |
261 | 261 |
File wellmet/dicebox/_circumtri.py changed (mode: 100644) (index a11e0fb..5f94305) | |||
... | ... | class CircumTri(_Exploration): | |
235 | 235 | if np.any(mask): | if np.any(mask): |
236 | 236 | nodes = nodes[mask] | nodes = nodes[mask] |
237 | 237 | ||
238 | dr = distance.cdist(nodes.G, [circum_center]).flatten() | ||
238 | dr = distance.cdist(nodes.G, [circum_center]).reshape(-1) | ||
239 | 239 | nodes_pdf = nodes.pdf('G') | nodes_pdf = nodes.pdf('G') |
240 | 240 | node_potentials = (r - dr) * nodes_pdf**(1/bx.nvar) | node_potentials = (r - dr) * nodes_pdf**(1/bx.nvar) |
241 | 241 |
File wellmet/dicebox/censoring.py changed (mode: 100644) (index 3d245b8..1df3764) | |||
... | ... | class BlackBox: | |
218 | 218 | ||
219 | 219 | LHS_node = np.empty(bx.nvar, dtype=float) | LHS_node = np.empty(bx.nvar, dtype=float) |
220 | 220 | for i in range(bx.nvar): | for i in range(bx.nvar): |
221 | if to_sample_node.U.flatten()[i] <= bx.sorted_plan_U[i][0]: | ||
221 | if to_sample_node.U.reshape(-1)[i] <= bx.sorted_plan_U[i][0]: | ||
222 | 222 | LHS_node[i] = (bx.sorted_plan_U[i][0] + bx.sorted_plan_U[i][1]) / 2 | LHS_node[i] = (bx.sorted_plan_U[i][0] + bx.sorted_plan_U[i][1]) / 2 |
223 | elif to_sample_node.U.flatten()[i] >= bx.sorted_plan_U[i][-1]: | ||
223 | elif to_sample_node.U.reshape(-1)[i] >= bx.sorted_plan_U[i][-1]: | ||
224 | 224 | LHS_node[i] = (bx.sorted_plan_U[i][-2] + bx.sorted_plan_U[i][-1]) / 2 | LHS_node[i] = (bx.sorted_plan_U[i][-2] + bx.sorted_plan_U[i][-1]) / 2 |
225 | 225 | else: | else: |
226 | plan_index = np.searchsorted(bx.sorted_plan_U[i], to_sample_node.U.flatten()[i]) | ||
226 | plan_index = np.searchsorted(bx.sorted_plan_U[i], to_sample_node.U.reshape(-1)[i]) | ||
227 | 227 | # vzdy | # vzdy |
228 | 228 | LHS_node[i] = (bx.sorted_plan_U[i][plan_index] + bx.sorted_plan_U[i][plan_index - 1]) / 2 | LHS_node[i] = (bx.sorted_plan_U[i][plan_index] + bx.sorted_plan_U[i][plan_index - 1]) / 2 |
229 | 229 | ||
... | ... | class MinEnergyCensoredSampling(Censoring): | |
885 | 885 | # zkontrolujeme co se změnilo | # zkontrolujeme co se změnilo |
886 | 886 | # předpokladám, že se počet simplexů přidaním bodů nezměnší | # předpokladám, že se počet simplexů přidaním bodů nezměnší |
887 | 887 | equal_mask = former_simplices == bx.tri.simplices[:len(former_simplices)] | equal_mask = former_simplices == bx.tri.simplices[:len(former_simplices)] |
888 | changed_simplices_ids = np.argwhere(~equal_mask.all(axis=1)).flatten() | ||
888 | changed_simplices_ids = np.argwhere(~equal_mask.all(axis=1)).reshape(-1) | ||
889 | 889 | ||
890 | 890 | # invalidirujeme jejich odhady | # invalidirujeme jejich odhady |
891 | 891 | for simplex_id in changed_simplices_ids: | for simplex_id in changed_simplices_ids: |
... | ... | class OptimizedCensoredSampling(MinEnergyCensoredSampling): | |
1295 | 1295 | # zkontrolujeme co se změnilo | # zkontrolujeme co se změnilo |
1296 | 1296 | # předpokladám, že se počet simplexů přidaním bodů nezměnší | # předpokladám, že se počet simplexů přidaním bodů nezměnší |
1297 | 1297 | equal_mask = former_simplices == bx.tri.simplices[:len(former_simplices)] | equal_mask = former_simplices == bx.tri.simplices[:len(former_simplices)] |
1298 | changed_simplices_ids = np.argwhere(~equal_mask.all(axis=1)).flatten() | ||
1298 | changed_simplices_ids = np.argwhere(~equal_mask.all(axis=1)).reshape(-1) | ||
1299 | 1299 | ||
1300 | 1300 | # invalidirujeme jejich odhady | # invalidirujeme jejich odhady |
1301 | 1301 | for simplex_id in changed_simplices_ids: | for simplex_id in changed_simplices_ids: |
... | ... | class BlackSimpleX(OptimizedCensoredSampling): | |
1505 | 1505 | # zkontrolujeme co se změnilo | # zkontrolujeme co se změnilo |
1506 | 1506 | # předpokladám, že se počet simplexů přidaním bodů nezměnší | # předpokladám, že se počet simplexů přidaním bodů nezměnší |
1507 | 1507 | equal_mask = former_simplices == bx.tri.simplices[:len(former_simplices)] | equal_mask = former_simplices == bx.tri.simplices[:len(former_simplices)] |
1508 | changed_simplices_ids = np.argwhere(~equal_mask.all(axis=1)).flatten() | ||
1508 | changed_simplices_ids = np.argwhere(~equal_mask.all(axis=1)).reshape(-1) | ||
1509 | 1509 | ||
1510 | 1510 | ||
1511 | 1511 | #č popajem pouze mixy, ty musel jsem spočítat před aktualizací | #č popajem pouze mixy, ty musel jsem spočítat před aktualizací |
File wellmet/dicebox/circumtri.py changed (mode: 100644) (index 55bd26d..e113932) | |||
... | ... | class FullCircumTri(_Exploration): | |
217 | 217 | ||
218 | 218 | # max_node_potential = -np.inf | # max_node_potential = -np.inf |
219 | 219 | # if not bx.circumcenters_only: | # if not bx.circumcenters_only: |
220 | # dr = distance.cdist(nodes.G, [circum_center]).flatten() | ||
220 | # dr = distance.cdist(nodes.G, [circum_center]).reshape(-1) | ||
221 | 221 | # nodes_pdf = nodes.pdf(bx.tri_space) | # nodes_pdf = nodes.pdf(bx.tri_space) |
222 | 222 | # node_potentials = (r - dr)**bx.nvar * nodes_pdf#**bx.psi_q * PDF[i]**(1-bx.psi_q) | # node_potentials = (r - dr)**bx.nvar * nodes_pdf#**bx.psi_q * PDF[i]**(1-bx.psi_q) |
223 | 223 | # | # |
... | ... | class FullCircumTri(_Exploration): | |
280 | 280 | if np.any(mask): | if np.any(mask): |
281 | 281 | nodes = nodes[mask] | nodes = nodes[mask] |
282 | 282 | ||
283 | dr = distance.cdist(nodes.G, [circum_center]).flatten() | ||
283 | dr = distance.cdist(nodes.G, [circum_center]).reshape(-1) | ||
284 | 284 | nodes_pdf = nodes.pdf(bx.tri_space) | nodes_pdf = nodes.pdf(bx.tri_space) |
285 | 285 | #č nejdřív rouška, pak slice. V tomto pořadí numpy to zvladné bez alokací | #č nejdřív rouška, pak slice. V tomto pořadí numpy to zvladné bez alokací |
286 | 286 | i = ii[mask][:,0] | i = ii[mask][:,0] |
File wellmet/dicebox/goal.py changed (mode: 100644) (index b686600..fd1981f) | |||
... | ... | class DiceBox: | |
249 | 249 | ||
250 | 250 | LHS_node = np.empty(bx.nvar, dtype=float) | LHS_node = np.empty(bx.nvar, dtype=float) |
251 | 251 | for i in range(bx.nvar): | for i in range(bx.nvar): |
252 | if to_sample_node.U.flatten()[i] <= bx.sorted_plan_U[i][0]: | ||
252 | if to_sample_node.U.reshape(-1)[i] <= bx.sorted_plan_U[i][0]: | ||
253 | 253 | LHS_node[i] = (bx.sorted_plan_U[i][0] + bx.sorted_plan_U[i][1]) / 2 | LHS_node[i] = (bx.sorted_plan_U[i][0] + bx.sorted_plan_U[i][1]) / 2 |
254 | elif to_sample_node.U.flatten()[i] >= bx.sorted_plan_U[i][-1]: | ||
254 | elif to_sample_node.U.reshape(-1)[i] >= bx.sorted_plan_U[i][-1]: | ||
255 | 255 | LHS_node[i] = (bx.sorted_plan_U[i][-2] + bx.sorted_plan_U[i][-1]) / 2 | LHS_node[i] = (bx.sorted_plan_U[i][-2] + bx.sorted_plan_U[i][-1]) / 2 |
256 | 256 | else: | else: |
257 | plan_index = np.searchsorted(bx.sorted_plan_U[i], to_sample_node.U.flatten()[i]) | ||
257 | plan_index = np.searchsorted(bx.sorted_plan_U[i], to_sample_node.U.reshape(-1)[i]) | ||
258 | 258 | # vzdy | # vzdy |
259 | 259 | LHS_node[i] = (bx.sorted_plan_U[i][plan_index] + bx.sorted_plan_U[i][plan_index - 1]) / 2 | LHS_node[i] = (bx.sorted_plan_U[i][plan_index] + bx.sorted_plan_U[i][plan_index - 1]) / 2 |
260 | 260 | ||
... | ... | class DiceSimpleX: | |
1740 | 1740 | # zkontrolujeme co se změnilo | # zkontrolujeme co se změnilo |
1741 | 1741 | # předpokladám, že se počet simplexů přidaním bodů nezměnší | # předpokladám, že se počet simplexů přidaním bodů nezměnší |
1742 | 1742 | equal_mask = former_simplices == bx.tri.simplices[:len(former_simplices)] | equal_mask = former_simplices == bx.tri.simplices[:len(former_simplices)] |
1743 | changed_simplices_ids = np.argwhere(~equal_mask.all(axis=1)).flatten() | ||
1743 | changed_simplices_ids = np.argwhere(~equal_mask.all(axis=1)).reshape(-1) | ||
1744 | 1744 | ||
1745 | 1745 | ||
1746 | 1746 | #č popajem pouze mixy, ty musel jsem spočítat před aktualizací | #č popajem pouze mixy, ty musel jsem spočítat před aktualizací |
File wellmet/estimation.py changed (mode: 100644) (index 0f2452b..da765e2) | |||
... | ... | def Voronoi_tesselation(sample_box, model_space='Rn', sampling_space=None, p_nor | |
162 | 162 | ||
163 | 163 | # find distance to the nearest sampling point (from all points) | # find distance to the nearest sampling point (from all points) |
164 | 164 | dd2, ii2 = tree_sampling.query(sampled_plan_sing[failure_points], k=[2], p=p_norm) | dd2, ii2 = tree_sampling.query(sampled_plan_sing[failure_points], k=[2], p=p_norm) |
165 | mindist_sing = dd2.flatten() | ||
166 | #ii2 = ii2.flatten() | ||
165 | mindist_sing = dd2.reshape(-1) | ||
166 | #ii2 = ii2.reshape(-1) | ||
167 | 167 | ||
168 | 168 | ||
169 | 169 | ||
... | ... | def Voronoi_2_point_estimation(sample_box, model_space='Rn', sampling_space=None | |
268 | 268 | ||
269 | 269 | # find distance to the nearest sampling point (from all points) | # find distance to the nearest sampling point (from all points) |
270 | 270 | dd2, ii2 = tree_sampling.query(sampled_plan_sing, k=[2], p=p_norm) | dd2, ii2 = tree_sampling.query(sampled_plan_sing, k=[2], p=p_norm) |
271 | mindist_sing = dd2.flatten() | ||
271 | mindist_sing = dd2.reshape(-1) | ||
272 | 272 | ||
273 | 273 | # chcu, aby behem první iterace pulka (p_base) tečiček jistě dopadla do buňky | # chcu, aby behem první iterace pulka (p_base) tečiček jistě dopadla do buňky |
274 | 274 | base_r = sball.Sball(sample_box.nvar).get_r(1 - p_base) | base_r = sball.Sball(sample_box.nvar).get_r(1 - p_base) |
... | ... | def Voronoi_2_point_estimation(sample_box, model_space='Rn', sampling_space=None | |
411 | 411 | ||
412 | 412 | ||
413 | 413 | dd2, ii2 = tree.query(h_plan_model_ma, k=[2], p=p_norm) | dd2, ii2 = tree.query(h_plan_model_ma, k=[2], p=p_norm) |
414 | dd2 = dd2.flatten() | ||
415 | ii2 = ii2.flatten() | ||
414 | dd2 = dd2.reshape(-1) | ||
415 | ii2 = ii2.reshape(-1) | ||
416 | 416 | ||
417 | 417 | # tahle hračka s indexy je pro numpy poměrně drahá | # tahle hračka s indexy je pro numpy poměrně drahá |
418 | 418 | failsii_2 = failsi[ii2] | failsii_2 = failsi[ii2] |
File wellmet/f_models.py changed (mode: 100644) (index 6f430b0..a255b14) | |||
... | ... | class WellMetError(ValueError): | |
19 | 19 | ||
20 | 20 | # alpha atribut beztak veřejný, ale tato funkce ještě provadí normalizaci a kontrolu | # alpha atribut beztak veřejný, ale tato funkce ještě provadí normalizaci a kontrolu |
21 | 21 | def set_alpha(f_model, input_alpha): | def set_alpha(f_model, input_alpha): |
22 | alpha = np.atleast_1d(input_alpha).flatten() | ||
22 | alpha = np.atleast_1d(input_alpha).reshape(-1) | ||
23 | 23 | if len(alpha) != f_model.nvar: | if len(alpha) != f_model.nvar: |
24 | 24 | raise WellMetError | raise WellMetError |
25 | 25 | else: | else: |
File wellmet/mplot/mart.py changed (mode: 100644) (index 061ff90..a621ed0) | |||
... | ... | def rbf_density_colormesh(ax, ngrid=500, **kwargs): | |
380 | 380 | y = np.linspace(ymin, ymax, ngrid, endpoint=True) | y = np.linspace(ymin, ymax, ngrid, endpoint=True) |
381 | 381 | X, Y = np.meshgrid(x, y) | X, Y = np.meshgrid(x, y) |
382 | 382 | ||
383 | XY = np.vstack((X.flatten(), Y.flatten())).T | ||
383 | XY = np.vstack((X.reshape(-1), Y.reshape(-1))).T | ||
384 | 384 | z = ax.sample_box.sample_pdf(XY, ax.space) | z = ax.sample_box.sample_pdf(XY, ax.space) |
385 | 385 | Z = z.reshape(ngrid, ngrid) | Z = z.reshape(ngrid, ngrid) |
386 | 386 | ||
... | ... | def lsf_boundary(ax, ngrid=200, limits=None, **kwargs): | |
472 | 472 | x = np.linspace(xmin, xmax, ngrid) | x = np.linspace(xmin, xmax, ngrid) |
473 | 473 | y = np.linspace(ymin, ymax, ngrid) | y = np.linspace(ymin, ymax, ngrid) |
474 | 474 | X, Y = np.meshgrid(x, y) | X, Y = np.meshgrid(x, y) |
475 | XY = np.vstack((X.flatten(), Y.flatten())).T | ||
475 | XY = np.vstack((X.reshape(-1), Y.reshape(-1))).T | ||
476 | 476 | sb = ax.sample_box.gm(ax.sample_box.f_model.new_sample(XY, space=ax.space)) | sb = ax.sample_box.gm(ax.sample_box.f_model.new_sample(XY, space=ax.space)) |
477 | 477 | Z = sb.g_values | Z = sb.g_values |
478 | 478 | return ax.contour(X, Y, Z.reshape(ngrid, ngrid), np.zeros(1), **kwargs) | return ax.contour(X, Y, Z.reshape(ngrid, ngrid), np.zeros(1), **kwargs) |
... | ... | def isocurves(ax, ngrid=200, limits=None, ncurves=5, **kwargs): | |
496 | 496 | x = np.linspace(xmin, xmax, ngrid) | x = np.linspace(xmin, xmax, ngrid) |
497 | 497 | y = np.linspace(ymin, ymax, ngrid) | y = np.linspace(ymin, ymax, ngrid) |
498 | 498 | X, Y = np.meshgrid(x, y) | X, Y = np.meshgrid(x, y) |
499 | XY = np.vstack((X.flatten(), Y.flatten())).T | ||
499 | XY = np.vstack((X.reshape(-1), Y.reshape(-1))).T | ||
500 | 500 | Z = ax.sample_box.f_model.sample_pdf(XY, ax.space) | Z = ax.sample_box.f_model.sample_pdf(XY, ax.space) |
501 | 501 | ||
502 | 502 |
File wellmet/mplot/mart3d.py changed (mode: 100644) (index 10c45eb..56de7bf) | |||
... | ... | def get_g_model_wireframe_data(shape_share, limits, space='R', ngrid=50): | |
35 | 35 | x = np.linspace(xmin, xmax, ngrid) | x = np.linspace(xmin, xmax, ngrid) |
36 | 36 | y = np.linspace(ymin, ymax, ngrid) | y = np.linspace(ymin, ymax, ngrid) |
37 | 37 | X, Y = np.meshgrid(x, y) | X, Y = np.meshgrid(x, y) |
38 | XY = np.vstack((X.flatten(), Y.flatten())).T | ||
38 | XY = np.vstack((X.reshape(-1), Y.reshape(-1))).T | ||
39 | 39 | ||
40 | 40 | if space == 'R': | if space == 'R': |
41 | 41 | g_values = shape_share.gm(XY).g_values | g_values = shape_share.gm(XY).g_values |
... | ... | def density_surface(ax3d, **kwargs): | |
277 | 277 | x = np.linspace(xmin, xmax, ngrid) | x = np.linspace(xmin, xmax, ngrid) |
278 | 278 | y = np.linspace(ymin, ymax, ngrid) | y = np.linspace(ymin, ymax, ngrid) |
279 | 279 | X, Y = np.meshgrid(x, y) | X, Y = np.meshgrid(x, y) |
280 | XY = np.vstack((X.flatten(), Y.flatten())).T | ||
280 | XY = np.vstack((X.reshape(-1), Y.reshape(-1))).T | ||
281 | 281 | z = ax3d.sample_box.sample_pdf(XY, ax3d.space) | z = ax3d.sample_box.sample_pdf(XY, ax3d.space) |
282 | 282 | Z = z.reshape(ngrid, ngrid) | Z = z.reshape(ngrid, ngrid) |
283 | 283 | ||
... | ... | def density_colored_surface(ax3d, hull, colors=('#7735C2', '#808080'), **kwargs) | |
298 | 298 | x = np.linspace(xmin, xmax, ngrid) | x = np.linspace(xmin, xmax, ngrid) |
299 | 299 | y = np.linspace(ymin, ymax, ngrid) | y = np.linspace(ymin, ymax, ngrid) |
300 | 300 | X, Y = np.meshgrid(x, y) | X, Y = np.meshgrid(x, y) |
301 | XY = np.vstack((X.flatten(), Y.flatten())).T | ||
301 | XY = np.vstack((X.reshape(-1), Y.reshape(-1))).T | ||
302 | 302 | z = ax3d.sample_box.sample_pdf(XY, ax3d.space) | z = ax3d.sample_box.sample_pdf(XY, ax3d.space) |
303 | 303 | Z = z.reshape(ngrid, ngrid) | Z = z.reshape(ngrid, ngrid) |
304 | 304 | ||
... | ... | def density_colored_surface(ax3d, hull, colors=('#7735C2', '#808080'), **kwargs) | |
306 | 306 | _x = np.linspace(xmin, xmax, ngrid-1, endpoint=False) + (xmax-xmin)/(ngrid-1)/2 | _x = np.linspace(xmin, xmax, ngrid-1, endpoint=False) + (xmax-xmin)/(ngrid-1)/2 |
307 | 307 | _y = np.linspace(ymin, ymax, ngrid-1, endpoint=False) + (ymax-ymin)/(ngrid-1)/2 | _y = np.linspace(ymin, ymax, ngrid-1, endpoint=False) + (ymax-ymin)/(ngrid-1)/2 |
308 | 308 | _X, _Y = np.meshgrid(_x, _y) | _X, _Y = np.meshgrid(_x, _y) |
309 | _XY = np.vstack((_X.flatten(), _Y.flatten())).T | ||
309 | _XY = np.vstack((_X.reshape(-1), _Y.reshape(-1))).T | ||
310 | 310 | facecolors = np.full(len(_XY), inside_color) | facecolors = np.full(len(_XY), inside_color) |
311 | 311 | mask = hull.is_outside(hull.sample.f_model.new_sample(_XY, space=ax3d.space)) | mask = hull.is_outside(hull.sample.f_model.new_sample(_XY, space=ax3d.space)) |
312 | 312 | facecolors[mask] = outside_color | facecolors[mask] = outside_color |
File wellmet/qt_gui/gl_plot.py changed (mode: 100644) (index fd6775f..1d492ac) | |||
... | ... | class ConvexHull(gl.GLMeshItem): | |
343 | 343 | ## dd, ii = tree.query(self.points, k=1, p=2) | ## dd, ii = tree.query(self.points, k=1, p=2) |
344 | 344 | ## | ## |
345 | 345 | ## self.simplices = self.w.sample_box.convex_hull.simplices | ## self.simplices = self.w.sample_box.convex_hull.simplices |
346 | ## box_facets = ii[self.simplices.flatten()].reshape(-1, 3) | ||
346 | ## box_facets = ii[self.simplices.reshape(-1)].reshape(-1, 3) | ||
347 | 347 | ## self.events = self.w.sample_box.get_events(box_facets) | ## self.events = self.w.sample_box.get_events(box_facets) |
348 | 348 | ## | ## |
349 | 349 | ## | ## |
File wellmet/qt_gui/qt_plot.py changed (mode: 100644) (index ba85bfd..2c2c2fa) | |||
... | ... | class Triangulation: | |
802 | 802 | else: | else: |
803 | 803 | #č zkontrolujeme co se změnilo | #č zkontrolujeme co se změnilo |
804 | 804 | equal_mask = former_simplices == self.simplices[:len(former_simplices)] | equal_mask = former_simplices == self.simplices[:len(former_simplices)] |
805 | changed_simplices_ids = np.argwhere(~equal_mask.all(axis=1)).flatten() | ||
805 | changed_simplices_ids = np.argwhere(~equal_mask.all(axis=1)).reshape(-1) | ||
806 | 806 | self.draw_simplices(changed_simplices_ids) | self.draw_simplices(changed_simplices_ids) |
807 | 807 | ||
808 | 808 | #č teď nové simplexy | #č teď nové simplexy |
File wellmet/reader.py changed (mode: 100644) (index eba49da..f1379a8) | |||
... | ... | def reader(filename, f_model=None): | |
237 | 237 | ||
238 | 238 | if f_model is None: | if f_model is None: |
239 | 239 | # veškeré datové řadky, sloupy - od (včetně) do (nezahrnuje) | # veškeré datové řadky, sloupy - od (včetně) do (nezahrnuje) |
240 | return SampleBox(Ingot(data[:,:-2]), data[:,-2:-1].flatten(), rows[0][0]) | ||
240 | return SampleBox(Ingot(data[:,:-2]), data[:,-2:-1].reshape(-1), rows[0][0]) | ||
241 | 241 | else: | else: |
242 | 242 | sample = f_model() | sample = f_model() |
243 | 243 | sample.add_sample(data[:,:-2]) | sample.add_sample(data[:,:-2]) |
244 | return SampleBox(sample, data[:,-2:-1].flatten(), rows[0][0]) | ||
244 | return SampleBox(sample, data[:,-2:-1].reshape(-1), rows[0][0]) | ||
245 | 245 | ||
246 | 246 | ||
247 | 247 |
File wellmet/samplebox.py changed (mode: 100644) (index a0e0b4e..e6e7459) | |||
... | ... | class SampleBox: | |
73 | 73 | # ~(g_values>0) to handle nan | # ~(g_values>0) to handle nan |
74 | 74 | return ~(sb.g_values>0) | return ~(sb.g_values>0) |
75 | 75 | elif attr == 'success_points': | elif attr == 'success_points': |
76 | return np.argwhere(sb.g_values>0).flatten() | ||
76 | return np.argwhere(sb.g_values>0).reshape(-1) | ||
77 | 77 | elif attr == 'failure_points': | elif attr == 'failure_points': |
78 | return np.argwhere(~(sb.g_values>0)).flatten() | ||
78 | return np.argwhere(~(sb.g_values>0)).reshape(-1) | ||
79 | 79 | elif attr == 'failure_samples': | elif attr == 'failure_samples': |
80 | 80 | return sb[~(sb.g_values>0)] | return sb[~(sb.g_values>0)] |
81 | 81 | elif attr == 'success_samples': | elif attr == 'success_samples': |
... | ... | class SampleBox: | |
108 | 108 | return sb.consistency_check() | return sb.consistency_check() |
109 | 109 | else: | else: |
110 | 110 | #raise ValueError("Merge sa nám nějak nepovedol") | #raise ValueError("Merge sa nám nějak nepovedol") |
111 | print(sb.gm_signature, input_sb.gm_signature) | ||
112 | print(type(sb.gm_signature), type(input_sb.gm_signature)) | ||
111 | 113 | raise ValueError("gm_signatures are unequal. You are probably trying to merge data from different sources") | raise ValueError("gm_signatures are unequal. You are probably trying to merge data from different sources") |
112 | 114 | ||
113 | 115 | def new_sample(sb, input_sb): | def new_sample(sb, input_sb): |
File wellmet/voronoi.py changed (mode: 100644) (index 9a12bdd..655f090) | |||
... | ... | from . import IS_stat | |
12 | 12 | from .candynodes import CandyNodes | from .candynodes import CandyNodes |
13 | 13 | from . import sball | from . import sball |
14 | 14 | ||
15 | ##č (jednotka dočasnosti - jeden furt) | ||
15 | |||
16 | 16 | ||
17 | 17 | ||
18 | 18 | ||
... | ... | class ContactVoronoi: | |
510 | 510 | č 3. sqrt(sum((w_i - w_mean)**2)) / n Směrodatná odchylka odhadu w_mean | č 3. sqrt(sum((w_i - w_mean)**2)) / n Směrodatná odchylka odhadu w_mean |
511 | 511 | """ | """ |
512 | 512 | def __init__(self, sample_box, hull, model_space='G', \ | def __init__(self, sample_box, hull, model_space='G', \ |
513 | p_norm=2, ns=1000, p_base=0.5, auto_update=True, workers=1,\ | ||
513 | ns=1000, p_base=0.5, auto_update=True, workers=1,\ | ||
514 | 514 | on_add_mixed=None, on_update_mixed=None, on_delete_mixed=None): | on_add_mixed=None, on_update_mixed=None, on_delete_mixed=None): |
515 | 515 | self.sample_box = sample_box | self.sample_box = sample_box |
516 | 516 | self.hull = hull | self.hull = hull |
517 | 517 | self.model_space = model_space | self.model_space = model_space |
518 | self.p_norm = p_norm | ||
519 | 518 | self.ns = ns | self.ns = ns |
520 | 519 | ||
521 | 520 | self.auto_update = auto_update | self.auto_update = auto_update |
... | ... | class ContactVoronoi: | |
1084 | 1083 | imask = nodes.imask | imask = nodes.imask |
1085 | 1084 | d2 = nodes.d2 | d2 = nodes.d2 |
1086 | 1085 | ||
1087 | di1 = cdist(nodes_model[imask], np.atleast_2d(self.points[i])).flatten() | ||
1088 | dj1 = cdist(nodes_model[~imask], np.atleast_2d(self.points[j])).flatten() | ||
1086 | di1 = cdist(nodes_model[imask], np.atleast_2d(self.points[i])).reshape(-1) | ||
1087 | dj1 = cdist(nodes_model[~imask], np.atleast_2d(self.points[j])).reshape(-1) | ||
1089 | 1088 | ||
1090 | 1089 | d1 = np.empty(len(imask)) | d1 = np.empty(len(imask)) |
1091 | 1090 | d1[imask] = di1 | d1[imask] = di1 |