MCPcopy
hub / github.com/dask/dask / moment_combine

Function moment_combine

dask/array/reductions.py:467–508  ·  view source on GitHub ↗
(
    pairs,
    order=2,
    ddof=0,
    dtype="f8",
    sum=np.sum,
    axis=None,
    computing_meta=False,
    **kwargs,
)

Source from the content-addressed store, hash-verified

465
466
467def moment_combine(
468 pairs,
469 order=2,
470 ddof=0,
471 dtype="f8",
472 sum=np.sum,
473 axis=None,
474 computing_meta=False,
475 **kwargs,
476):
477 if not isinstance(pairs, list):
478 pairs = [pairs]
479
480 kwargs["dtype"] = None
481 kwargs["keepdims"] = True
482
483 ns = deepmap(lambda pair: pair["n"], pairs) if not computing_meta else pairs
484 ns = _concatenate2(ns, axes=axis)
485 n = ns.sum(axis=axis, **kwargs)
486
487 if computing_meta:
488 return n
489
490 totals = _concatenate2(deepmap(lambda pair: pair["total"], pairs), axes=axis)
491 Ms = _concatenate2(deepmap(lambda pair: pair["M"], pairs), axes=axis)
492
493 total = totals.sum(axis=axis, **kwargs)
494
495 with np.errstate(divide="ignore", invalid="ignore"):
496 if np.issubdtype(total.dtype, np.complexfloating):
497 mu = divide(total, n)
498 inner_term = np.abs(divide(totals, ns) - mu)
499 else:
500 mu = divide(total, n, dtype=dtype)
501 inner_term = divide(totals, ns, dtype=dtype) - mu
502
503 xs = [
504 _moment_helper(Ms, ns, inner_term, o, sum, axis, kwargs)
505 for o in range(2, order + 1)
506 ]
507 M = np.stack(xs, axis=-1)
508 return {"total": total, "n": n, "M": M}
509
510
511def moment_agg(

Callers 2

reduction_combineMethod · 0.90
reduction_combineMethod · 0.90

Calls 6

deepmapFunction · 0.90
_concatenate2Function · 0.90
_moment_helperFunction · 0.85
divideFunction · 0.70
sumMethod · 0.45
absMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…