Add `row_stack` to NumPy 2.0 migration rule (#10646)

Hi! 

I left out one of the functions in the migration rule which became
deprecated/removed in NumPy 2.0
(https://github.com/numpy/numpy/issues/26032#issuecomment-1999870797).

cc @anntzer
This commit is contained in:
Mateusz Sokół 2024-03-28 14:49:40 +01:00 committed by GitHub
parent 6b580c1544
commit a0263ab472
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 29 additions and 0 deletions

View File

@ -104,3 +104,5 @@ def func():
np.unicode_("asf") np.unicode_("asf")
np.who() np.who()
np.row_stack(([1,2], [3,4]))

View File

@ -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."), 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, _ => None,
}); });

View File

@ -836,6 +836,7 @@ NPY201.py:104:5: NPY201 [*] `np.unicode_` will be removed in NumPy 2.0. Use `num
104 |+ np.str_("asf") 104 |+ np.str_("asf")
105 105 | 105 105 |
106 106 | np.who() 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. NPY201.py:106:5: NPY201 `np.who` will be removed in NumPy 2.0. Use an IDE variable explorer or `locals()` instead.
| |
@ -843,6 +844,24 @@ NPY201.py:106:5: NPY201 `np.who` will be removed in NumPy 2.0. Use an IDE variab
105 | 105 |
106 | np.who() 106 | np.who()
| ^^^^^^ NPY201 | ^^^^^^ 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]))