Skip to content

Commit 4b9314a

Browse files
authored
clib.Session: Remove deprecated open_virtual_file method, use open_virtualfile instead (Deprecated since v0.11.0) (#3738)
1 parent 4d60eac commit 4b9314a

File tree

2 files changed

+0
-50
lines changed

2 files changed

+0
-50
lines changed

pygmt/clib/session.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,24 +1389,6 @@ def open_virtualfile(
13891389
msg = f"Failed to close virtual file '{vfname}'."
13901390
raise GMTCLibError(msg)
13911391

1392-
# TODO(PyGMT>=0.15.0): Remove the deprecated open_virtual_file method.
1393-
def open_virtual_file(self, family, geometry, direction, data):
1394-
"""
1395-
Open a GMT virtual file associated with a data object for reading or writing.
1396-
1397-
.. deprecated: 0.11.0
1398-
1399-
Will be removed in v0.15.0. Use :meth:`pygmt.clib.Session.open_virtualfile`
1400-
instead.
1401-
"""
1402-
msg = (
1403-
"API function `Session.open_virtual_file()' has been deprecated "
1404-
"since v0.11.0 and will be removed in v0.15.0. "
1405-
"Use `Session.open_virtualfile()' instead."
1406-
)
1407-
warnings.warn(msg, category=FutureWarning, stacklevel=2)
1408-
return self.open_virtualfile(family, geometry, direction, data)
1409-
14101392
@contextlib.contextmanager
14111393
def virtualfile_from_vectors(
14121394
self, vectors: Sequence, *args

pygmt/tests/test_clib_virtualfiles.py

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -107,35 +107,3 @@ def test_open_virtualfile_bad_direction():
107107
with pytest.raises(GMTInvalidInput):
108108
with lib.open_virtualfile(*vfargs):
109109
pass
110-
111-
112-
# TODO(PyGMT>=0.15.0): Remove the test after removing the deprecated open_virtual_file
113-
# method.
114-
def test_open_virtual_file():
115-
"""
116-
Test the deprecated Session.open_virtual_file method.
117-
118-
This test is the same as test_open_virtualfile, but using the deprecated method.
119-
"""
120-
shape = (5, 3)
121-
with clib.Session() as lib:
122-
family = "GMT_IS_DATASET|GMT_VIA_MATRIX"
123-
geometry = "GMT_IS_POINT"
124-
dataset = lib.create_data(
125-
family=family,
126-
geometry=geometry,
127-
mode="GMT_CONTAINER_ONLY",
128-
dim=[shape[1], shape[0], 1, 0], # columns, rows, layers, dtype
129-
)
130-
data = np.arange(shape[0] * shape[1]).reshape(shape)
131-
lib.put_matrix(dataset, matrix=data)
132-
# Add the dataset to a virtual file and pass it along to gmt info
133-
with pytest.warns(FutureWarning, match="open_virtual_file"):
134-
vfargs = (family, geometry, "GMT_IN|GMT_IS_REFERENCE", dataset)
135-
with lib.open_virtual_file(*vfargs) as vfile:
136-
with GMTTempFile() as outfile:
137-
lib.call_module("info", [vfile, f"->{outfile.name}"])
138-
output = outfile.read(keep_tabs=True)
139-
bounds = "\t".join([f"<{col.min():.0f}/{col.max():.0f}>" for col in data.T])
140-
expected = f"<matrix memory>: N = {shape[0]}\t{bounds}\n"
141-
assert output == expected

0 commit comments

Comments
 (0)