Skip to content

Commit

Permalink
Silence NumPy warnings about numerical operations with zero.
Browse files Browse the repository at this point in the history
  • Loading branch information
LTLA committed Dec 20, 2024
1 parent a9f50fe commit c36c443
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/delayedarray/UnaryIsometricOpSimple.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import Callable, Literal, Tuple, Sequence
import numpy
from numpy import dtype, zeros
import warnings

from .DelayedOp import DelayedOp
from .SparseNdarray import SparseNdarray
Expand Down Expand Up @@ -68,7 +69,9 @@ def __init__(self, seed, operation: OP):
String specifying the unary operation.
"""
f = _choose_operator(operation)
dummy = f(zeros(1, dtype=seed.dtype))
with warnings.catch_warnings(): # silence warnings from divide by zero.
warnings.simplefilter("ignore")
dummy = f(zeros(1, dtype=seed.dtype))

self._seed = seed
self._op = operation
Expand Down

0 comments on commit c36c443

Please sign in to comment.