Skip to content

Commit 6ad6eb9

Browse files
committed
Move pa.array parametrizations to another file
The test_virtualfile_from_vectors_one_string_or_object_column unit test was moved to test_clib_virtualfile_from_vectors.py. Xref #3512
1 parent acaf350 commit 6ad6eb9

File tree

2 files changed

+19
-40
lines changed

2 files changed

+19
-40
lines changed

pygmt/tests/test_clib_virtualfile_from_vectors.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,30 @@ def test_virtualfile_from_vectors(dtypes):
5353

5454

5555
@pytest.mark.benchmark
56-
@pytest.mark.parametrize("dtype", [str, object])
57-
def test_virtualfile_from_vectors_one_string_or_object_column(dtype):
58-
"""
59-
Test passing in one column with string or object dtype into virtual file dataset.
56+
@pytest.mark.parametrize(
57+
("array_func", "dtype"),
58+
[
59+
pytest.param(np.array, {"dtype": np.str_}, id="str"),
60+
pytest.param(np.array, {"dtype": np.object_}, id="object"),
61+
pytest.param(
62+
getattr(pa, "array", None),
63+
{}, # pa.string()
64+
marks=skip_if_no(package="pyarrow"),
65+
id="pyarrow",
66+
),
67+
],
68+
)
69+
def test_virtualfile_from_vectors_one_string_or_object_column(array_func, dtype):
70+
"""
71+
Test passing in one column with string (numpy/pyarrow) or object (numpy)
72+
dtype into virtual file dataset.
6073
"""
6174
size = 5
6275
x = np.arange(size, dtype=np.int32)
6376
y = np.arange(size, size * 2, 1, dtype=np.int32)
64-
strings = np.array(["a", "bc", "defg", "hijklmn", "opqrst"], dtype=dtype)
77+
strings = array_func(["a", "bc", "defg", "hijklmn", "opqrst"], **dtype)
6578
with clib.Session() as lib:
66-
with lib.virtualfile_from_vectors((x, y, strings)) as vfile:
79+
with lib.virtualfile_from_vectors(x, y, strings) as vfile:
6780
with GMTTempFile() as outfile:
6881
lib.call_module("convert", [vfile, f"->{outfile.name}"])
6982
output = outfile.read(keep_tabs=True)

pygmt/tests/test_clib_virtualfiles.py

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -143,37 +143,3 @@ def test_open_virtual_file():
143143
bounds = "\t".join([f"<{col.min():.0f}/{col.max():.0f}>" for col in data.T])
144144
expected = f"<matrix memory>: N = {shape[0]}\t{bounds}\n"
145145
assert output == expected
146-
147-
148-
@pytest.mark.benchmark
149-
@pytest.mark.parametrize(
150-
("array_func", "dtype"),
151-
[
152-
pytest.param(np.array, {"dtype": np.str_}, id="str"),
153-
pytest.param(np.array, {"dtype": np.object_}, id="object"),
154-
pytest.param(
155-
getattr(pa, "array", None),
156-
{}, # pa.string()
157-
marks=skip_if_no(package="pyarrow"),
158-
id="pyarrow",
159-
),
160-
],
161-
)
162-
def test_virtualfile_from_vectors_one_string_or_object_column(array_func, dtype):
163-
"""
164-
Test passing in one column with string (numpy/pyarrow) or object (numpy)
165-
dtype into virtual file dataset.
166-
"""
167-
size = 5
168-
x = np.arange(size, dtype=np.int32)
169-
y = np.arange(size, size * 2, 1, dtype=np.int32)
170-
strings = array_func(["a", "bc", "defg", "hijklmn", "opqrst"], **dtype)
171-
with clib.Session() as lib:
172-
with lib.virtualfile_from_vectors(x, y, strings) as vfile:
173-
with GMTTempFile() as outfile:
174-
lib.call_module("convert", [vfile, f"->{outfile.name}"])
175-
output = outfile.read(keep_tabs=True)
176-
expected = "".join(
177-
f"{i}\t{j}\t{k}\n" for i, j, k in zip(x, y, strings, strict=True)
178-
)
179-
assert output == expected

0 commit comments

Comments
 (0)