Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finalises Lazy Data documentation #5137

Merged
merged 17 commits into from
Apr 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/src/whatsnew/latest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ This document explains the changes made to Iris for this release

#. `@HGWright`_ fixed some typo's from Gitwash. (:pull:`5145`)

#. `@Esadek-MO`_ added notes to function docstrings to
to clarify if the function preserves laziness or not. (:pull:`5137`)

💼 Internal
===========
Expand Down
1 change: 1 addition & 0 deletions lib/iris/analysis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2032,6 +2032,7 @@ def interp_order(length):

result = cube.collapsed('longitude', iris.analysis.MEDIAN)


This aggregator handles masked data, but NOT lazy data. For lazy aggregation,
please try :obj:`~.PERCENTILE`.

Expand Down
12 changes: 12 additions & 0 deletions lib/iris/pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ def as_cube(
as_cube(series, calendars={0: cf_units.CALENDAR_360_DAY})
as_cube(data_frame, calendars={1: cf_units.CALENDAR_STANDARD})

Since this function converts to/from a Pandas object, laziness will not be preserved.

"""
message = (
"iris.pandas.as_cube has been deprecated, and will be removed in a "
Expand Down Expand Up @@ -240,6 +242,8 @@ def as_cubes(

:class:`dask.dataframe.DataFrame`\\ s are not supported.

Since this function converts to/from a Pandas object, laziness will not be preserved.

Examples
--------
>>> from iris.pandas import as_cubes
Expand Down Expand Up @@ -599,6 +603,10 @@ def as_series(cube, copy=True):
If you have a large array that cannot be copied,
make sure it is not masked and use copy=False.

Notes
------
Since this function converts to/from a Pandas object, laziness will not be preserved.

"""
message = (
"iris.pandas.as_series has been deprecated, and will be removed in a "
Expand Down Expand Up @@ -809,6 +817,10 @@ def as_data_frame(
419903 298.995148
Name: surface_temperature, Length: 419904, dtype: float32

Notes
------
Since this function converts to/from a Pandas object, laziness will not be preserved.

"""

def merge_metadata(meta_var_list):
Expand Down
96 changes: 94 additions & 2 deletions lib/iris/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1112,6 +1112,11 @@ def contour(cube, *args, **kwargs):
See :func:`matplotlib.pyplot.contour` for details of other valid
keyword arguments.

Notes
------
This function does not maintain laziness when called; it realises data.
See more at :doc:`/userguide/real_and_lazy_data`.

"""
result = _draw_2d_from_points("contour", None, cube, *args, **kwargs)
return result
Expand All @@ -1136,6 +1141,11 @@ def contourf(cube, *args, **kwargs):
See :func:`matplotlib.pyplot.contourf` for details of other valid
keyword arguments.

Notes
------
This function does not maintain laziness when called; it realises data.
See more at :doc:`/userguide/real_and_lazy_data`.

"""
coords = kwargs.get("coords")
kwargs.setdefault("antialiased", True)
Expand Down Expand Up @@ -1200,6 +1210,11 @@ def default_projection(cube):
import matplotlib.pyplot as plt
ax = plt.ax(projection=default_projection(cube))

Notes
------
This function does not maintain laziness when called; it realises data.
See more at :doc:`/userguide/real_and_lazy_data`.

"""
# XXX logic seems flawed, but it is what map_setup did...
cs = cube.coord_system("CoordSystem")
Expand All @@ -1218,6 +1233,11 @@ def default_projection_extent(cube, mode=iris.coords.POINT_MODE):
points, or the limits of the cell's bounds.
The default is iris.coords.POINT_MODE.

Notes
------
This function does not maintain laziness when called; it realises data.
See more at :doc:`/userguide/real_and_lazy_data`.

"""
extents = cartography._xy_range(cube, mode)
xlim = extents[0]
Expand Down Expand Up @@ -1255,7 +1275,13 @@ def _fill_orography(cube, coords, mode, vert_plot, horiz_plot, style_args):


def orography_at_bounds(cube, facecolor="#888888", coords=None, axes=None):
"""Plots orography defined at cell boundaries from the given Cube."""
"""Plots orography defined at cell boundaries from the given Cube.

Notes
------
This function does not maintain laziness when called; it realises data.
See more at :doc:`/userguide/real_and_lazy_data`.
"""

# XXX Needs contiguous orography corners to work.
raise NotImplementedError(
Expand Down Expand Up @@ -1288,7 +1314,13 @@ def horiz_plot(v_coord, orography, style_args):


def orography_at_points(cube, facecolor="#888888", coords=None, axes=None):
"""Plots orography defined at sample points from the given Cube."""
"""Plots orography defined at sample points from the given Cube.

Notes
------
This function does not maintain laziness when called; it realises data.
See more at :doc:`/userguide/real_and_lazy_data`.
"""

style_args = {"facecolor": facecolor}

Expand Down Expand Up @@ -1334,6 +1366,11 @@ def outline(cube, coords=None, color="k", linewidth=None, axes=None):
The axes to use for drawing. Defaults to the current axes if none
provided.

Notes
------
This function does not maintain laziness when called; it realises data.
See more at :doc:`/userguide/real_and_lazy_data`.

"""
result = _draw_2d_from_bounds(
"pcolormesh",
Expand Down Expand Up @@ -1376,6 +1413,11 @@ def pcolor(cube, *args, **kwargs):
See :func:`matplotlib.pyplot.pcolor` for details of other valid
keyword arguments.

Notes
------
This function does not maintain laziness when called; it realises data.
See more at :doc:`/userguide/real_and_lazy_data`.

"""
kwargs.setdefault("antialiased", True)
kwargs.setdefault("snap", False)
Expand Down Expand Up @@ -1410,6 +1452,11 @@ def pcolormesh(cube, *args, **kwargs):
See :func:`matplotlib.pyplot.pcolormesh` for details of other
valid keyword arguments.

Notes
------
This function does not maintain laziness when called; it realises data.
See more at :doc:`/userguide/real_and_lazy_data`.

"""
result = _draw_2d_from_bounds("pcolormesh", cube, *args, **kwargs)
return result
Expand All @@ -1435,6 +1482,11 @@ def points(cube, *args, **kwargs):
See :func:`matplotlib.pyplot.scatter` for details of other valid
keyword arguments.

Notes
------
This function does not maintain laziness when called; it realises data.
See more at :doc:`/userguide/real_and_lazy_data`.

"""

def _scatter_args(u, v, data, *args, **kwargs):
Expand Down Expand Up @@ -1526,6 +1578,11 @@ def barbs(u_cube, v_cube, *args, **kwargs):
See :func:`matplotlib.pyplot.barbs` for details of other valid
keyword arguments.

Notes
------
This function does not maintain laziness when called; it realises data.
See more at :doc:`/userguide/real_and_lazy_data`.

"""
#
# TODO: check u + v cubes for compatibility.
Expand Down Expand Up @@ -1576,6 +1633,11 @@ def quiver(u_cube, v_cube, *args, **kwargs):
See :func:`matplotlib.pyplot.quiver` for details of other valid
keyword arguments.

Notes
------
This function does not maintain laziness when called; it realises data.
See more at :doc:`/userguide/real_and_lazy_data`.

"""
#
# TODO: check u + v cubes for compatibility.
Expand Down Expand Up @@ -1622,6 +1684,11 @@ def plot(*args, **kwargs):
See :func:`matplotlib.pyplot.plot` for details of additional valid
keyword arguments.

Notes
------
This function does not maintain laziness when called; it realises data.
See more at :doc:`/userguide/real_and_lazy_data`.

"""
if "coords" in kwargs:
raise TypeError(
Expand Down Expand Up @@ -1654,6 +1721,11 @@ def scatter(x, y, *args, **kwargs):
See :func:`matplotlib.pyplot.scatter` for details of additional
valid keyword arguments.

Notes
------
This function does not maintain laziness when called; it realises data.
See more at :doc:`/userguide/real_and_lazy_data`.

"""
# here we are more specific about argument types than generic 1d plotting
if not isinstance(x, (iris.cube.Cube, iris.coords.Coord)):
Expand Down Expand Up @@ -1689,6 +1761,11 @@ def fill_between(x, y1, y2, *args, **kwargs):
See :func:`matplotlib.pyplot.fill_between` for details of additional valid
keyword arguments.

Notes
------
This function does not maintain laziness when called; it realises data.
See more at :doc:`/userguide/real_and_lazy_data`.

"""
# here we are more specific about argument types than generic 1d plotting
if not isinstance(x, (iris.cube.Cube, iris.coords.Coord)):
Expand Down Expand Up @@ -1721,6 +1798,11 @@ def hist(x, *args, **kwargs):
See :func:`matplotlib.pyplot.hist` for details of additional valid
keyword arguments.

Notes
------
This function does not maintain laziness when called; it realises data.
See more at :doc:`/userguide/real_and_lazy_data`.

"""
if isinstance(x, iris.cube.Cube):
data = x.data
Expand Down Expand Up @@ -1767,6 +1849,11 @@ def symbols(x, y, symbols, size, axes=None, units="inches"):
* units: ['inches', 'points']
The unit for the symbol size.

Notes
------
This function does maintain laziness when called; it doesn't realise data.
See more at :doc:`/userguide/real_and_lazy_data`.

"""
if axes is None:
axes = plt.gca()
Expand Down Expand Up @@ -1892,6 +1979,11 @@ def animate(cube_iterator, plot_func, fig=None, **kwargs):
>>> ani = iplt.animate(cube_iter, qplt.contourf)
>>> iplt.show()

Notes
------
This function does not maintain laziness when called; it realises data.
See more at :doc:`/userguide/real_and_lazy_data`.

"""
bjlittle marked this conversation as resolved.
Show resolved Hide resolved
kwargs.setdefault("interval", 100)
coords = kwargs.pop("coords", None)
Expand Down
47 changes: 47 additions & 0 deletions lib/iris/quickplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,11 @@ def contour(cube, *args, **kwargs):

See :func:`iris.plot.contour` for details of valid keyword arguments.

Notes
------
This function does not maintain laziness when called; it realises data.
See more at :doc:`/userguide/real_and_lazy_data`.

"""
coords = kwargs.get("coords")
axes = kwargs.get("axes")
Expand Down Expand Up @@ -201,6 +206,10 @@ def contourf(cube, *args, **kwargs):

See :func:`iris.plot.contourf` for details of valid keyword arguments.

Notes
------
This function does not maintain laziness when called; it realises data.
See more at :doc:`/userguide/real_and_lazy_data`.
"""
coords = kwargs.get("coords")
axes = kwargs.get("axes")
Expand Down Expand Up @@ -229,6 +238,11 @@ def outline(cube, coords=None, color="k", linewidth=None, axes=None):
The width of the lines showing the cell outlines. If None, the default
width in patch.linewidth in matplotlibrc is used.

Notes
------
This function does not maintain laziness when called; it realises data.
See more at :doc:`/userguide/real_and_lazy_data`.

"""
result = iplt.outline(
cube, color=color, linewidth=linewidth, coords=coords, axes=axes
Expand All @@ -244,6 +258,10 @@ def pcolor(cube, *args, **kwargs):

See :func:`iris.plot.pcolor` for details of valid keyword arguments.

Notes
------
This function does not maintain laziness when called; it realises data.
See more at :doc:`/userguide/real_and_lazy_data`.
"""
coords = kwargs.get("coords")
axes = kwargs.get("axes")
Expand All @@ -258,6 +276,11 @@ def pcolormesh(cube, *args, **kwargs):

See :func:`iris.plot.pcolormesh` for details of valid keyword arguments.

Notes
------
This function does not maintain laziness when called; it realises data.
See more at :doc:`/userguide/real_and_lazy_data`.

"""
coords = kwargs.get("coords")
axes = kwargs.get("axes")
Expand All @@ -272,6 +295,11 @@ def points(cube, *args, **kwargs):

See :func:`iris.plot.points` for details of valid keyword arguments.

Notes
------
This function does not maintain laziness when called; it realises data.
See more at :doc:`/userguide/real_and_lazy_data`.

"""
coords = kwargs.get("coords")
axes = kwargs.get("axes")
Expand All @@ -288,6 +316,11 @@ def plot(*args, **kwargs):
See :func:`iris.plot.plot` for details of valid arguments and
keyword arguments.

Notes
------
This function does not maintain laziness when called; it realises data.
See more at :doc:`/userguide/real_and_lazy_data`.

"""
axes = kwargs.get("axes")
result = iplt.plot(*args, **kwargs)
Expand All @@ -303,6 +336,11 @@ def scatter(x, y, *args, **kwargs):
See :func:`iris.plot.scatter` for details of valid arguments and
keyword arguments.

Notes
------
This function does not maintain laziness when called; it realises data.
See more at :doc:`/userguide/real_and_lazy_data`.

"""
bjlittle marked this conversation as resolved.
Show resolved Hide resolved
axes = kwargs.get("axes")
result = iplt.scatter(x, y, *args, **kwargs)
Expand All @@ -317,6 +355,10 @@ def fill_between(x, y1, y2, *args, **kwargs):
See :func:`iris.plot.fill_between` for details of valid arguments and
keyword arguments.

Notes
------
This function does not maintain laziness when called; it realises data.
See more at :doc:`/userguide/real_and_lazy_data`.
"""
axes = kwargs.get("axes")
result = iplt.fill_between(x, y1, y2, *args, **kwargs)
Expand All @@ -330,6 +372,11 @@ def hist(x, *args, **kwargs):

See :func:`iris.plot.hist` for details of valid arguments and
keyword arguments.

Notes
------
This function does not maintain laziness when called; it realises data.
See more at :doc:`/userguide/real_and_lazy_data`.
"""
axes = kwargs.get("axes")
result = iplt.hist(x, *args, **kwargs)
Expand Down