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

Function _gradient_kernel

dask/array/routines.py:640–657  ·  view source on GitHub ↗

x: nd-array array of one block coord: 1d-array or scalar coordinate along which the gradient is computed. axis: int axis along which the gradient is computed array_locs: actual location along axis. None if coordinate is scalar grad_kwargs:

(x, block_id, coord, axis, array_locs, grad_kwargs)

Source from the content-addressed store, hash-verified

638
639
640def _gradient_kernel(x, block_id, coord, axis, array_locs, grad_kwargs):
641 """
642 x: nd-array
643 array of one block
644 coord: 1d-array or scalar
645 coordinate along which the gradient is computed.
646 axis: int
647 axis along which the gradient is computed
648 array_locs:
649 actual location along axis. None if coordinate is scalar
650 grad_kwargs:
651 keyword to be passed to np.gradient
652 """
653 block_loc = block_id[axis]
654 if array_locs is not None:
655 coord = coord[array_locs[0][block_loc] : array_locs[1][block_loc]]
656 grad = np.gradient(x, coord, axis=axis, **grad_kwargs)
657 return grad
658
659
660@derived_from(np)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected