Skip to content

Commit 9298222

Browse files
committed
Fix loss_function_sm for recent numpy compatibility
Use .item() instead of float() on model.predict() result to avoid "only 0-dimensional arrays can be converted to Python scalars" TypeError.
1 parent da6da9a commit 9298222

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

nevergrad/optimization/metamodel.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,8 @@ def my_kernel(x, y):
174174
DiscreteLenglerOnePlusOne = registry["DiscreteLenglerOnePlusOne"]
175175

176176
def loss_function_sm(x):
177-
return float(model.predict(trans(np.asarray(x, dtype=X[0].dtype).flatten()[None, :])))
177+
x = np.asarray(x, dtype=X[0].dtype).flatten()[None, :]
178+
return model.predict(trans(x)).item()
178179

179180
for cls in (
180181
(Powell, DE) if algorithm != "image" else (DiscreteLenglerOnePlusOne,)

0 commit comments

Comments
 (0)