Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
seisman committed Aug 6, 2024
1 parent 9da6cef commit 9f4ca3e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 21 deletions.
1 change: 0 additions & 1 deletion pygmt/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,6 @@ def _repr_html_(self):
wiggle,
)


def set_display(method=None):
"""
Set the display method when calling :meth:`pygmt.Figure.show`.
Expand Down
35 changes: 15 additions & 20 deletions pygmt/src/shift_origin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@
shift_origin - Shift plot origin in x and/or y directions.
"""

from __future__ import annotations

from pygmt import Figure
from pygmt.clib import Session
from pygmt.helpers import build_arg_list


class shift_origin(Figure): # noqa: N801
class shift_origin: # noqa: N801
r"""
Shift plot origin in x and/or y directions.
Expand Down Expand Up @@ -61,32 +58,30 @@ class shift_origin(Figure): # noqa: N801
def __init__(
self, xshift: float | str | None = None, yshift: float | str | None = None
):
"""
Shift the plot origin in x/y directions and store the shift values.
"""
# self._preprocess() # pylint: disable=protected-access

kwargs = {"T": True}
if xshift:
kwargs["X"] = xshift
if yshift:
kwargs["Y"] = yshift
kwdict = {"T": True, "X": xshift, "Y": yshift}
with Session() as lib:
lib.call_module(module="plot", args=build_arg_list(kwargs))
self.saved_xshift = lib.get_common("X") # False or xshift in inches
self.saved_yshift = lib.get_common("Y") # False or yshift in inches
lib.call_module(module="plot", args=build_arg_list(kwdict))
self._xshift = lib.get_common("X") # False or xshift in inches
self._yshift = lib.get_common("Y") # False or yshift in inches

def __enter__(self):
"""
Enter the context manager.
Do nothing but return self.
"""
return self

Check warning on line 75 in pygmt/src/shift_origin.py

View check run for this annotation

Codecov / codecov/patch

pygmt/src/shift_origin.py#L75

Added line #L75 was not covered by tests

def __exit__(self, exc_type, exc_value, traceback):
"""
Exit the context manager.
"""
kwargs = {"T": True}
if self.saved_xshift:
kwargs["X"] = f"{-1.0 * self.saved_xshift}i"
if self.saved_yshift:
kwargs["Y"] = f"{-1.0 * self.saved_yshift}i"
kwdict = {

Check warning on line 81 in pygmt/src/shift_origin.py

View check run for this annotation

Codecov / codecov/patch

pygmt/src/shift_origin.py#L81

Added line #L81 was not covered by tests
"T": True,
"X": f"{-1.0 * self._xshift}i" if self._xshift else None,
"Y": f"{-1.0 * self._yshift}i" if self._yshift else None,
}
with Session() as lib:
lib.call_module(module="plot", args=build_arg_list(kwargs))
lib.call_module(module="plot", args=build_arg_list(kwdict))

Check warning on line 87 in pygmt/src/shift_origin.py

View check run for this annotation

Codecov / codecov/patch

pygmt/src/shift_origin.py#L86-L87

Added lines #L86 - L87 were not covered by tests

0 comments on commit 9f4ca3e

Please sign in to comment.