Skip to content

Commit 6028bf4

Browse files
authored
Make a duplicate fixture for pandas dtypes including pyarrow types (#2941)
* Make a duplicate fixture for pandas dtypes including pyarrow types Explicitly copying the numpy dtypes fixture in test_clib_virtualfiles.py to a new dtypes_pandas fixture that includes pyarrow types, so that modifications to the original numpy dtypes fixture won't affect other tests. * Let test_virtualfile_from_vectors_transpose use dtypes fixture No need to recreate a new dtypes list.
1 parent 5639f24 commit 6028bf4

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

pygmt/tests/test_clib_virtualfiles.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,19 @@ def fixture_dtypes():
3434
return "int8 int16 int32 int64 uint8 uint16 uint32 uint64 float32 float64".split()
3535

3636

37+
@pytest.fixture(scope="module", name="dtypes_pandas")
38+
def fixture_dtypes_pandas(dtypes):
39+
"""
40+
List of supported pandas dtypes.
41+
"""
42+
dtypes_pandas = dtypes.copy()
43+
44+
if find_spec("pyarrow") is not None:
45+
dtypes_pandas.extend([f"{dtype}[pyarrow]" for dtype in dtypes_pandas])
46+
47+
return tuple(dtypes_pandas)
48+
49+
3750
def test_virtual_file(dtypes):
3851
"""
3952
Test passing in data via a virtual file with a Dataset.
@@ -248,11 +261,10 @@ def test_virtualfile_from_vectors_two_string_or_object_columns(dtype):
248261
assert output == expected
249262

250263

251-
def test_virtualfile_from_vectors_transpose():
264+
def test_virtualfile_from_vectors_transpose(dtypes):
252265
"""
253266
Test transforming matrix columns to virtual file dataset.
254267
"""
255-
dtypes = "float32 float64 int32 int64 uint32 uint64".split()
256268
shape = (7, 5)
257269
for dtype in dtypes:
258270
data = np.arange(shape[0] * shape[1], dtype=dtype).reshape(shape)
@@ -315,16 +327,14 @@ def test_virtualfile_from_matrix_slice(dtypes):
315327
assert output == expected
316328

317329

318-
def test_virtualfile_from_vectors_pandas(dtypes):
330+
def test_virtualfile_from_vectors_pandas(dtypes_pandas):
319331
"""
320332
Pass vectors to a dataset using pandas.Series, checking both numpy and pyarrow
321333
dtypes.
322334
"""
323335
size = 13
324-
if find_spec("pyarrow") is not None:
325-
dtypes.extend([f"{dtype}[pyarrow]" for dtype in dtypes])
326336

327-
for dtype in dtypes:
337+
for dtype in dtypes_pandas:
328338
data = pd.DataFrame(
329339
data={
330340
"x": np.arange(size),

0 commit comments

Comments
 (0)