Skip to content

NumPy 2.x compatibility: replace removed np.in1d with np.isin #12

Description

@NGC2023

Hi,

With NumPy 2.x, np.in1d has been removed, causing the test suite to fail with:

AttributeError: module 'numpy' has no attribute 'in1d'

The issue can be fixed by replacing np.in1d with np.isin, which provides the same functionality.

--- a/skopt/learning/gbrt.py
+++ b/skopt/learning/gbrt.py
@@ -116,7 +116,7 @@ class GradientBoostingQuantileRegressor(RegressorMixin, BaseEstimator):
         if return_std:
             std_quantiles = [0.16, 0.84]
-            is_present_mask = np.in1d(std_quantiles, self.quantiles)
+            is_present_mask = np.isin(std_quantiles, self.quantiles)
             if not np.all(is_present_mask):
                 raise ValueError(
                     "return_std works only if the quantiles during "

This change restores compatibility with NumPy 2.x while preserving the existing behavior.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions