Skip to content

Commit

Permalink
Add more NPY201 tests (#12087)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaReiser authored Jun 28, 2024
1 parent 2336c07 commit 117ab78
Show file tree
Hide file tree
Showing 8 changed files with 734 additions and 542 deletions.
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

0 comments on commit 117ab78

Please sign in to comment.