count_nonzero#
- class brainunit.math.count_nonzero(a, axis=None, keepdims=None, **kwargs)#
Count the number of non-zero values in the input.
Units are stripped before counting.
- Parameters:
- Returns:
count – Number of non-zero values along the given axis.
- Return type:
Array
Examples
>>> import saiunit as u >>> import jax.numpy as jnp >>> u.math.count_nonzero(jnp.array([0, 1, 0, 2, 3])) Array(3, dtype=int32)