Skip to content

Commit

Permalink
Revert "Lazy median aggregator (#6167)"
Browse files Browse the repository at this point in the history
This reverts commit 869691f.
  • Loading branch information
pp-mo authored Jan 20, 2025
1 parent e9d3cfc commit 6b14a74
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 114 deletions.
9 changes: 2 additions & 7 deletions docs/src/whatsnew/latest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ This document explains the changes made to Iris for this release
(:issue:`6248`, :pull:`6257`)


#. `@fnattino`_ added the lazy median aggregator :class:`iris.analysis.MEDIAN`
based on the implementation discussed by `@rcomer`_ and `@stefsmeets`_ in
:issue:`4039` (:pull:`6167`).


🐛 Bugs Fixed
=============
Expand Down Expand Up @@ -103,9 +99,8 @@ This document explains the changes made to Iris for this release
Whatsnew author names (@github name) in alphabetical order. Note that,
core dev names are automatically included by the common_links.inc:
.. _@fnattino: https://github.com/fnattino
.. _@jrackham-mo: https://github.com/jrackham-mo
.. _@stefsmeets: https://github.com/stefsmeets
.. comment
Whatsnew resources in alphabetical order:
20 changes: 3 additions & 17 deletions lib/iris/analysis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1612,19 +1612,6 @@ def _lazy_max_run(array, axis=-1, **kwargs):
return result


def _lazy_median(data, axis=None, **kwargs):
"""Calculate the lazy median, with support for masked arrays."""
# Dask median requires the axes to be explicitly listed.
axis = range(data.ndim) if axis is None else axis

if np.issubdtype(data, np.integer):
data = data.astype(float)
filled = da.ma.filled(data, np.nan)
result = da.nanmedian(filled, axis=axis, **kwargs)
result_masked = da.ma.fix_invalid(result)
return result_masked


def _rms(array, axis, **kwargs):
rval = np.sqrt(ma.average(array**2, axis=axis, **kwargs))

Expand Down Expand Up @@ -1953,9 +1940,7 @@ def interp_order(length):
"""


MEDIAN = Aggregator(
"median", ma.median, lazy_func=_build_dask_mdtol_function(_lazy_median)
)
MEDIAN = Aggregator("median", ma.median)
"""
An :class:`~iris.analysis.Aggregator` instance that calculates
the median over a :class:`~iris.cube.Cube`, as computed by
Expand All @@ -1968,7 +1953,8 @@ def interp_order(length):
result = cube.collapsed('longitude', iris.analysis.MEDIAN)
This aggregator handles masked data and lazy data.
This aggregator handles masked data, but NOT lazy data. For lazy aggregation,
please try :obj:`~.PERCENTILE`.
"""

Expand Down
90 changes: 0 additions & 90 deletions lib/iris/tests/unit/analysis/test_MEDIAN.py

This file was deleted.

0 comments on commit 6b14a74

Please sign in to comment.