Skip to content

Commit 4d60eac

Browse files
authored
clib.Session: Remove deprecated virtualfile_from_data method, use virtualfile_in instead (Deprecated since v0.13.0) (#3739)
1 parent b1c984a commit 4d60eac

File tree

3 files changed

+0
-70
lines changed

3 files changed

+0
-70
lines changed

doc/api/index.rst

-1
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,6 @@ Low level access (these are mostly used by the :mod:`pygmt.clib` package):
335335
clib.Session.read_virtualfile
336336
clib.Session.extract_region
337337
clib.Session.get_libgmt_func
338-
clib.Session.virtualfile_from_data
339338
clib.Session.virtualfile_from_grid
340339
clib.Session.virtualfile_from_stringio
341340
clib.Session.virtualfile_from_matrix

pygmt/clib/session.py

-37
Original file line numberDiff line numberDiff line change
@@ -1920,43 +1920,6 @@ def virtualfile_in(
19201920
file_context = _virtualfile_from(_data)
19211921
return file_context
19221922

1923-
# TODO(PyGMT>=0.15.0): Remove the deprecated virtualfile_from_data method.
1924-
def virtualfile_from_data(
1925-
self,
1926-
check_kind=None,
1927-
data=None,
1928-
x=None,
1929-
y=None,
1930-
z=None,
1931-
extra_arrays=None,
1932-
required_z=False,
1933-
required_data=True,
1934-
):
1935-
"""
1936-
Store any data inside a virtual file.
1937-
1938-
.. deprecated: 0.13.0
1939-
1940-
Will be removed in v0.15.0. Use :meth:`pygmt.clib.Session.virtualfile_in`
1941-
instead.
1942-
"""
1943-
msg = (
1944-
"API function 'Session.virtualfile_from_data()' has been deprecated since "
1945-
"v0.13.0 and will be removed in v0.15.0. Use 'Session.virtualfile_in()' "
1946-
"instead."
1947-
)
1948-
warnings.warn(msg, category=FutureWarning, stacklevel=2)
1949-
return self.virtualfile_in(
1950-
check_kind=check_kind,
1951-
data=data,
1952-
x=x,
1953-
y=y,
1954-
z=z,
1955-
extra_arrays=extra_arrays,
1956-
required_z=required_z,
1957-
required_data=required_data,
1958-
)
1959-
19601923
@contextlib.contextmanager
19611924
def virtualfile_out(
19621925
self,

pygmt/tests/test_clib_virtualfile_in.py

-32
Original file line numberDiff line numberDiff line change
@@ -128,35 +128,3 @@ def test_virtualfile_in_matrix_string_dtype():
128128
assert output == "347.5 348.5 -30.5 -30\n"
129129
# Should check that lib.virtualfile_from_vectors is called once,
130130
# not lib.virtualfile_from_matrix, but it's technically complicated.
131-
132-
133-
# TODO(PyGMT>=0.16.0): Remove this test in PyGMT v0.16.0 in which the old usage of
134-
# virtualfile_from_data is removed.
135-
def test_virtualfile_from_data():
136-
"""
137-
Test the backwards compatibility of the virtualfile_from_data method.
138-
139-
This test is the same as test_virtualfile_in_required_z_matrix, but using the
140-
deprecated method.
141-
"""
142-
shape = (5, 3)
143-
dataframe = pd.DataFrame(
144-
data=np.arange(shape[0] * shape[1]).reshape(shape), columns=["x", "y", "z"]
145-
)
146-
data = np.array(dataframe)
147-
with clib.Session() as lib:
148-
with pytest.warns(FutureWarning, match="virtualfile_from_data"):
149-
with lib.virtualfile_from_data(
150-
data=data, required_z=True, check_kind="vector"
151-
) as vfile:
152-
with GMTTempFile() as outfile:
153-
lib.call_module("info", [vfile, f"->{outfile.name}"])
154-
output = outfile.read(keep_tabs=True)
155-
bounds = "\t".join(
156-
[
157-
f"<{i.min():.0f}/{i.max():.0f}>"
158-
for i in (dataframe.x, dataframe.y, dataframe.z)
159-
]
160-
)
161-
expected = f"<matrix memory>: N = {shape[0]}\t{bounds}\n"
162-
assert output == expected

0 commit comments

Comments
 (0)