MCPcopy
hub / github.com/dask/dask / expand_pad_value

Function expand_pad_value

dask/array/creation.py:936–970  ·  view source on GitHub ↗
(array, pad_value)

Source from the content-addressed store, hash-verified

934
935
936def expand_pad_value(array, pad_value):
937 if isinstance(pad_value, Number) or getattr(pad_value, "ndim", None) == 0:
938 pad_value = array.ndim * ((pad_value, pad_value),)
939 elif (
940 isinstance(pad_value, Sequence)
941 and all(isinstance(pw, Number) for pw in pad_value)
942 and len(pad_value) == 1
943 ):
944 pad_value = array.ndim * ((pad_value[0], pad_value[0]),)
945 elif (
946 isinstance(pad_value, Sequence)
947 and len(pad_value) == 2
948 and all(isinstance(pw, Number) for pw in pad_value)
949 ):
950 pad_value = array.ndim * (tuple(pad_value),)
951 elif (
952 isinstance(pad_value, Sequence)
953 and len(pad_value) == array.ndim
954 and all(isinstance(pw, Sequence) for pw in pad_value)
955 and all((len(pw) == 2) for pw in pad_value)
956 and all(all(isinstance(w, Number) for w in pw) for pw in pad_value)
957 ):
958 pad_value = tuple(tuple(pw) for pw in pad_value)
959 elif (
960 isinstance(pad_value, Sequence)
961 and len(pad_value) == 1
962 and isinstance(pad_value[0], Sequence)
963 and len(pad_value[0]) == 2
964 and all(isinstance(pw, Number) for pw in pad_value[0])
965 ):
966 pad_value = array.ndim * (tuple(pad_value[0]),)
967 else:
968 raise TypeError("`pad_value` must be composed of integral typed values.")
969
970 return pad_value
971
972
973def get_pad_shapes_chunks(array, pad_width, axes, mode):

Callers 3

pad_edgeFunction · 0.85
pad_statsFunction · 0.85
padFunction · 0.85

Calls 1

allFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…