Skip to content

Commit 723cac6

Browse files
authored
Session.virtualfile_from_vectors: Remove the deprecated '*args' parameter [deprecated since v0.14.0] (#3893)
1 parent 1b71e0b commit 723cac6

File tree

2 files changed

+1
-43
lines changed

2 files changed

+1
-43
lines changed

pygmt/clib/session.py

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,9 +1390,7 @@ def open_virtualfile(
13901390
raise GMTCLibError(msg)
13911391

13921392
@contextlib.contextmanager
1393-
def virtualfile_from_vectors(
1394-
self, vectors: Sequence, *args
1395-
) -> Generator[str, None, None]:
1393+
def virtualfile_from_vectors(self, vectors: Sequence) -> Generator[str, None, None]:
13961394
"""
13971395
Store a sequence of 1-D vectors as columns of a dataset inside a virtual file.
13981396
@@ -1438,21 +1436,6 @@ def virtualfile_from_vectors(
14381436
... print(fout.read().strip())
14391437
<vector memory>: N = 3 <1/3> <4/6> <7/9>
14401438
"""
1441-
# TODO(PyGMT>=0.16.0): Remove the "*args" parameter and related codes.
1442-
# "*args" is added in v0.14.0 for backward-compatibility with the deprecated
1443-
# syntax of passing multiple vectors as positional arguments.
1444-
if len(args) > 0:
1445-
msg = (
1446-
"Passing multiple arguments to Session.virtualfile_from_vectors is "
1447-
"deprecated since v0.14.0 and will be unsupported in v0.16.0. "
1448-
"Put all vectors in a sequence (a tuple or a list) instead and pass "
1449-
"the sequence as the single argument to this function. "
1450-
"E.g., use `with lib.virtualfile_from_vectors((x, y, z)) as vfile` "
1451-
"instead of `with lib.virtualfile_from_vectors(x, y, z) as vfile`."
1452-
)
1453-
warnings.warn(message=msg, category=FutureWarning, stacklevel=3)
1454-
vectors = (vectors, *args)
1455-
14561439
# Conversion to a C-contiguous array needs to be done here and not in put_vector
14571440
# or put_strings because we need to maintain a reference to the copy while it is
14581441
# being used by the C API. Otherwise, the array would be garbage collected and

pygmt/tests/test_clib_virtualfile_from_vectors.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -190,28 +190,3 @@ def test_virtualfile_from_vectors_arraylike():
190190
bounds = "\t".join([f"<{min(i):.0f}/{max(i):.0f}>" for i in (x, y, z)])
191191
expected = f"<vector memory>: N = {size}\t{bounds}\n"
192192
assert output == expected
193-
194-
195-
# TODO(PyGMT>=0.16.0): Remove this test in PyGMT v0.16.0 in which the "*args" parameter
196-
# will be removed.
197-
def test_virtualfile_from_vectors_args():
198-
"""
199-
Test the backward compatibility of the deprecated syntax for passing multiple
200-
vectors.
201-
202-
This test is the same as test_virtualfile_from_vectors_arraylike, but using the
203-
old syntax.
204-
"""
205-
size = 13
206-
x = list(range(0, size, 1))
207-
y = tuple(range(size, size * 2, 1))
208-
z = range(size * 2, size * 3, 1)
209-
with pytest.warns(FutureWarning, match="virtualfile_from_vectors"):
210-
with clib.Session() as lib:
211-
with lib.virtualfile_from_vectors(x, y, z) as vfile:
212-
with GMTTempFile() as outfile:
213-
lib.call_module("info", [vfile, f"->{outfile.name}"])
214-
output = outfile.read(keep_tabs=True)
215-
bounds = "\t".join([f"<{min(i):.0f}/{max(i):.0f}>" for i in (x, y, z)])
216-
expected = f"<vector memory>: N = {size}\t{bounds}\n"
217-
assert output == expected

0 commit comments

Comments
 (0)