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 more NPY201 tests #12087

Merged
merged 3 commits into from
Jun 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 0 additions & 56 deletions crates/ruff_linter/resources/test/fixtures/numpy/NPY201.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,59 +68,3 @@ def func():
np.longfloat(12+34j)

np.lookfor

np.obj2sctype(int)

np.PINF

np.PZERO

np.recfromcsv

np.recfromtxt

np.round_(12.34)

np.safe_eval

np.sctype2char

np.sctypes

np.seterrobj

np.set_numeric_ops

np.set_string_function

np.singlecomplex(12+1j)

np.string_("asdf")

np.source

np.tracemalloc_domain

np.unicode_("asf")

np.who()

np.row_stack(([1,2], [3,4]))

np.alltrue([True, True])

np.anytrue([True, False])

np.cumproduct([1, 2, 3])

np.product([1, 2, 3])

np.trapz([1, 2, 3])

np.in1d([1, 2], [1, 3, 5])

np.AxisError

np.ComplexWarning

np.compare_chararrays
58 changes: 58 additions & 0 deletions crates/ruff_linter/resources/test/fixtures/numpy/NPY201_2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
def func():
import numpy as np

np.obj2sctype(int)

np.PINF

np.PZERO

np.recfromcsv

np.recfromtxt

np.round_(12.34)

np.safe_eval

np.sctype2char

np.sctypes

np.seterrobj

np.set_numeric_ops

np.set_string_function

np.singlecomplex(12+1j)

np.string_("asdf")

np.source

np.tracemalloc_domain

np.unicode_("asf")

np.who()

np.row_stack(([1,2], [3,4]))

np.alltrue([True, True])

np.anytrue([True, False])

np.cumproduct([1, 2, 3])

np.product([1, 2, 3])

np.trapz([1, 2, 3])

np.in1d([1, 2], [1, 3, 5])

np.AxisError

np.ComplexWarning

np.compare_chararrays
16 changes: 16 additions & 0 deletions crates/ruff_linter/resources/test/fixtures/numpy/NPY201_3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
def func():
import numpy as np

np.DTypePromotionError

np.ModuleDeprecationWarning

np.RankWarning

np.TooHardError

np.VisibleDeprecationWarning

np.chararray

np.format_parser
3 changes: 3 additions & 0 deletions crates/ruff_linter/src/rules/numpy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ mod tests {
#[test_case(Rule::NumpyDeprecatedTypeAlias, Path::new("NPY001.py"))]
#[test_case(Rule::NumpyLegacyRandom, Path::new("NPY002.py"))]
#[test_case(Rule::NumpyDeprecatedFunction, Path::new("NPY003.py"))]
// The NPY201 tests are split into multiple files because they get fixed one by one and too many diagnostic exceed the max-iterations limit.
#[test_case(Rule::Numpy2Deprecation, Path::new("NPY201.py"))]
#[test_case(Rule::Numpy2Deprecation, Path::new("NPY201_2.py"))]
#[test_case(Rule::Numpy2Deprecation, Path::new("NPY201_3.py"))]
fn rules(rule_code: Rule, path: &Path) -> Result<()> {
let snapshot = format!("{}_{}", rule_code.as_ref(), path.to_string_lossy());
let diagnostics = test_path(
Expand Down
Loading
Loading