Skip to content

Commit

Permalink
Merge branch 'main' into timestamp/deprecate-justify
Browse files Browse the repository at this point in the history
  • Loading branch information
seisman committed Jan 17, 2024
2 parents eed500a + 6d5c466 commit bcb668d
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:

- name: Link Checker
id: lychee
uses: lycheeverse/[email protected].0
uses: lycheeverse/[email protected].1
with:
# 429: Too many requests
args: >
Expand Down
6 changes: 1 addition & 5 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@ build:
then
exit 183;
fi
pre_build:
# ReadTheDocs fails to download external resources.
# Temporarily delete the two files to make ReadTheDocs building work again.
- rm examples/gallery/lines/roads.py examples/gallery/maps/choropleth_map.py
# Generate api stub files before building
pre_build: # Generate api stub files before building
- make -C doc api

# Build documentation in the doc/ directory with Sphinx
Expand Down
2 changes: 1 addition & 1 deletion doc/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,6 @@ Low level access (these are mostly used by the :mod:`pygmt.clib` package):
clib.Session.put_strings
clib.Session.put_vector
clib.Session.write_data
clib.Session.open_virtual_file
clib.Session.open_virtualfile
clib.Session.extract_region
clib.Session.get_libgmt_func
33 changes: 25 additions & 8 deletions pygmt/clib/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,7 @@ def write_data(self, family, geometry, mode, wesn, output, data):
raise GMTCLibError(f"Failed to write dataset to '{output}'")

@contextlib.contextmanager
def open_virtual_file(self, family, geometry, direction, data):
def open_virtualfile(self, family, geometry, direction, data):
"""
Open a GMT virtual file to pass data to and from a module.
Expand Down Expand Up @@ -1142,7 +1142,7 @@ def open_virtual_file(self, family, geometry, direction, data):
... lib.put_vector(dataset, column=1, vector=y)
... # Add the dataset to a virtual file
... vfargs = (family, geometry, "GMT_IN|GMT_IS_REFERENCE", dataset)
... with lib.open_virtual_file(*vfargs) as vfile:
... with lib.open_virtualfile(*vfargs) as vfile:
... # Send the output to a temp file so that we can read it
... with GMTTempFile() as ofile:
... args = f"{vfile} ->{ofile.name}"
Expand Down Expand Up @@ -1190,6 +1190,23 @@ def open_virtual_file(self, family, geometry, direction, data):
if status != 0:
raise GMTCLibError(f"Failed to close virtual file '{vfname}'.")

def open_virtual_file(self, family, geometry, direction, data):
"""
Open a GMT virtual file to pass data to and from a module.
.. deprecated: 0.11.0
Will be removed in v0.15.0. Use :meth:`pygmt.clib.Session.open_virtualfile`
instead.
"""
msg = (
"API function `Session.open_virtual_file()' has been deprecated "
"since v0.11.0 and will be removed in v0.15.0. "
"Use `Session.open_virtualfile()' instead."
)
warnings.warn(msg, category=FutureWarning, stacklevel=2)
return self.open_virtualfile(family, geometry, direction, data)

@contextlib.contextmanager
def virtualfile_from_vectors(self, *vectors):
"""
Expand All @@ -1205,7 +1222,7 @@ def virtualfile_from_vectors(self, *vectors):
Use this instead of creating the data container and virtual file by
hand with :meth:`pygmt.clib.Session.create_data`,
:meth:`pygmt.clib.Session.put_vector`, and
:meth:`pygmt.clib.Session.open_virtual_file`.
:meth:`pygmt.clib.Session.open_virtualfile`.
If the arrays are C contiguous blocks of memory, they will be passed
without copying to GMT. If they are not (e.g., they are columns of a
Expand Down Expand Up @@ -1286,7 +1303,7 @@ def virtualfile_from_vectors(self, *vectors):
dataset, family="GMT_IS_VECTOR|GMT_IS_DUPLICATE", strings=strings
)

with self.open_virtual_file(
with self.open_virtualfile(
family, geometry, "GMT_IN|GMT_IS_REFERENCE", dataset
) as vfile:
yield vfile
Expand All @@ -1313,7 +1330,7 @@ def virtualfile_from_matrix(self, matrix):
Use this instead of creating the data container and virtual file by
hand with :meth:`pygmt.clib.Session.create_data`,
:meth:`pygmt.clib.Session.put_matrix`, and
:meth:`pygmt.clib.Session.open_virtual_file`
:meth:`pygmt.clib.Session.open_virtualfile`
The matrix must be C contiguous in memory. If it is not (e.g., it is a
slice of a larger array), the array will be copied to make sure it is.
Expand Down Expand Up @@ -1366,7 +1383,7 @@ def virtualfile_from_matrix(self, matrix):

self.put_matrix(dataset, matrix)

with self.open_virtual_file(
with self.open_virtualfile(
family, geometry, "GMT_IN|GMT_IS_REFERENCE", dataset
) as vfile:
yield vfile
Expand All @@ -1389,7 +1406,7 @@ def virtualfile_from_grid(self, grid):
Use this instead of creating a data container and virtual file by hand
with :meth:`pygmt.clib.Session.create_data`,
:meth:`pygmt.clib.Session.put_matrix`, and
:meth:`pygmt.clib.Session.open_virtual_file`
:meth:`pygmt.clib.Session.open_virtualfile`.
The grid data matrix must be C contiguous in memory. If it is not
(e.g., it is a slice of a larger array), the array will be copied to
Expand Down Expand Up @@ -1453,7 +1470,7 @@ def virtualfile_from_grid(self, grid):
)
self.put_matrix(gmt_grid, matrix)
args = (family, geometry, "GMT_IN|GMT_IS_REFERENCE", gmt_grid)
with self.open_virtual_file(*args) as vfile:
with self.open_virtualfile(*args) as vfile:
yield vfile

@fmt_docstring
Expand Down
4 changes: 2 additions & 2 deletions pygmt/src/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ def text_( # noqa: PLR0912
[*dx/dy*][**+to**\|\ **O**\|\ **c**\|\ **C**].
Adjust the clearance between the text and the surrounding box
[Default is 15% of the font size]. Only used if ``pen`` or ``fill``
are specified. Append the unit you want (*c* for centimeters,
*i* for inches, or *p* for points; if not given we consult
are specified. Append the unit you want (**c** for centimeters,
**i** for inches, or **p** for points; if not given we consult
:gmt-term:`PROJ_LENGTH_UNIT`) or *%* for a percentage of the font
size. Optionally, use modifier **+t** to set the shape of the text
box when using ``fill`` and/or ``pen``. Append lower case **o**
Expand Down
2 changes: 1 addition & 1 deletion pygmt/src/tilemap.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def tilemap(
**kwargs,
):
r"""
Plots an XYZ tile map.
Plot an XYZ tile map.
This method loads XYZ tile maps from a tile server or local file using
:func:`pygmt.datasets.load_tile_map` into a georeferenced form, and plots
Expand Down
8 changes: 4 additions & 4 deletions pygmt/tests/test_clib_virtualfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def test_virtual_file(dtypes):
lib.put_matrix(dataset, matrix=data)
# Add the dataset to a virtual file and pass it along to gmt info
vfargs = (family, geometry, "GMT_IN|GMT_IS_REFERENCE", dataset)
with lib.open_virtual_file(*vfargs) as vfile:
with lib.open_virtualfile(*vfargs) as vfile:
with GMTTempFile() as outfile:
lib.call_module("info", f"{vfile} ->{outfile.name}")
output = outfile.read(keep_tabs=True)
Expand All @@ -93,7 +93,7 @@ def test_virtual_file_fails():
# virtual file.
with clib.Session() as lib, mock(lib, "GMT_Open_VirtualFile", returns=1):
with pytest.raises(GMTCLibError):
with lib.open_virtual_file(*vfargs):
with lib.open_virtualfile(*vfargs):
pass

# Test the status check when closing the virtual file
Expand All @@ -103,7 +103,7 @@ def test_virtual_file_fails():
lib, "GMT_Close_VirtualFile", returns=1
):
with pytest.raises(GMTCLibError):
with lib.open_virtual_file(*vfargs):
with lib.open_virtualfile(*vfargs):
pass


Expand All @@ -119,7 +119,7 @@ def test_virtual_file_bad_direction():
0,
)
with pytest.raises(GMTInvalidInput):
with lib.open_virtual_file(*vfargs):
with lib.open_virtualfile(*vfargs):
pass


Expand Down

0 comments on commit bcb668d

Please sign in to comment.