Skip to content

Commit 589cfec

Browse files
committed
catch warnings divide by 0
1 parent 617ba67 commit 589cfec

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

ot/lp/solver_1d.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -791,10 +791,12 @@ def binary_search_circle(
791791
-1, 1
792792
)
793793

794-
mask_end = mask * (nx.abs(dCptm - dCmtp) > 0.001)
795-
tc[mask_end > 0] = (
796-
(Ctp - Ctm + tm * dCptm - tp * dCmtp) / (dCptm - dCmtp)
797-
)[mask_end > 0]
794+
with warnings.catch_warnings():
795+
warnings.simplefilter("ignore", category=RuntimeWarning)
796+
mask_end = mask * (nx.abs(dCptm - dCmtp) > 0.001)
797+
tc[mask_end > 0] = (
798+
(Ctp - Ctm + tm * dCptm - tp * dCmtp) / (dCptm - dCmtp)
799+
)[mask_end > 0]
798800
done[nx.prod(mask, axis=-1) > 0] = 1
799801
elif nx.any(1 - done):
800802
tm[((1 - mask) * (dCp < 0)) > 0] = tc[((1 - mask) * (dCp < 0)) > 0]

0 commit comments

Comments
 (0)