Skip to content

Commit

Permalink
avoid transformations of types in _sample
Browse files Browse the repository at this point in the history
  • Loading branch information
Deathn0t committed Apr 11, 2022
1 parent c272896 commit 1625078
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions skopt/optimizer/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,12 +641,11 @@ def _filter_failures(self, yi):

def _sample(self, X, y):

X = np.asarray(X)
X = np.asarray(X, dtype="O")
y = np.asarray(y)
size = y.shape[0]

if self._sample_max_size > 0 and size > self._sample_max_size:

if self._sample_strategy == "quantile":
quantiles = np.quantile(y, [0.10, 0.25, 0.50, 0.75, 0.90])
int_size = self._sample_max_size // (len(quantiles) + 1)
Expand All @@ -671,6 +670,8 @@ def _sample(self, X, y):
X = np.concatenate(Xs, axis=0)
y = np.concatenate(ys, axis=0)

X = X.tolist()
y = y.tolist()
return X, y

def _ask_random_points(self, size=None):
Expand Down

0 comments on commit 1625078

Please sign in to comment.