My apologies, never write code directly in an email...
s/b:
mask = np.array([1, 0, 1], dtype=bool)

What do you mean by indicator?

On Thu, Oct 11, 2018 at 1:31 PM Andras Deak <deak.and...@gmail.com> wrote:

> On Thu, Oct 11, 2018 at 6:54 PM Matthew Harrigan
> <harrigan.matt...@gmail.com> wrote:
> >
> > Hello,
> >
> > I am documenting some code, translating the core of the algorithm to
> LaTeX.  The style I have currently is very similar to the einsum syntax
> (which is awesome btw).  Here is an example of some of the basic operations
> in NumPy.  One part I do not know how to capture well is boolean indexing,
> ie:
> >
> > mask = np.array([1, 0, 1])
> > x = np.array([1, 2, 3])
> > y = x[mask]
>
> That is fancy indexing with an index array rather than boolean
> indexing. That's why the result is [2, 1, 2] rather than [1, 3].
> In case this is really what you need, it's the case of your indices
> originating from another sequence: `y_i = x_{m_i}` where `m_i` is your
> indexing sequence.
> For proper boolean indexing you lose the one-to-one correspondence
> between input and output (due to the size almost always changing), so
> you might not be able to formalize it this nicely with an index
> appearing in both sides. But something with an indicator might work...
>
> AndrĂ¡s
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@python.org
> https://mail.python.org/mailman/listinfo/numpy-discussion
>
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@python.org
https://mail.python.org/mailman/listinfo/numpy-discussion

Reply via email to