<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 23, 2015 at 2:59 PM, Daniel da Silva <span dir="ltr"><<a href="mailto:var.mail.daniel@gmail.com" target="_blank">var.mail.daniel@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hope this isn't too off-topic: but it would be very nice if np.histogram and np.histogram2d supported masked arrays. Is this out of scope for outside the <a href="http://numpy.ma" target="_blank">numpy.ma</a> package?<br></div></blockquote><div><br></div><div>Right now it looks like there's no histogram function at all for masked arrays - would be good to improve that situation.<br><br></div><div>If it's as easy as adding to np.histogram something like:<br><br></div><div>    if isinstance(a, np.ma.MaskedArray):<br></div><div>        a = a.data[~a.mask]<br><br></div><div>then it makes sense to add that I think. <br><br></div><div>Ralf<br><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 16, 2015 at 2:35 PM, Robert McGibbon <span dir="ltr"><<a href="mailto:rmcgibbo@gmail.com" target="_blank">rmcgibbo@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">Hi,</p>
<p dir="ltr">It sounds like putting together a PR makes sense then. I'll try hacking on this a bit.</p><span><font color="#888888">
<p dir="ltr">-Robert</p>
</font></span><div class="gmail_quote"><div><div>On Mar 16, 2015 11:20 AM, "Jaime Fernández del Río" <<a href="mailto:jaime.frio@gmail.com" target="_blank">jaime.frio@gmail.com</a>> wrote:<br type="attribution"></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Mar 16, 2015 at 9:28 AM, Jerome Kieffer <span dir="ltr"><<a href="mailto:Jerome.Kieffer@esrf.fr" target="_blank">Jerome.Kieffer@esrf.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Mon, 16 Mar 2015 06:56:58 -0700<br>
<span>Jaime Fernández del Río <<a href="mailto:jaime.frio@gmail.com" target="_blank">jaime.frio@gmail.com</a>> wrote:<br>
<br>
</span><span>> Dispatching to a different method seems like a no brainer indeed. The<br>
> question is whether we really need to do this in C.<br>
<br>
</span>I need to do both unweighted & weighted histograms and we got a factor 5 using (simple) cython:<br>
it is in the proceedings of Euroscipy, last year.<br>
<a href="http://arxiv.org/pdf/1412.6367.pdf" target="_blank">http://arxiv.org/pdf/1412.6367.pdf</a></blockquote><div><br></div><div>If I read your paper and code properly, you got 5x faster, mostly because you combined the weighted and unweighted histograms into a single search of the array, and because you used an algorithm that can only be applied to equal- sized bins, similarly to the 10x speed-up Robert was reporting.</div><div><br></div><div>I think that having a special path for equal sized bins is a great idea: let's do it, PRs are always welcome!</div><div>Similarly, getting the counts together with the weights seems like a very good idea.</div><div><br></div><div>I also think that writing it in Python is going to take us 80% of the way there: most of the improvements both of you have reported are not likely to be coming from the language chosen, but from the algorithm used. And if C proves to be sufficiently faster to warrant using it, it should be confined to the number crunching: I don;t think there is any point in rewriting argument parsing in C.</div><div><br></div><div>Also, keep in mind `np.histogram` can now handle arrays of just about **any** dtype. Handling that complexity in C is not a ride in the park. Other functions like `np.bincount` and `np.digitize` cheat by only handling `double` typed arrays, a luxury that histogram probably can't afford at this point in time.</div><div><br></div><div>Jaime</div><div><br></div></div>-- <br><div>(\__/)<br>( O.o)<br>( > <) Este es Conejo. Copia a Conejo en tu firma y ayúdale en sus planes de dominación mundial.</div>
</div></div>
<br></div></div><span>_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org" target="_blank">NumPy-Discussion@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
<br></span></blockquote></div>
<br>_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org" target="_blank">NumPy-Discussion@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
<br></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
<br></blockquote></div><br></div></div>