MCPcopy Create free account
hub / github.com/numpy/numpy / _convolve_or_correlate

Function _convolve_or_correlate

numpy/ma/core.py:7963–7979  ·  view source on GitHub ↗

Helper function for ma.correlate and ma.convolve

(f, a, v, mode, propagate_mask)

Source from the content-addressed store, hash-verified

7961
7962
7963def _convolve_or_correlate(f, a, v, mode, propagate_mask):
7964 """
7965 Helper function for ma.correlate and ma.convolve
7966 """
7967 if propagate_mask:
7968 # results which are contributed to by either item in any pair being invalid
7969 mask = (
7970 f(getmaskarray(a), np.ones(np.shape(v), dtype=bool), mode=mode)
7971 | f(np.ones(np.shape(a), dtype=bool), getmaskarray(v), mode=mode)
7972 )
7973 data = f(getdata(a), getdata(v), mode=mode)
7974 else:
7975 # results which are not contributed to by any pair of valid elements
7976 mask = ~f(~getmaskarray(a), ~getmaskarray(v))
7977 data = f(filled(a, 0), filled(v, 0), mode=mode)
7978
7979 return masked_array(data, mask=mask)
7980
7981
7982def correlate(a, v, mode='valid', propagate_mask=True):

Callers 2

correlateFunction · 0.85
convolveFunction · 0.85

Calls 5

fFunction · 0.85
getmaskarrayFunction · 0.85
getdataFunction · 0.85
filledFunction · 0.85
shapeMethod · 0.45

Tested by

no test coverage detected