Skip to content

Commit

Permalink
Merge branch 'main' into changelog-0.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
seisman authored Jun 30, 2022
2 parents 325022a + cfbc3bb commit 8134b7d
Show file tree
Hide file tree
Showing 13 changed files with 9 additions and 113 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
steps:
# Cancel previous runs that are not completed
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.9.1
uses: styfle/cancel-workflow-action@0.10.0
with:
access_token: ${{ github.token }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
steps:
# Cancel previous runs that are not completed
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.9.1
uses: styfle/cancel-workflow-action@0.10.0
with:
access_token: ${{ github.token }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_tests_dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
steps:
# Cancel previous runs that are not completed
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.9.1
uses: styfle/cancel-workflow-action@0.10.0
with:
access_token: ${{ github.token }}

Expand Down
1 change: 0 additions & 1 deletion pygmt/helpers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
Functions, classes, decorators, and context managers to help wrap GMT modules.
"""
from pygmt.helpers.decorators import (
check_data_input_order,
deprecate_parameter,
fmt_docstring,
kwargs_to_strings,
Expand Down
68 changes: 0 additions & 68 deletions pygmt/helpers/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -806,71 +806,3 @@ def new_module(*args, **kwargs):
return new_module

return deprecator


def check_data_input_order(deprecate_version, remove_version):
"""
Decorator to raise a FutureWarning if the order of data input parameters
changes and positional arguments are passed.
The decorator is temporary and should be removed in v0.7.0.
Parameters
----------
deprecate_version : str
The PyGMT version when the order of data input parameters is changed.
remove_version : str
The PyGMT version when the deprecation warning should be removed.
Examples
--------
>>> @check_data_input_order("v0.0.0", "v9.9.9")
... def module(data=None, x=None, y=None, z=None, **kwargs):
... "A module that prints the arguments it received"
... print(f"data={data}, x={x}, y={y}, z={z}")
>>> module(data="table.txt")
data=table.txt, x=None, y=None, z=None
>>> module(x=0, y=1, z=2)
data=None, x=0, y=1, z=2
>>> with warnings.catch_warnings(record=True) as w:
... module(0, 1, 2)
... assert len(w) == 1
... assert issubclass(w[0].category, FutureWarning)
...
data=0, x=1, y=2, z=None
"""

def data_input_order_checker(module_func):
"""
The decorator that creates the new function to check if positional
arguments are passed.
"""

@functools.wraps(module_func)
def new_module(*args, **kwargs):
"""
New module instance that raises a warning if positional arguments
are passed.
"""
# Plotting functions always have a "self" parameter
# which is a pygmt.Figure instance that has a "savefig" method
if len(args) > 1 and hasattr(args[0], "savefig"):
plotting_func = 1
else:
plotting_func = 0

if len(args) > 1 + plotting_func:
# more than one positional arguments are used
msg = (
"The function parameters has been re-ordered as 'data, x, y, [z]' "
f"since {deprecate_version} but you're passing positional arguments. "
"You can silence the warning by passing keyword arguments "
"like 'x=x, y=y, z=z'. Otherwise, the warning will be removed "
f"in {remove_version}."
)
warnings.warn(msg, category=FutureWarning, stacklevel=2)
return module_func(*args, **kwargs)

return new_module

return data_input_order_checker
4 changes: 0 additions & 4 deletions pygmt/src/blockm.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from pygmt.helpers import (
GMTTempFile,
build_arg_string,
check_data_input_order,
fmt_docstring,
kwargs_to_strings,
use_alias,
Expand Down Expand Up @@ -70,7 +69,6 @@ def _blockm(block_method, data, x, y, z, outfile, **kwargs):


@fmt_docstring
@check_data_input_order("v0.5.0", remove_version="v0.7.0")
@use_alias(
I="spacing",
R="region",
Expand Down Expand Up @@ -168,7 +166,6 @@ def blockmean(data=None, x=None, y=None, z=None, outfile=None, **kwargs):


@fmt_docstring
@check_data_input_order("v0.5.0", remove_version="v0.7.0")
@use_alias(
I="spacing",
R="region",
Expand Down Expand Up @@ -256,7 +253,6 @@ def blockmedian(data=None, x=None, y=None, z=None, outfile=None, **kwargs):


@fmt_docstring
@check_data_input_order("v0.5.0", remove_version="v0.7.0")
@use_alias(
I="spacing",
R="region",
Expand Down
9 changes: 1 addition & 8 deletions pygmt/src/contour.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,10 @@
"""

from pygmt.clib import Session
from pygmt.helpers import (
build_arg_string,
check_data_input_order,
fmt_docstring,
kwargs_to_strings,
use_alias,
)
from pygmt.helpers import build_arg_string, fmt_docstring, kwargs_to_strings, use_alias


@fmt_docstring
@check_data_input_order("v0.5.0", remove_version="v0.7.0")
@use_alias(
A="annotation",
B="frame",
Expand Down
2 changes: 0 additions & 2 deletions pygmt/src/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from pygmt.exceptions import GMTInvalidInput
from pygmt.helpers import (
build_arg_string,
check_data_input_order,
data_kind,
fmt_docstring,
is_nonstr_iter,
Expand All @@ -16,7 +15,6 @@


@fmt_docstring
@check_data_input_order("v0.5.0", remove_version="v0.7.0")
@use_alias(
A="straight_line",
B="frame",
Expand Down
2 changes: 0 additions & 2 deletions pygmt/src/plot3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from pygmt.exceptions import GMTInvalidInput
from pygmt.helpers import (
build_arg_string,
check_data_input_order,
data_kind,
fmt_docstring,
is_nonstr_iter,
Expand All @@ -16,7 +15,6 @@


@fmt_docstring
@check_data_input_order("v0.5.0", remove_version="v0.7.0")
@use_alias(
A="straight_line",
B="frame",
Expand Down
9 changes: 1 addition & 8 deletions pygmt/src/rose.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,10 @@
"""

from pygmt.clib import Session
from pygmt.helpers import (
build_arg_string,
check_data_input_order,
fmt_docstring,
kwargs_to_strings,
use_alias,
)
from pygmt.helpers import build_arg_string, fmt_docstring, kwargs_to_strings, use_alias


@fmt_docstring
@check_data_input_order("v0.5.0", remove_version="v0.7.0")
@use_alias(
A="sector",
B="frame",
Expand Down
2 changes: 0 additions & 2 deletions pygmt/src/surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from pygmt.helpers import (
GMTTempFile,
build_arg_string,
check_data_input_order,
fmt_docstring,
kwargs_to_strings,
use_alias,
Expand All @@ -17,7 +16,6 @@


@fmt_docstring
@check_data_input_order("v0.5.0", remove_version="v0.7.0")
@use_alias(
I="spacing",
R="region",
Expand Down
9 changes: 1 addition & 8 deletions pygmt/src/wiggle.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,10 @@
wiggle - Plot z=f(x,y) anomalies along tracks.
"""
from pygmt.clib import Session
from pygmt.helpers import (
build_arg_string,
check_data_input_order,
fmt_docstring,
kwargs_to_strings,
use_alias,
)
from pygmt.helpers import build_arg_string, fmt_docstring, kwargs_to_strings, use_alias


@fmt_docstring
@check_data_input_order("v0.5.0", remove_version="v0.7.0")
@use_alias(
B="frame",
D="position",
Expand Down
10 changes: 3 additions & 7 deletions pygmt/tests/test_filter1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,17 @@
import pandas as pd
import pytest
from pygmt import filter1d
from pygmt.datasets import load_sample_data
from pygmt.exceptions import GMTInvalidInput
from pygmt.helpers import GMTTempFile
from pygmt.src import which


@pytest.fixture(scope="module", name="data")
def fixture_table():
"""
Load the grid data from the sample earth_relief file.
Load the @MaunaLoa_CO2.txt dataset as a pandas dataframe.
"""
fname = which("@MaunaLoa_CO2.txt", download="c")
data = pd.read_csv(
fname, header=None, skiprows=1, sep=r"\s+", names=["date", "co2_ppm"]
)
return data
return load_sample_data(name="maunaloa_co2")


def test_filter1d_no_outfile(data):
Expand Down

0 comments on commit 8134b7d

Please sign in to comment.