Skip to content

Commit

Permalink
Merge pull request #233 from ChristopherMayes/bugfix
Browse files Browse the repository at this point in the history
Bugfix for using numpy 2.0.0
  • Loading branch information
roussel-ryan authored Jun 18, 2024
2 parents b64973e + 9238e27 commit b83cda7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions tests/generators/bayesian/test_bayesian_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ def test_get_model_w_conditions(self):
# try with input data that contains Nans due to xopt raising an error
# currently we drop all rows containing Nans
test_data = deepcopy(TEST_VOCS_DATA)
test_data["y1"].iloc[5] = np.NaN
test_data["y1"].iloc[5] = np.nan
model = gen.train_model(test_data)
assert len(model.models[0].train_inputs[0]) == len(test_data) - 1

# test with input data that is only Nans
test_data = deepcopy(TEST_VOCS_DATA)
test_data["y1"].iloc[:] = np.NaN
test_data["y1"].iloc[:] = np.nan
with pytest.raises(ValueError):
gen.train_model(test_data)

Expand Down
2 changes: 1 addition & 1 deletion tests/generators/bayesian/test_time_dependent_bo.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def test_model_generation(self):
model = gen.train_model(test_data)

# make sure time data is in the last model
assert np.alltrue(
assert np.all(
model.models[-1]
.input_transform.untransform(model.models[-1].train_inputs[0])[:, -1]
.numpy()
Expand Down
5 changes: 2 additions & 3 deletions xopt/generators/scipy/neldermead.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import numpy as np
import pandas as pd
from numpy import asfarray
from pydantic import ConfigDict, Field, field_validator

from xopt.generator import Generator
Expand Down Expand Up @@ -346,7 +345,7 @@ def save_state():
warnings.warn("Initial guess is not within the specified bounds")

if stage == -1:
x0 = asfarray(x0).flatten()
x0 = np.array(x0, dtype=float).flatten()

nonzdelt = 0.05
zdelt = 0.00025
Expand All @@ -367,7 +366,7 @@ def save_state():
y[k] = zdelt
sim[k + 1] = y
else:
sim = np.asfarray(initial_simplex).copy()
sim = np.array(initial_simplex, dtype=float).copy()
if sim.ndim != 2 or sim.shape[0] != sim.shape[1] + 1:
raise ValueError(
"`initial_simplex` should be an array of shape (N+1,N)"
Expand Down

0 comments on commit b83cda7

Please sign in to comment.