Skip to content

Commit 3ca669d

Browse files
ESadek-MOpre-commit-ci[bot]bjlittle
authored
Finalises Lazy Data documentation (#5137)
* cube and io lazy data notes added * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Added comments within analysis, as well as palette and iterate, and what's new * fixed docstrings as requested in @trexfeathers review * reverted cube.py for time being * fixed flake8 issue * Lazy data second batch * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * updated lastest what'snew * I almost hope this wasn't the fix, I'm such a moron * adressed review changes --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Bill Little <bill.james.little@gmail.com>
1 parent 5585684 commit 3ca669d

File tree

6 files changed

+295
-6
lines changed

6 files changed

+295
-6
lines changed

docs/src/whatsnew/latest.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ This document explains the changes made to Iris for this release
135135

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

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

139141
💼 Internal
140142
===========

lib/iris/analysis/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2036,6 +2036,7 @@ def interp_order(length):
20362036
20372037
result = cube.collapsed('longitude', iris.analysis.MEDIAN)
20382038
2039+
20392040
This aggregator handles masked data, but NOT lazy data. For lazy aggregation,
20402041
please try :obj:`~.PERCENTILE`.
20412042

lib/iris/pandas.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ def as_cube(
159159
as_cube(series, calendars={0: cf_units.CALENDAR_360_DAY})
160160
as_cube(data_frame, calendars={1: cf_units.CALENDAR_STANDARD})
161161
162+
Since this function converts to/from a Pandas object, laziness will not be preserved.
163+
162164
"""
163165
message = (
164166
"iris.pandas.as_cube has been deprecated, and will be removed in a "
@@ -240,6 +242,8 @@ def as_cubes(
240242
241243
:class:`dask.dataframe.DataFrame`\\ s are not supported.
242244
245+
Since this function converts to/from a Pandas object, laziness will not be preserved.
246+
243247
Examples
244248
--------
245249
>>> from iris.pandas import as_cubes
@@ -599,6 +603,10 @@ def as_series(cube, copy=True):
599603
If you have a large array that cannot be copied,
600604
make sure it is not masked and use copy=False.
601605
606+
Notes
607+
------
608+
Since this function converts to/from a Pandas object, laziness will not be preserved.
609+
602610
"""
603611
message = (
604612
"iris.pandas.as_series has been deprecated, and will be removed in a "
@@ -809,6 +817,10 @@ def as_data_frame(
809817
419903 298.995148
810818
Name: surface_temperature, Length: 419904, dtype: float32
811819
820+
Notes
821+
------
822+
Since this function converts to/from a Pandas object, laziness will not be preserved.
823+
812824
"""
813825

814826
def merge_metadata(meta_var_list):

lib/iris/plot.py

Lines changed: 94 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,6 +1112,11 @@ def contour(cube, *args, **kwargs):
11121112
See :func:`matplotlib.pyplot.contour` for details of other valid
11131113
keyword arguments.
11141114
1115+
Notes
1116+
------
1117+
This function does not maintain laziness when called; it realises data.
1118+
See more at :doc:`/userguide/real_and_lazy_data`.
1119+
11151120
"""
11161121
result = _draw_2d_from_points("contour", None, cube, *args, **kwargs)
11171122
return result
@@ -1136,6 +1141,11 @@ def contourf(cube, *args, **kwargs):
11361141
See :func:`matplotlib.pyplot.contourf` for details of other valid
11371142
keyword arguments.
11381143
1144+
Notes
1145+
------
1146+
This function does not maintain laziness when called; it realises data.
1147+
See more at :doc:`/userguide/real_and_lazy_data`.
1148+
11391149
"""
11401150
coords = kwargs.get("coords")
11411151
kwargs.setdefault("antialiased", True)
@@ -1200,6 +1210,11 @@ def default_projection(cube):
12001210
import matplotlib.pyplot as plt
12011211
ax = plt.ax(projection=default_projection(cube))
12021212
1213+
Notes
1214+
------
1215+
This function does not maintain laziness when called; it realises data.
1216+
See more at :doc:`/userguide/real_and_lazy_data`.
1217+
12031218
"""
12041219
# XXX logic seems flawed, but it is what map_setup did...
12051220
cs = cube.coord_system("CoordSystem")
@@ -1218,6 +1233,11 @@ def default_projection_extent(cube, mode=iris.coords.POINT_MODE):
12181233
points, or the limits of the cell's bounds.
12191234
The default is iris.coords.POINT_MODE.
12201235
1236+
Notes
1237+
------
1238+
This function does not maintain laziness when called; it realises data.
1239+
See more at :doc:`/userguide/real_and_lazy_data`.
1240+
12211241
"""
12221242
extents = cartography._xy_range(cube, mode)
12231243
xlim = extents[0]
@@ -1255,7 +1275,13 @@ def _fill_orography(cube, coords, mode, vert_plot, horiz_plot, style_args):
12551275

12561276

12571277
def orography_at_bounds(cube, facecolor="#888888", coords=None, axes=None):
1258-
"""Plots orography defined at cell boundaries from the given Cube."""
1278+
"""Plots orography defined at cell boundaries from the given Cube.
1279+
1280+
Notes
1281+
------
1282+
This function does not maintain laziness when called; it realises data.
1283+
See more at :doc:`/userguide/real_and_lazy_data`.
1284+
"""
12591285

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

12891315

12901316
def orography_at_points(cube, facecolor="#888888", coords=None, axes=None):
1291-
"""Plots orography defined at sample points from the given Cube."""
1317+
"""Plots orography defined at sample points from the given Cube.
1318+
1319+
Notes
1320+
------
1321+
This function does not maintain laziness when called; it realises data.
1322+
See more at :doc:`/userguide/real_and_lazy_data`.
1323+
"""
12921324

12931325
style_args = {"facecolor": facecolor}
12941326

@@ -1334,6 +1366,11 @@ def outline(cube, coords=None, color="k", linewidth=None, axes=None):
13341366
The axes to use for drawing. Defaults to the current axes if none
13351367
provided.
13361368
1369+
Notes
1370+
------
1371+
This function does not maintain laziness when called; it realises data.
1372+
See more at :doc:`/userguide/real_and_lazy_data`.
1373+
13371374
"""
13381375
result = _draw_2d_from_bounds(
13391376
"pcolormesh",
@@ -1376,6 +1413,11 @@ def pcolor(cube, *args, **kwargs):
13761413
See :func:`matplotlib.pyplot.pcolor` for details of other valid
13771414
keyword arguments.
13781415
1416+
Notes
1417+
------
1418+
This function does not maintain laziness when called; it realises data.
1419+
See more at :doc:`/userguide/real_and_lazy_data`.
1420+
13791421
"""
13801422
kwargs.setdefault("antialiased", True)
13811423
kwargs.setdefault("snap", False)
@@ -1410,6 +1452,11 @@ def pcolormesh(cube, *args, **kwargs):
14101452
See :func:`matplotlib.pyplot.pcolormesh` for details of other
14111453
valid keyword arguments.
14121454
1455+
Notes
1456+
------
1457+
This function does not maintain laziness when called; it realises data.
1458+
See more at :doc:`/userguide/real_and_lazy_data`.
1459+
14131460
"""
14141461
result = _draw_2d_from_bounds("pcolormesh", cube, *args, **kwargs)
14151462
return result
@@ -1435,6 +1482,11 @@ def points(cube, *args, **kwargs):
14351482
See :func:`matplotlib.pyplot.scatter` for details of other valid
14361483
keyword arguments.
14371484
1485+
Notes
1486+
------
1487+
This function does not maintain laziness when called; it realises data.
1488+
See more at :doc:`/userguide/real_and_lazy_data`.
1489+
14381490
"""
14391491

14401492
def _scatter_args(u, v, data, *args, **kwargs):
@@ -1526,6 +1578,11 @@ def barbs(u_cube, v_cube, *args, **kwargs):
15261578
See :func:`matplotlib.pyplot.barbs` for details of other valid
15271579
keyword arguments.
15281580
1581+
Notes
1582+
------
1583+
This function does not maintain laziness when called; it realises data.
1584+
See more at :doc:`/userguide/real_and_lazy_data`.
1585+
15291586
"""
15301587
#
15311588
# TODO: check u + v cubes for compatibility.
@@ -1576,6 +1633,11 @@ def quiver(u_cube, v_cube, *args, **kwargs):
15761633
See :func:`matplotlib.pyplot.quiver` for details of other valid
15771634
keyword arguments.
15781635
1636+
Notes
1637+
------
1638+
This function does not maintain laziness when called; it realises data.
1639+
See more at :doc:`/userguide/real_and_lazy_data`.
1640+
15791641
"""
15801642
#
15811643
# TODO: check u + v cubes for compatibility.
@@ -1622,6 +1684,11 @@ def plot(*args, **kwargs):
16221684
See :func:`matplotlib.pyplot.plot` for details of additional valid
16231685
keyword arguments.
16241686
1687+
Notes
1688+
------
1689+
This function does not maintain laziness when called; it realises data.
1690+
See more at :doc:`/userguide/real_and_lazy_data`.
1691+
16251692
"""
16261693
if "coords" in kwargs:
16271694
raise TypeError(
@@ -1654,6 +1721,11 @@ def scatter(x, y, *args, **kwargs):
16541721
See :func:`matplotlib.pyplot.scatter` for details of additional
16551722
valid keyword arguments.
16561723
1724+
Notes
1725+
------
1726+
This function does not maintain laziness when called; it realises data.
1727+
See more at :doc:`/userguide/real_and_lazy_data`.
1728+
16571729
"""
16581730
# here we are more specific about argument types than generic 1d plotting
16591731
if not isinstance(x, (iris.cube.Cube, iris.coords.Coord)):
@@ -1689,6 +1761,11 @@ def fill_between(x, y1, y2, *args, **kwargs):
16891761
See :func:`matplotlib.pyplot.fill_between` for details of additional valid
16901762
keyword arguments.
16911763
1764+
Notes
1765+
------
1766+
This function does not maintain laziness when called; it realises data.
1767+
See more at :doc:`/userguide/real_and_lazy_data`.
1768+
16921769
"""
16931770
# here we are more specific about argument types than generic 1d plotting
16941771
if not isinstance(x, (iris.cube.Cube, iris.coords.Coord)):
@@ -1721,6 +1798,11 @@ def hist(x, *args, **kwargs):
17211798
See :func:`matplotlib.pyplot.hist` for details of additional valid
17221799
keyword arguments.
17231800
1801+
Notes
1802+
------
1803+
This function does not maintain laziness when called; it realises data.
1804+
See more at :doc:`/userguide/real_and_lazy_data`.
1805+
17241806
"""
17251807
if isinstance(x, iris.cube.Cube):
17261808
data = x.data
@@ -1767,6 +1849,11 @@ def symbols(x, y, symbols, size, axes=None, units="inches"):
17671849
* units: ['inches', 'points']
17681850
The unit for the symbol size.
17691851
1852+
Notes
1853+
------
1854+
This function does maintain laziness when called; it doesn't realise data.
1855+
See more at :doc:`/userguide/real_and_lazy_data`.
1856+
17701857
"""
17711858
if axes is None:
17721859
axes = plt.gca()
@@ -1892,6 +1979,11 @@ def animate(cube_iterator, plot_func, fig=None, **kwargs):
18921979
>>> ani = iplt.animate(cube_iter, qplt.contourf)
18931980
>>> iplt.show()
18941981
1982+
Notes
1983+
------
1984+
This function does not maintain laziness when called; it realises data.
1985+
See more at :doc:`/userguide/real_and_lazy_data`.
1986+
18951987
"""
18961988
kwargs.setdefault("interval", 100)
18971989
coords = kwargs.pop("coords", None)

lib/iris/quickplot.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,11 @@ def contour(cube, *args, **kwargs):
174174
175175
See :func:`iris.plot.contour` for details of valid keyword arguments.
176176
177+
Notes
178+
------
179+
This function does not maintain laziness when called; it realises data.
180+
See more at :doc:`/userguide/real_and_lazy_data`.
181+
177182
"""
178183
coords = kwargs.get("coords")
179184
axes = kwargs.get("axes")
@@ -201,6 +206,10 @@ def contourf(cube, *args, **kwargs):
201206
202207
See :func:`iris.plot.contourf` for details of valid keyword arguments.
203208
209+
Notes
210+
------
211+
This function does not maintain laziness when called; it realises data.
212+
See more at :doc:`/userguide/real_and_lazy_data`.
204213
"""
205214
coords = kwargs.get("coords")
206215
axes = kwargs.get("axes")
@@ -229,6 +238,11 @@ def outline(cube, coords=None, color="k", linewidth=None, axes=None):
229238
The width of the lines showing the cell outlines. If None, the default
230239
width in patch.linewidth in matplotlibrc is used.
231240
241+
Notes
242+
------
243+
This function does not maintain laziness when called; it realises data.
244+
See more at :doc:`/userguide/real_and_lazy_data`.
245+
232246
"""
233247
result = iplt.outline(
234248
cube, color=color, linewidth=linewidth, coords=coords, axes=axes
@@ -244,6 +258,10 @@ def pcolor(cube, *args, **kwargs):
244258
245259
See :func:`iris.plot.pcolor` for details of valid keyword arguments.
246260
261+
Notes
262+
------
263+
This function does not maintain laziness when called; it realises data.
264+
See more at :doc:`/userguide/real_and_lazy_data`.
247265
"""
248266
coords = kwargs.get("coords")
249267
axes = kwargs.get("axes")
@@ -258,6 +276,11 @@ def pcolormesh(cube, *args, **kwargs):
258276
259277
See :func:`iris.plot.pcolormesh` for details of valid keyword arguments.
260278
279+
Notes
280+
------
281+
This function does not maintain laziness when called; it realises data.
282+
See more at :doc:`/userguide/real_and_lazy_data`.
283+
261284
"""
262285
coords = kwargs.get("coords")
263286
axes = kwargs.get("axes")
@@ -272,6 +295,11 @@ def points(cube, *args, **kwargs):
272295
273296
See :func:`iris.plot.points` for details of valid keyword arguments.
274297
298+
Notes
299+
------
300+
This function does not maintain laziness when called; it realises data.
301+
See more at :doc:`/userguide/real_and_lazy_data`.
302+
275303
"""
276304
coords = kwargs.get("coords")
277305
axes = kwargs.get("axes")
@@ -288,6 +316,11 @@ def plot(*args, **kwargs):
288316
See :func:`iris.plot.plot` for details of valid arguments and
289317
keyword arguments.
290318
319+
Notes
320+
------
321+
This function does not maintain laziness when called; it realises data.
322+
See more at :doc:`/userguide/real_and_lazy_data`.
323+
291324
"""
292325
axes = kwargs.get("axes")
293326
result = iplt.plot(*args, **kwargs)
@@ -303,6 +336,11 @@ def scatter(x, y, *args, **kwargs):
303336
See :func:`iris.plot.scatter` for details of valid arguments and
304337
keyword arguments.
305338
339+
Notes
340+
------
341+
This function does not maintain laziness when called; it realises data.
342+
See more at :doc:`/userguide/real_and_lazy_data`.
343+
306344
"""
307345
axes = kwargs.get("axes")
308346
result = iplt.scatter(x, y, *args, **kwargs)
@@ -317,6 +355,10 @@ def fill_between(x, y1, y2, *args, **kwargs):
317355
See :func:`iris.plot.fill_between` for details of valid arguments and
318356
keyword arguments.
319357
358+
Notes
359+
------
360+
This function does not maintain laziness when called; it realises data.
361+
See more at :doc:`/userguide/real_and_lazy_data`.
320362
"""
321363
axes = kwargs.get("axes")
322364
result = iplt.fill_between(x, y1, y2, *args, **kwargs)
@@ -330,6 +372,11 @@ def hist(x, *args, **kwargs):
330372
331373
See :func:`iris.plot.hist` for details of valid arguments and
332374
keyword arguments.
375+
376+
Notes
377+
------
378+
This function does not maintain laziness when called; it realises data.
379+
See more at :doc:`/userguide/real_and_lazy_data`.
333380
"""
334381
axes = kwargs.get("axes")
335382
result = iplt.hist(x, *args, **kwargs)

0 commit comments

Comments
 (0)