Skip to content

Commit 7a1d847

Browse files
v0.0.11 Nicer Outputs
1 parent 7de4c72 commit 7a1d847

5 files changed

Lines changed: 31 additions & 35 deletions

File tree

notebooks/01_spot_intro.ipynb

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@
141141
{
142142
"data": {
143143
"text/plain": [
144-
"<spotPython.spot.spot.Spot at 0x2917b7c40>"
144+
"<spotPython.spot.spot.Spot at 0x16b45aaa0>"
145145
]
146146
},
147147
"execution_count": 5,
@@ -163,7 +163,7 @@
163163
"output_type": "stream",
164164
"text": [
165165
"min y: 4.897545259852824e-10\n",
166-
"min X: [[2.21303982e-05]]\n"
166+
"x0: 2.2130398233770724e-05\n"
167167
]
168168
}
169169
],
@@ -243,7 +243,7 @@
243243
{
244244
"data": {
245245
"text/plain": [
246-
"<spotPython.spot.spot.Spot at 0x291aae7d0>"
246+
"<spotPython.spot.spot.Spot at 0x16b84c610>"
247247
]
248248
},
249249
"execution_count": 9,
@@ -280,25 +280,7 @@
280280
"output_type": "stream",
281281
"text": [
282282
"min y: 3.648984784366253e-07\n",
283-
"min X: [[-0.00060407]]\n"
284-
]
285-
}
286-
],
287-
"source": [
288-
"spot_1.print_results()"
289-
]
290-
},
291-
{
292-
"cell_type": "code",
293-
"execution_count": 11,
294-
"metadata": {},
295-
"outputs": [
296-
{
297-
"name": "stdout",
298-
"output_type": "stream",
299-
"text": [
300-
"min y: 3.648984784366253e-07\n",
301-
"min X: [[-0.00060407]]\n"
283+
"x0: -0.0006040682729929005\n"
302284
]
303285
}
304286
],

notebooks/02_spot_multidim.ipynb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
{
104104
"data": {
105105
"text/plain": [
106-
"<spotPython.spot.spot.Spot at 0x288c37a00>"
106+
"<spotPython.spot.spot.Spot at 0x29b1bf9a0>"
107107
]
108108
},
109109
"execution_count": 3,
@@ -139,7 +139,9 @@
139139
"output_type": "stream",
140140
"text": [
141141
"min y: 5.9908343748136085e-05\n",
142-
"min X: [[0.00515786 0.00195711 0.00542904]]\n"
142+
"Pressure: 0.005157864627379999\n",
143+
"Temp: 0.00195710957248863\n",
144+
"Lambda: 0.005429042121316765\n"
143145
]
144146
}
145147
],
@@ -273,9 +275,9 @@
273275
"output_type": "stream",
274276
"text": [
275277
"Importance relative to the most important parameter:\n",
276-
"Parameter 0 : 100.0\n",
277-
"Parameter 1 : 99.78247670817808\n",
278-
"Parameter 2 : 94.72233826625329\n"
278+
"Pressure: 100.0\n",
279+
"Temp: 99.78247670817808\n",
280+
"Lambda: 94.72233826625329\n"
279281
]
280282
}
281283
],

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.10"
10+
version = "0.0.11"
1111
authors = [
1212
{ name="T. Bartz-Beielstein", email="tbb@bartzundbartz.de" }
1313
]

src/spotPython/spot/spot.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -537,10 +537,20 @@ def print_results(self):
537537
4. min mean X
538538
"""
539539
print(f"min y: {self.min_y}")
540-
print(f"min X: {self.to_all_dim(self.min_X.reshape(1, -1))}")
540+
res = self.to_all_dim(self.min_X.reshape(1, -1))
541+
for i in range(res.shape[1]):
542+
if self.var_name is None:
543+
print("x" + str(i) + ":", res[0][i])
544+
else:
545+
print(self.var_name[i] + ":", res[0][i])
541546
if self.noise:
547+
res = self.to_all_dim(self.min_mean_X.reshape(1, -1))
542548
print(f"min mean y: {self.min_mean_y}")
543-
print(f"min mean X: {self.to_all_dim(self.min_mean_X.reshape(1, -1))}")
549+
for i in range(res.shape[1]):
550+
if self.var_name is None:
551+
print("x" + str(i) + ":", res[0][i])
552+
else:
553+
print(self.var_name[i] + ":", res[0][i])
544554

545555
def chg(self, x, y, z0, i, j):
546556
z0[i] = x
@@ -598,5 +608,9 @@ def print_importance(self):
598608
theta = np.power(10, self.surrogate.theta)
599609
print("Importance relative to the most important parameter:")
600610
imp = 100 * theta / np.max(theta)
601-
for i in range(len(imp)):
602-
print("Parameter", i, ": ", imp[i])
611+
if self.var_name is None:
612+
for i in range(len(imp)):
613+
print("x", i, ": ", imp[i])
614+
else:
615+
for i in range(len(imp)):
616+
print(self.var_name[i] + ": ", imp[i])

src/spotPython/utils/progress.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ def progress_bar(progress, bar_length=10, message="spotPython tuning:"):
2626
progress = 1
2727
status = "Done...\r\n"
2828
block = int(round(bar_length * progress))
29-
text = message + " [{0}] {1:.2f}% {2}\r".format(
30-
"#" * block + "-" * (bar_length - block), progress * 100, status
31-
)
29+
text = message + " [{0}] {1:.2f}% {2}\r".format("#" * block + "-" * (bar_length - block), progress * 100, status)
3230
stdout.write(text)
3331
stdout.flush()

0 commit comments

Comments
 (0)