Skip to content

Commit

Permalink
Merge pull request #7340 from nabobalis/deps_peek
Browse files Browse the repository at this point in the history
Removed positional argument support for timeseries peek
  • Loading branch information
nabobalis committed Jan 4, 2024
2 parents 235792b + 5bfd931 commit 1755dab
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 26 deletions.
1 change: 1 addition & 0 deletions changelog/7340.breaking.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Arguments for :meth:`sunpy.timeseries.GenericTimeSeries.peek` are now keywords only.
7 changes: 7 additions & 0 deletions docs/whatsnew/6.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,10 @@ Removal of ``sunpy.net.helioviewer.HelioViewerClient``
Users should instead use the `hvpy <https://hvpy.readthedocs.io/en/latest/>`__ package.
This package provides a Python wrapper around the Helioviewer API and is maintained by the Helioviewer Project.
The ``hvpy`` package supersedes the ``sunpy.net.helioviewer`` module.

Arguments for :meth:`sunpy.timeseries.GenericTimeSeries.peek` are now keywords only
-----------------------------------------------------------------------------------

The arguments for :meth:`sunpy.timeseries.GenericTimeSeries.peek` have been changed to be keyword only.
This means that you must now specify the arguments by name, rather than by position and has been done to make the API more consistent.
This has been raising a warning since sunpy 4.1 and is now an error.
3 changes: 0 additions & 3 deletions sunpy/timeseries/sources/eve.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import sunpy.io
from sunpy.time import parse_time
from sunpy.timeseries.timeseriesbase import GenericTimeSeries
from sunpy.util.decorators import deprecate_positional_args_since
from sunpy.util.exceptions import warn_deprecated
from sunpy.util.metadata import MetaDict
from sunpy.visualization import peek_show
Expand Down Expand Up @@ -90,7 +89,6 @@ def plot(self, axes=None, columns=None, **kwargs):
return axes

@peek_show
@deprecate_positional_args_since("4.1")
def peek(self, *, title="EVE/ESP Level 1", columns=None, **kwargs):
"""
Displays the EVE ESP Level 1 timeseries data by calling
Expand Down Expand Up @@ -198,7 +196,6 @@ class EVESpWxTimeSeries(GenericTimeSeries):
_url = "http://lasp.colorado.edu/home/eve/"

@peek_show
@deprecate_positional_args_since("4.1")
def peek(self, *, columns=None, **kwargs):
"""
Plots the time series in a new figure.
Expand Down
2 changes: 0 additions & 2 deletions sunpy/timeseries/sources/fermi_gbm.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import sunpy.io
from sunpy.time import parse_time
from sunpy.timeseries.timeseriesbase import GenericTimeSeries
from sunpy.util.decorators import deprecate_positional_args_since
from sunpy.util.metadata import MetaDict
from sunpy.visualization import peek_show

Expand Down Expand Up @@ -96,7 +95,6 @@ def plot(self, axes=None, columns=None, **kwargs):
return axes

@peek_show
@deprecate_positional_args_since("4.1")
def peek(self, *, title=None, columns=None, **kwargs):
"""
Displays the GBM timeseries by calling
Expand Down
2 changes: 0 additions & 2 deletions sunpy/timeseries/sources/lyra.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from sunpy import config
from sunpy.time import parse_time
from sunpy.timeseries.timeseriesbase import GenericTimeSeries
from sunpy.util.decorators import deprecate_positional_args_since
from sunpy.util.metadata import MetaDict
from sunpy.visualization import peek_show

Expand Down Expand Up @@ -95,7 +94,6 @@ def plot(self, axes=None, columns=None, names=3, **kwargs):
return axes

@peek_show
@deprecate_positional_args_since("4.1")
def peek(self, *, title=None, columns=None, names=3, **kwargs):
"""
Displays the LYRA data by calling `~sunpy.timeseries.sources.lyra.LYRATimeSeries.plot`.
Expand Down
2 changes: 0 additions & 2 deletions sunpy/timeseries/sources/noaa.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import astropy.units as u

from sunpy.timeseries.timeseriesbase import GenericTimeSeries
from sunpy.util.decorators import deprecate_positional_args_since
from sunpy.util.metadata import MetaDict
from sunpy.visualization import peek_show

Expand Down Expand Up @@ -109,7 +108,6 @@ def plot(self, axes=None, plot_type='sunspot SWO', columns=None, **kwargs):
return axes

@peek_show
@deprecate_positional_args_since("4.1")
def peek(self, *, title="Solar Cycle Progression", plot_type='sunspot SWO', columns=None, **kwargs):
"""
Displays the NOAA Indices as a function of time by calling
Expand Down
2 changes: 0 additions & 2 deletions sunpy/timeseries/sources/norh.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from sunpy import config
from sunpy.time import parse_time
from sunpy.timeseries.timeseriesbase import GenericTimeSeries
from sunpy.util.decorators import deprecate_positional_args_since
from sunpy.util.metadata import MetaDict
from sunpy.visualization import peek_show

Expand Down Expand Up @@ -89,7 +88,6 @@ def plot(self, axes=None, columns=None, **kwargs):
return axes

@peek_show
@deprecate_positional_args_since("4.1")
def peek(self, *, title="Nobeyama Radioheliograph", columns=None, **kwargs):
"""
Displays the NoRH lightcurve TimeSeries by calling
Expand Down
8 changes: 1 addition & 7 deletions sunpy/timeseries/sources/tests/test_eve.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import re

import pytest

import sunpy.timeseries
from sunpy.data.test import get_test_filepath
from sunpy.tests.helpers import figure_test
from sunpy.util.exceptions import SunpyDeprecationWarning, SunpyUserWarning
from sunpy.util.exceptions import SunpyUserWarning

esp_filepath = get_test_filepath('eve_l1_esp_2011046_00_truncated.fits')
eve_filepath = get_test_filepath('EVE_L0CS_DIODES_1m_truncated.txt')
Expand Down Expand Up @@ -38,11 +37,6 @@ def test_esp_plot_column(esp_test_ts):
assert '36nm' in axes[2].get_ylabel()


def test_esp_peek_keyword_deprecation(esp_test_ts):
with pytest.warns(SunpyDeprecationWarning, match=re.escape('Pass title= as keyword args')):
esp_test_ts.peek('')


@figure_test
def test_esp_peek(esp_test_ts):
esp_test_ts.peek()
Expand Down
7 changes: 1 addition & 6 deletions sunpy/timeseries/tests/test_timeseriesbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from sunpy.tests.helpers import figure_test
from sunpy.time import TimeRange, parse_time
from sunpy.timeseries import TimeSeriesMetaData
from sunpy.util import SunpyDeprecationWarning, SunpyUserWarning
from sunpy.util import SunpyUserWarning
from sunpy.util.metadata import MetaDict

# Test fixtures are in ../conftest.py
Expand Down Expand Up @@ -550,11 +550,6 @@ def test_timeseries_array():
assert isinstance(ts, sunpy.timeseries.GenericTimeSeries)


def test_deprecated_positional_peek_args(many_ts):
# Check that all positional arguments to peek() are deprecated
with pytest.warns(SunpyDeprecationWarning, match='passing these as positional arguments will result in an error'):
many_ts.peek(many_ts.columns[0:1])

# TODO:
# _validate_units
# _validate_meta
Expand Down
2 changes: 0 additions & 2 deletions sunpy/timeseries/timeseriesbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
from sunpy.time import TimeRange
from sunpy.timeseries import TimeSeriesMetaData
from sunpy.util.datatype_factory_base import NoMatchError
from sunpy.util.decorators import deprecate_positional_args_since
from sunpy.util.exceptions import warn_user
from sunpy.util.metadata import MetaDict
from sunpy.util.util import _figure_to_base64
Expand Down Expand Up @@ -751,7 +750,6 @@ def _setup_x_axis(ax):
ax.xaxis.set_major_formatter(mdates.ConciseDateFormatter(locator))

@peek_show
@deprecate_positional_args_since("4.1")
def peek(self, *, columns=None, title=None, **kwargs):
"""
Displays a graphical overview of the data in this object for user evaluation.
Expand Down

0 comments on commit 1755dab

Please sign in to comment.