Skip to content

Commit 68feb66

Browse files
v0.0.9: Labels for contour plots
1 parent be0c457 commit 68feb66

6 files changed

Lines changed: 27 additions & 12 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ __pycache__/
44
spotPython.code-workspace
55
src/spotPython/_version.py
66
*.log
7-
site/
7+
site/
8+
dist/
-39.7 KB
Binary file not shown.

dist/spotPython-0.0.8.tar.gz

-3.69 MB
Binary file not shown.

notebooks/02_spot_multidim.ipynb

Lines changed: 5 additions & 4 deletions
Large diffs are not rendered by default.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
77

88
[project]
99
name = "spotPython"
10-
version = "0.0.8"
10+
version = "0.0.9"
1111
authors = [
1212
{ name="T. Bartz-Beielstein", email="tbb@bartzundbartz.de" }
1313
]

src/spotPython/spot/spot.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ class Spot:
7575
If zero (which is the default), every new solution is accepted.
7676
ocba_delta (int): OCBA increment (only used if `noise==True`)
7777
var_type (list): list of type information, can be either "num" or "factor"
78+
var_name (list): list of variable names, e.g., ["x1", "x2"]
7879
infill_criterion (string): Can be `"y"`, `"s"`, `"ei"` (negative expected improvement), or `"all"`.
7980
n_points (int): number of infill points
8081
seed (int): initial seed
@@ -129,6 +130,7 @@ def __init__(
129130
noise=False,
130131
tolerance_x=0,
131132
var_type=["num"],
133+
var_name=None,
132134
infill_criterion="y",
133135
n_points=1,
134136
ocba_delta=0,
@@ -149,6 +151,7 @@ def __init__(
149151
self.lower = lower
150152
self.upper = upper
151153
self.var_type = var_type
154+
self.var_name = var_name
152155
# Reduce dim based on lower == upper logic:
153156
# modifies lower, upper, and var_type
154157
self.to_red_dim()
@@ -252,6 +255,9 @@ def to_red_dim(self):
252255
self.red_dim = self.ident.any()
253256
self.all_var_type = self.var_type
254257
self.var_type = [x for x, y in zip(self.all_var_type, self.ident) if not y]
258+
if self.var_name is not None:
259+
self.all_var_name = self.var_name
260+
self.var_name = [x for x, y in zip(self.all_var_name, self.ident) if not y]
255261

256262
def to_all_dim(self, X0):
257263
n = X0.shape[0]
@@ -524,7 +530,7 @@ def print_results(self):
524530
Print results from the run:
525531
1. min y
526532
2. min X
527-
If `noise == True`, additinally the following values are printed:
533+
If `noise == True`, additionally the following values are printed:
528534
3. min mean y
529535
4. min mean X
530536
"""
@@ -566,16 +572,23 @@ def plot_contour(self, i=0, j=1, min_z=None, max_z=None, show=True):
566572
ax = fig.add_subplot(221)
567573
# plot predicted values:
568574
plt.contourf(X, Y, Z, contour_levels, zorder=1, cmap="jet", vmin=min_z, vmax=max_z)
569-
plt.xlabel("x" + str(i))
570-
plt.ylabel("x" + str(j))
575+
if self.var_name is None:
576+
plt.xlabel("x" + str(i))
577+
plt.ylabel("x" + str(j))
578+
else:
579+
plt.xlabel("x" + str(i) + ": " + self.var_name[i])
580+
plt.ylabel("x" + str(j) + ": " + self.var_name[j])
571581
plt.title("Surrogate")
572582
pylab.colorbar()
573583
#
574584
ax = fig.add_subplot(222, projection="3d")
575585
ax.plot_surface(X, Y, Z, rstride=3, cstride=3, alpha=0.9, cmap="jet", vmin=min_z, vmax=max_z)
576-
ax.set_xlabel("x" + str(i))
577-
ax.set_ylabel("x" + str(j))
578-
#
586+
if self.var_name is None:
587+
plt.xlabel("x" + str(i))
588+
plt.ylabel("x" + str(j))
589+
else:
590+
plt.xlabel("x" + str(i) + ": " + self.var_name[i])
591+
plt.ylabel("x" + str(j) + ": " + self.var_name[j])
579592
#
580593
pylab.show()
581594

0 commit comments

Comments
 (0)