[Numpy-discussion] count_nonzero axis argument?

Sebastian Berg sebastian at sipsolutions.net
Mon Sep 17 07:46:29 EDT 2018


On Mon, 2018-09-17 at 12:37 +0100, Matthew Brett wrote:
> Hi,
> 
> Is there any reason that np.count_nonzero should not take an axis
> argument?  As in:
> 

No, sounds like an obvious improvement, but as also with those, someone
has to volunteer to do it...
Coding it will probably mean adding the NpyIter and possibly fast paths
(not sure about the state of count nonzero), but should not be very
difficult.

- Sebastian



> > > > np.better_count_nonzero([[10, 11], [0, 3]], axis=1)
> 
> array([2, 1])
> 
> It would be much more useful if it did...
> 
> Cheers,
> 
> Matthew
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at python.org
> https://mail.python.org/mailman/listinfo/numpy-discussion
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20180917/dd8fc5d3/attachment-0001.sig>


More information about the NumPy-Discussion mailing list