MCPcopy Index your code
hub / github.com/pydata/xarray / inject_reduce_methods

Function inject_reduce_methods

xarray/computation/ops.py:244–268  ·  view source on GitHub ↗
(cls)

Source from the content-addressed store, hash-verified

242
243
244def inject_reduce_methods(cls):
245 methods = (
246 [
247 (name, getattr(duck_array_ops, f"array_{name}"), False)
248 for name in REDUCE_METHODS
249 ]
250 + [(name, getattr(duck_array_ops, name), True) for name in NAN_REDUCE_METHODS]
251 + [("count", duck_array_ops.count, False)]
252 )
253 for name, f, include_skipna in methods:
254 numeric_only = getattr(f, "numeric_only", False)
255 available_min_count = getattr(f, "available_min_count", False)
256 skip_na_docs = _SKIPNA_DOCSTRING if include_skipna else ""
257 min_count_docs = _MINCOUNT_DOCSTRING if available_min_count else ""
258
259 func = cls._reduce_method(f, include_skipna, numeric_only)
260 func.__name__ = name
261 func.__doc__ = _REDUCE_DOCSTRING_TEMPLATE.format(
262 name=name,
263 cls=cls.__name__,
264 extra_args=cls._reduce_extra_args_docstring.format(name=name),
265 skip_na_docs=skip_na_docs,
266 min_count_docs=min_count_docs,
267 )
268 setattr(cls, name, func)
269
270
271def op_str(name):

Callers 1

__init_subclass__Method · 0.85

Calls 2

_reduce_methodMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…