[Numpy-discussion] index partition
ndarray at mac.com
Sat Apr 12 17:20:59 EDT 2014
On Sat, Apr 12, 2014 at 5:03 PM, Sebastian Berg
<sebastian at sipsolutions.net>wrote:
> > As a simple example, suppose for array `a` I want
> > np.flatnonzero(a>0) and np.flatnonzero(a<=0).
> > Can I get them both in one go?
> Might be missing something, but I don't think there is a way to do it in
> one go. The result is irregularly structured and there are few functions
> like nonzero which give something like that.
The "set routines"  are in this category and may help you deal with
partitions, but I would recommend using boolean arrays instead. If you
commonly deal with both a subset and a complement, set representation does
not give you a memory advantage over a boolean mask.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion