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

Function push

dask/array/overlap.py:896–929  ·  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

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