Skip to content

Commit 42a0951

Browse files
seismanweiji14
andauthored
Define params list
Co-authored-by: Wei Ji <[email protected]>
1 parent 8bc2f56 commit 42a0951

File tree

1 file changed

+23
-44
lines changed

1 file changed

+23
-44
lines changed

pygmt/tests/test_clib_to_numpy.py

Lines changed: 23 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -57,28 +57,28 @@ def test_to_numpy_python_types_numeric(data, expected_dtype):
5757
#
5858
# Reference: https://numpy.org/doc/2.1/reference/arrays.scalars.html
5959
########################################################################################
60-
@pytest.mark.parametrize(
61-
("dtype", "expected_dtype"),
62-
[
63-
pytest.param(np.int8, np.int8, id="int8"),
64-
pytest.param(np.int16, np.int16, id="int16"),
65-
pytest.param(np.int32, np.int32, id="int32"),
66-
pytest.param(np.int64, np.int64, id="int64"),
67-
pytest.param(np.longlong, np.longlong, id="longlong"),
68-
pytest.param(np.uint8, np.uint8, id="uint8"),
69-
pytest.param(np.uint16, np.uint16, id="uint16"),
70-
pytest.param(np.uint32, np.uint32, id="uint32"),
71-
pytest.param(np.uint64, np.uint64, id="uint64"),
72-
pytest.param(np.ulonglong, np.ulonglong, id="ulonglong"),
73-
pytest.param(np.float16, np.float16, id="float16"),
74-
pytest.param(np.float32, np.float32, id="float32"),
75-
pytest.param(np.float64, np.float64, id="float64"),
76-
pytest.param(np.longdouble, np.longdouble, id="longdouble"),
77-
pytest.param(np.complex64, np.complex64, id="complex64"),
78-
pytest.param(np.complex128, np.complex128, id="complex128"),
79-
pytest.param(np.clongdouble, np.clongdouble, id="clongdouble"),
80-
],
81-
)
60+
np_dtype_params = [
61+
pytest.param(np.int8, np.int8, id="int8"),
62+
pytest.param(np.int16, np.int16, id="int16"),
63+
pytest.param(np.int32, np.int32, id="int32"),
64+
pytest.param(np.int64, np.int64, id="int64"),
65+
pytest.param(np.longlong, np.longlong, id="longlong"),
66+
pytest.param(np.uint8, np.uint8, id="uint8"),
67+
pytest.param(np.uint16, np.uint16, id="uint16"),
68+
pytest.param(np.uint32, np.uint32, id="uint32"),
69+
pytest.param(np.uint64, np.uint64, id="uint64"),
70+
pytest.param(np.ulonglong, np.ulonglong, id="ulonglong"),
71+
pytest.param(np.float16, np.float16, id="float16"),
72+
pytest.param(np.float32, np.float32, id="float32"),
73+
pytest.param(np.float64, np.float64, id="float64"),
74+
pytest.param(np.longdouble, np.longdouble, id="longdouble"),
75+
pytest.param(np.complex64, np.complex64, id="complex64"),
76+
pytest.param(np.complex128, np.complex128, id="complex128"),
77+
pytest.param(np.clongdouble, np.clongdouble, id="clongdouble"),
78+
]
79+
80+
81+
@pytest.mark.parametrize(("dtype", "expected_dtype"), np_dtype_params)
8282
def test_to_numpy_ndarray_numpy_dtypes_numeric(dtype, expected_dtype):
8383
"""
8484
Test the _to_numpy function with NumPy arrays of NumPy numeric dtypes.
@@ -127,28 +127,7 @@ def test_to_numpy_ndarray_numpy_dtypes_numeric(dtype, expected_dtype):
127127
# 2. https://pandas.pydata.org/docs/user_guide/basics.html#basics-dtypes
128128
# 3. https://pandas.pydata.org/docs/user_guide/pyarrow.html
129129
########################################################################################
130-
@pytest.mark.parametrize(
131-
("dtype", "expected_dtype"),
132-
[
133-
pytest.param(np.int8, np.int8, id="int8"),
134-
pytest.param(np.int16, np.int16, id="int16"),
135-
pytest.param(np.int32, np.int32, id="int32"),
136-
pytest.param(np.int64, np.int64, id="int64"),
137-
pytest.param(np.longlong, np.longlong, id="longlong"),
138-
pytest.param(np.uint8, np.uint8, id="uint8"),
139-
pytest.param(np.uint16, np.uint16, id="uint16"),
140-
pytest.param(np.uint32, np.uint32, id="uint32"),
141-
pytest.param(np.uint64, np.uint64, id="uint64"),
142-
pytest.param(np.ulonglong, np.ulonglong, id="ulonglong"),
143-
pytest.param(np.float16, np.float16, id="float16"),
144-
pytest.param(np.float32, np.float32, id="float32"),
145-
pytest.param(np.float64, np.float64, id="float64"),
146-
pytest.param(np.longdouble, np.longdouble, id="longdouble"),
147-
pytest.param(np.complex64, np.complex64, id="complex64"),
148-
pytest.param(np.complex128, np.complex128, id="complex128"),
149-
pytest.param(np.clongdouble, np.clongdouble, id="clongdouble"),
150-
],
151-
)
130+
@pytest.mark.parametrize(("dtype", "expected_dtype"), np_dtype_params)
152131
def test_to_numpy_pandas_series_numpy_dtypes_numeric(dtype, expected_dtype):
153132
"""
154133
Test the _to_numpy function with pandas.Series of NumPy numeric dtypes.

0 commit comments

Comments
 (0)