On Mon, 2017-12-18 at 12:02 +0100, hanno_li...@gmx.net wrote:
> Hi,
>  
> is it possible, to apply a logical operation, such as AND or OR along
> a particular axis of a numpy array?
> 

As mentioned, `np.any` and `np.all` work. However, what is more/also
interesting to you is maybe that:

`np.logical_or.reduce`

works. All binary ufuncs (most elementwise functions such as addition,
subtraction, multiplication, etc. support this `reduce` (and some
other, please find out yourself ;)) methods.
So that thing like `any`, `sum`, or `cumsum` are actually just thin
wrappers around those.

- Sebastian


>  
> Let's say I have an (n,m) array and I want to AND along the first
> axis, such that I get a (1,m) (or just (m,) dimensional array back. I
> looked at the documentation for np.logical_and and friends but
> couldn't find an axis keyword on the logical_xyz operations and
> nothing else seemed to fit.
>  
> Thanks, and best regards,
> Hanno
>  
>  
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@python.org
> https://mail.python.org/mailman/listinfo/numpy-discussion

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@python.org
https://mail.python.org/mailman/listinfo/numpy-discussion

Reply via email to