On 10/16/2016 05:52 AM, Hanno Klemm wrote:
>
>
>> On 16 Oct 2016, at 03:21, Allan Haldane <allanhald...@gmail.com> wrote:
>>
>>> On 10/14/2016 07:49 PM, Juan Nunez-Iglesias wrote:
>>> +1 for propagate_mask. That is the only proposal that immediately makes
>>> sense to me. "contagious" may be cute but I think approximately 0% of
>>> users would guess its purpose on first use.
>>>
>>> Can you elaborate on what happens with the masks exactly? I didn't quite
>>> get why propagate_mask=False was unintuitive. My expectation is that any
>>> mask present in the input will not be set in the output, but the mask
>>> will be "respected" by the function.
>>
>> Here's an illustration of how the PR currently works with convolve, using
>> the name "propagate_mask":
>>
>> >>> m = np.ma.masked
>> >>> a = np.ma.array([1,1,1,m,1,1,1,m,m,m,1,1,1])
>> >>> b = np.ma.array([1,1,1])
>> >>>
>> >>> print np.ma.convolve(a, b, propagate_mask=True)
>> [1 2 3 -- -- -- 3 -- -- -- -- -- 3 2 1]
>> >>> print np.ma.convolve(a, b, propagate_mask=False)
>> [1 2 3 2 2 2 3 2 1 -- 1 2 3 2 1]
>>
>> Allan
>>
>
> Given this behaviour, I'm actually more concerned about the logic ma.convolve
> uses in the propagate_mask=False case. It appears that the masked values are
> essentially replaced by zero. Is my interpretation correct and if so does
> this make sense?
>

## Advertising

I think that's right.
Its usefulness wasn't obvious to me either, but googling shows that
in matlab people like the file "nanconv.m" which works this way, using
nans similarly to how the mask is used here.
Just as convolution functions often add zero-padding around an image,
here the mask behavior would allow you to have different borders, eg
[m,m,m,1,1,1,1,m,m,m,m]
using my notation from before.
Octave's "nanconv" does this too.
I still agree that in most cases people should be handling the missing
values more carefully (manually) if they are doing convolutions, but
this default behaviour maybe seems reasonable to me.
Allan
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
https://mail.scipy.org/mailman/listinfo/numpy-discussion