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

Add row_stack to NumPy 2.0 migration rule #10646

Merged
merged 1 commit into from
Mar 28, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions crates/ruff_linter/resources/test/fixtures/numpy/NPY201.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,5 @@ def func():
np.unicode_("asf")

np.who()

np.row_stack(([1,2], [3,4]))
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,14 @@ pub(crate) fn numpy_2_0_deprecation(checker: &mut Checker, expr: &Expr) {
guideline: Some("Use an IDE variable explorer or `locals()` instead."),
},
}),
["numpy", "row_stack"] => Some(Replacement {
existing: "row_stack",
details: Details::AutoImport {
path: "numpy",
name: "vstack",
compatibility: Compatibility::BackwardsCompatible,
},
}),
_ => None,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -836,13 +836,32 @@ NPY201.py:104:5: NPY201 [*] `np.unicode_` will be removed in NumPy 2.0. Use `num
104 |+ np.str_("asf")
105 105 |
106 106 | np.who()
107 107 |

NPY201.py:106:5: NPY201 `np.who` will be removed in NumPy 2.0. Use an IDE variable explorer or `locals()` instead.
|
104 | np.unicode_("asf")
105 |
106 | np.who()
| ^^^^^^ NPY201
107 |
108 | np.row_stack(([1,2], [3,4]))
|

NPY201.py:108:5: NPY201 [*] `np.row_stack` will be removed in NumPy 2.0. Use `numpy.vstack` instead.
|
106 | np.who()
107 |
108 | np.row_stack(([1,2], [3,4]))
| ^^^^^^^^^^^^ NPY201
|
= help: Replace with `numpy.vstack`

ℹ Safe fix
105 105 |
106 106 | np.who()
107 107 |
108 |- np.row_stack(([1,2], [3,4]))
108 |+ np.vstack(([1,2], [3,4]))