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 16 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
65 changes: 65 additions & 0 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 @@ -1334,6 +1354,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 +1401,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 +1440,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 +1470,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 +1566,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 +1621,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 +1672,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 +1709,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 @@ -1892,6 +1952,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
38 changes: 38 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 Down
Loading