File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change 13
13
# License: MIT License
14
14
15
15
import numpy as np
16
+ import warnings
16
17
17
18
from .backend import get_backend
18
19
from .bregman import sinkhorn , jcpot_barycenter
@@ -511,7 +512,11 @@ class label
511
512
# that he cells (i, j) has -Inf where there's no correction necessary
512
513
# by 'correction' we mean setting cost to a large value when
513
514
# labels do not match
514
- cost_correction = label_match * missing_labels * self .limit_max
515
+ # we suppress potential RuntimeWarning caused by Inf multiplication
516
+ # (as we explicitly cover potential NANs later)
517
+ with warnings .catch_warnings ():
518
+ warnings .simplefilter ('ignore' , category = RuntimeWarning )
519
+ cost_correction = label_match * missing_labels * self .limit_max
515
520
# this operation is necessary because 0 * Inf = NAN
516
521
# thus is irrelevant when limit_max is finite
517
522
cost_correction = nx .nan_to_num (cost_correction , - np .infty )
You can’t perform that action at this time.
0 commit comments