-
Notifications
You must be signed in to change notification settings - Fork 662
Forward-merge release/26.04 into main #7894
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
Changes from all commits
3cc7c9c
7682f16
9afada5
92757ff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,7 +71,6 @@ def _get_n_features(X): | |
| return len(row) | ||
| except Exception: | ||
| pass | ||
| return 1 | ||
|
|
||
| if hasattr(X, "shape"): | ||
| shape = X.shape | ||
|
|
@@ -82,9 +81,38 @@ def _get_n_features(X): | |
| else: | ||
| shape = np.asarray(X).shape | ||
|
|
||
| # TODO: Can remove the fallback to 1 when we finish dropping support | ||
| # for 1D X inputs | ||
| return shape[1] if len(shape) >= 2 else 1 | ||
| ndim = len(shape) | ||
|
|
||
| if ndim != 2: | ||
| import cuml.accel | ||
|
|
||
| if isinstance(X, (cudf.Series, pd.Series)): | ||
| msg = ( | ||
| f"Expected a 2-dimensional container but got {type(X).__name__} " | ||
| "instead. Pass a DataFrame containing a single row (i.e. " | ||
| "single sample) or a single column (i.e. single feature) " | ||
| "instead." | ||
| ) | ||
| else: | ||
| kind = "scalar" if ndim == 0 else f"{ndim}D" | ||
| msg = ( | ||
| f"Expected 2D array, got {kind} array instead. Reshape your data " | ||
| "using array.reshape(-1, 1) if your data has a single feature, " | ||
| "or array.reshape(1, -1) if it contains a single sample." | ||
| ) | ||
|
|
||
| if cuml.accel.enabled() or ndim > 2: | ||
| raise ValueError(msg) | ||
| else: | ||
| warnings.warn( | ||
| "Support for passing non-2-dimensional X was deprecated in 26.04 " | ||
| "and will be removed in version 26.06 of cuML. In version 26.06 this will error " | ||
| f"with the following message:\n\n{msg}", | ||
| FutureWarning, | ||
| ) | ||
| # Fallback to 1 feature until the deprecation is completed | ||
| return 1 | ||
| return shape[1] | ||
|
Comment on lines
+84
to
+115
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 3D Python sequences still bypass this new ndim check. This branch only runs after As per coding guidelines, 🧰 Tools🪛 Ruff (0.15.5)[warning] 107-107: No explicit Set (B028) |
||
|
|
||
|
|
||
| def _warn_or_error(exc_cls, msg): | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -174,8 +174,8 @@ class TargetEncoder(Base, InteropMixin): | |
| >>> test = DataFrame({'category': ['a', 'c', 'b', 'a']}) | ||
|
|
||
| >>> encoder = TargetEncoder(output_type='numpy') | ||
| >>> train_encoded = encoder.fit_transform(train.category, train.label) | ||
| >>> test_encoded = encoder.transform(test.category) | ||
| >>> train_encoded = encoder.fit_transform(train[["category"]], train.label) | ||
| >>> test_encoded = encoder.transform(test[["category"]]) | ||
|
Comment on lines
+177
to
+178
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Finish the doc cleanup for 2D The example now correctly uses a 1-column DataFrame, but the As per coding guidelines, 🤖 Prompt for AI Agents |
||
| >>> print(train_encoded) | ||
| [1. 1. 0. 1.] | ||
| >>> print(test_encoded) | ||
|
|
||
Large diffs are not rendered by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: rapidsai/cuml
Length of output: 1277
Set warning
stacklevelso deprecation points to callerLine 107 emits
warnings.warn(...)withoutstacklevel, so users get an internal location instead of their callsite (also matches Ruff B028).💡 Proposed fix
else: warnings.warn( "Support for passing non-2-dimensional X was deprecated in 26.04 " "and will be removed in 26.06. In cuml version 26.06 this will error " f"with the following message:\n\n{msg}", FutureWarning, + stacklevel=2, )🧰 Tools
🪛 Ruff (0.15.5)
[warning] 107-107: No explicit
stacklevelkeyword argument foundSet
stacklevel=2(B028)
🤖 Prompt for AI Agents