mention np.errstate
context manager in exercise 31.
This commit is contained in:
parent
e8ad2e1123
commit
4cb1d8cd76
@ -282,12 +282,19 @@ print(np.intersect1d(Z1,Z2))
|
|||||||
```python
|
```python
|
||||||
# Suicide mode on
|
# Suicide mode on
|
||||||
defaults = np.seterr(all="ignore")
|
defaults = np.seterr(all="ignore")
|
||||||
Z = np.ones(1)/0
|
Z = np.ones(1) / 0
|
||||||
|
|
||||||
# Back to sanity
|
# Back to sanity
|
||||||
_ = np.seterr(**defaults)
|
_ = np.seterr(**defaults)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
An equivalent way, with a context manager:
|
||||||
|
|
||||||
|
```python
|
||||||
|
with np.errstate(divide='ignore'):
|
||||||
|
Z = np.ones(1) / 0
|
||||||
|
```
|
||||||
|
|
||||||
#### 32. Is the following expressions true? (★☆☆)
|
#### 32. Is the following expressions true? (★☆☆)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user