MCPcopy Create free account
hub / github.com/dask/dask / moment_chunk

Function moment_chunk

dask/array/reductions.py:424–451  ·  view source on GitHub ↗
(
    A,
    order=2,
    sum=chunk.sum,
    numel=numel,
    dtype="f8",
    computing_meta=False,
    implicit_complex_dtype=False,
    **kwargs,
)

Source from the content-addressed store, hash-verified

422
423
424def moment_chunk(
425 A,
426 order=2,
427 sum=chunk.sum,
428 numel=numel,
429 dtype="f8",
430 computing_meta=False,
431 implicit_complex_dtype=False,
432 **kwargs,
433):
434 if computing_meta:
435 return A
436 n = numel(A, **kwargs)
437
438 n = n.astype(np.int64)
439 if implicit_complex_dtype:
440 total = sum(A, **kwargs)
441 else:
442 total = sum(A, dtype=dtype, **kwargs)
443
444 with np.errstate(divide="ignore", invalid="ignore"):
445 u = total / n
446 d = A - u
447 if np.issubdtype(A.dtype, np.complexfloating):
448 d = np.abs(d)
449 xs = [sum(d**i, dtype=dtype, **kwargs) for i in range(2, order + 1)]
450 M = np.stack(xs, axis=-1)
451 return {"total": total, "n": n, "M": M}
452
453
454def _moment_helper(Ms, ns, inner_term, order, sum, axis, kwargs):

Callers 2

reduction_chunkMethod · 0.90
reduction_chunkMethod · 0.90

Calls 4

numelFunction · 0.85
sumFunction · 0.70
astypeMethod · 0.45
absMethod · 0.45

Tested by

no test coverage detected