1
1
"""These tests are based on the doctests from `numpy/lib/recfunctions.py`."""
2
2
3
- from __future__ import annotations
4
-
5
3
from typing import TYPE_CHECKING , Any , assert_type
6
4
7
5
import numpy as np
10
8
if TYPE_CHECKING :
11
9
import _numtype as _nt
12
10
11
+ # ruff: noqa: S101
12
+
13
13
14
14
def test_recursive_fill_fields () -> None :
15
15
a : _nt .Array [np .void ] = np .array (
16
16
[(1 , 10.0 ), (2 , 20.0 )],
17
17
dtype = [("A" , np .int64 ), ("B" , np .float64 )],
18
18
)
19
- b = np .zeros ((int ( 3 ) ,), dtype = a .dtype )
19
+ b = np .zeros ((3 ,), dtype = a .dtype )
20
20
out = rfn .recursive_fill_fields (a , b )
21
21
assert_type (out , "_nt.Array1D[np.void]" )
22
22
@@ -57,16 +57,16 @@ def test_get_fieldstructure() -> None:
57
57
def test_merge_arrays () -> None :
58
58
assert_type (
59
59
rfn .merge_arrays ((
60
- np .ones ((int (2 ),), np .int_ ),
61
- np .ones ((int (3 ),), np .float64 ),
60
+ np .ones (((2 ),), np .int_ ),
61
+ np .ones (((3 ),), np .float64 ),
62
62
)),
63
63
"np.recarray[_nt.Rank1, np.dtype[np.void]]" ,
64
64
)
65
65
66
66
67
67
def test_drop_fields () -> None :
68
68
ndtype = [("a" , np .int64 ), ("b" , [("b_a" , np .double ), ("b_b" , np .int64 )])]
69
- a = np .ones ((int (3 ),), dtype = ndtype )
69
+ a = np .ones (((3 ),), dtype = ndtype )
70
70
71
71
assert_type (rfn .drop_fields (a , "a" ), "_nt.Array1D[np.void]" )
72
72
assert_type (
@@ -81,7 +81,7 @@ def test_drop_fields() -> None:
81
81
82
82
def test_rename_fields () -> None :
83
83
ndtype = [("a" , np .int64 ), ("b" , [("b_a" , np .double ), ("b_b" , np .int64 )])]
84
- a = np .ones ((int (3 ),), dtype = ndtype )
84
+ a = np .ones (((3 ),), dtype = ndtype )
85
85
86
86
assert_type (
87
87
rfn .rename_fields (a , {"a" : "A" , "b_b" : "B_B" }),
@@ -130,11 +130,11 @@ def test_require_fields() -> None:
130
130
131
131
132
132
def test_stack_arrays () -> None :
133
- x = np .zeros ((int (2 ),), np .int32 )
133
+ x = np .zeros (((2 ),), np .int32 )
134
134
assert_type (rfn .stack_arrays (x ), "_nt.Array1D[np.int32]" )
135
135
136
- z = np .ones ((int (2 ),), [("A" , "|S3" ), ("B" , float )])
137
- zz = np .ones ((int (2 ),), [("A" , "|S3" ), ("B" , np .float64 ), ("C" , np .float64 )])
136
+ z = np .ones (((2 ),), [("A" , "|S3" ), ("B" , float )])
137
+ zz = np .ones (((2 ),), [("A" , "|S3" ), ("B" , np .float64 ), ("C" , np .float64 )])
138
138
assert_type (rfn .stack_arrays ((z , zz )), "_nt.MArray[np.void]" )
139
139
140
140
0 commit comments