Skip to content

Commit 5aa0946

Browse files
committed
Merge all pandas-related tests into a single test
1 parent 6b0e8d0 commit 5aa0946

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

pygmt/tests/test_clib_to_numpy.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -159,20 +159,10 @@ def test_to_numpy_ndarray_numpy_dtypes_numeric(dtype, expected_dtype):
159159
# 2. https://pandas.pydata.org/docs/user_guide/basics.html#basics-dtypes
160160
# 3. https://pandas.pydata.org/docs/user_guide/pyarrow.html
161161
########################################################################################
162-
@pytest.mark.parametrize(("dtype", "expected_dtype"), np_dtype_params)
163-
def test_to_numpy_pandas_series_numpy_dtypes_numeric(dtype, expected_dtype):
164-
"""
165-
Test the _to_numpy function with pandas.Series of NumPy numeric dtypes.
166-
"""
167-
series = pd.Series([1, 2, 3, 4, 5, 6], dtype=dtype)[::2] # Not C-contiguous
168-
result = _to_numpy(series)
169-
_check_result(result, expected_dtype)
170-
npt.assert_array_equal(result, series)
171-
172-
173162
@pytest.mark.parametrize(
174163
("dtype", "expected_dtype"),
175164
[
165+
*np_dtype_params,
176166
pytest.param(pd.Int8Dtype(), np.int8, id="Int8"),
177167
pytest.param(pd.Int16Dtype(), np.int16, id="Int16"),
178168
pytest.param(pd.Int32Dtype(), np.int32, id="Int32"),
@@ -196,16 +186,16 @@ def test_to_numpy_pandas_series_numpy_dtypes_numeric(dtype, expected_dtype):
196186
pytest.param("float64[pyarrow]", np.float64, id="float64[pyarrow]", **pa_marks),
197187
],
198188
)
199-
def test_to_numpy_pandas_series_pandas_dtypes_numeric(dtype, expected_dtype):
189+
def test_to_numpy_pandas_numeric(dtype, expected_dtype):
200190
"""
201-
Test the _to_numpy function with pandas.Series of pandas/PyArrow numeric dtypes.
191+
Test the _to_numpy function with pandas.Series of NumPy/pandas/PyArrow numeric
192+
dtypes.
202193
"""
203194
data = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
204195
if dtype == "float16[pyarrow]" and Version(pd.__version__) < Version("2.2"):
205196
# float16 needs special handling for pandas < 2.2.
206197
# Example from https://arrow.apache.org/docs/python/generated/pyarrow.float16.html
207198
data = np.array(data, dtype=np.float16)
208-
209199
series = pd.Series(data, dtype=dtype)[::2] # Not C-contiguous
210200
result = _to_numpy(series)
211201
_check_result(result, expected_dtype)

0 commit comments

Comments
 (0)