Skip to content

Commit c36c443

Browse files
committed
Silence NumPy warnings about numerical operations with zero.
1 parent a9f50fe commit c36c443

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/delayedarray/UnaryIsometricOpSimple.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from typing import Callable, Literal, Tuple, Sequence
22
import numpy
33
from numpy import dtype, zeros
4+
import warnings
45

56
from .DelayedOp import DelayedOp
67
from .SparseNdarray import SparseNdarray
@@ -68,7 +69,9 @@ def __init__(self, seed, operation: OP):
6869
String specifying the unary operation.
6970
"""
7071
f = _choose_operator(operation)
71-
dummy = f(zeros(1, dtype=seed.dtype))
72+
with warnings.catch_warnings(): # silence warnings from divide by zero.
73+
warnings.simplefilter("ignore")
74+
dummy = f(zeros(1, dtype=seed.dtype))
7275

7376
self._seed = seed
7477
self._op = operation

0 commit comments

Comments
 (0)