Update README.md

Signed-off-by: David Rotermund <54365609+davrot@users.noreply.github.com>
This commit is contained in:
David Rotermund 2023-12-14 16:21:04 +01:00 committed by GitHub
parent 37ac4b0c05
commit 835a42b07b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -128,6 +128,32 @@ Output:
(array([0, 1, 1, 1]), array([2, 0, 1, 2])) (array([0, 1, 1, 1]), array([2, 0, 1, 2]))
``` ```
For reversing it, you can use this:
```python
import numpy as np
a = np.arange(0, 6).reshape((2, 3))
a = (a > 1)
print(a)
idx = np.nonzero(a)
print()
b = np.zeros((2, 3), dtype=bool)
b[idx] = True
print(b)
```
Output:
```python
[[False False True]
[ True True True]]
[[False False True]
[ True True True]]
```
## [Logic functions](https://numpy.org/doc/stable/reference/routines.logic.html) ## [Logic functions](https://numpy.org/doc/stable/reference/routines.logic.html)
### [Truth value testing](https://numpy.org/doc/stable/reference/routines.logic.html#truth-value-testing) ### [Truth value testing](https://numpy.org/doc/stable/reference/routines.logic.html#truth-value-testing)