Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix for using numpy 2.0.0 #233

Merged
merged 3 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading