MCPcopy
hub / github.com/dask/dask / push

Function push

dask/array/overlap.py:895–928  ·  view source on GitHub ↗

Dask-version of bottleneck.push .. note:: Requires bottleneck to be installed.

(array, n, axis)

Source from the content-addressed store, hash-verified

893
894
895def push(array, n, axis):
896 """
897 Dask-version of bottleneck.push
898
899 .. note::
900
901 Requires bottleneck to be installed.
902 """
903 import_optional_dependency("bottleneck", min_version="1.3.7")
904
905 if n is not None and 0 < n < array.shape[axis] - 1:
906 arr = broadcast_to(
907 arange(
908 array.shape[axis], chunks=array.chunks[axis], dtype=array.dtype
909 ).reshape(
910 tuple(size if i == axis else 1 for i, size in enumerate(array.shape))
911 ),
912 array.shape,
913 array.chunks,
914 )
915 valid_arange = where(notnull(array), arr, np.nan)
916 valid_limits = (arr - push(valid_arange, None, axis)) <= n
917 # omit the forward fill that violate the limit
918 return where(valid_limits, push(array, None, axis), np.nan)
919
920 # The method parameter makes that the tests for python 3.7 fails.
921 return cumreduction(
922 func=_push,
923 binop=_fill_with_last_one,
924 ident=np.nan,
925 x=array,
926 axis=axis,
927 dtype=array.dtype,
928 )
929
930
931def _fill_with_last_one(a, b):

Callers 1

test_pushFunction · 0.90

Calls 7

broadcast_toFunction · 0.90
arangeFunction · 0.90
whereFunction · 0.90
notnullFunction · 0.90
cumreductionFunction · 0.90
reshapeMethod · 0.80

Tested by 1

test_pushFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…