<p dir="auto"><em>Original ticket <a href="http://projects.scipy.org/scipy/ticket/1474" rel="nofollow">http://projects.scipy.org/scipy/ticket/1474</a> on 2011-07-08 by trac user jmerkin, assigned to trac user peridot.</em></p>
<p dir="auto">I have been using masked arrays a lot in some of my analyses, but from what I have seen spatial.distance does not currently use the masks (converted to normal arrays). I have copied and modified a number of distance functions as well as spatial.distance.pdist to consider the masks when evaluating. I can contribute the code if it would be useful.</p>
<p dir="auto">At the moment <code class="notranslate">pdist</code> returns a distance matrix with a <code class="notranslate">nan</code>-entry whenever a vector with any <code class="notranslate">nan</code>-element is part of the respective pair. This is consistent with, for example, the R <code class="notranslate">dist</code> function, as well as MATLAB, I believe.</p>
<p dir="auto">In my case, and I should think a few others' as well, there are very few <code class="notranslate">nan</code>s in a high-dimensional space. I would thus only ignore the corresponding pairs of elements of the vectors. I have solutions for this problem both in Cython and directly in C, which mirrors the current scipy code. Is there a general interest in having this in scipy?</p>
<p dir="auto">If the answer is yes, I will submit a pull request and then we just have to discuss the use of Cython or C or a mix of both.</p>