Skip to content

Commit d392abf

Browse files
fix: Use np.inf to avoid AttributeError
* Avoids: AttributeError: `np.infty` was removed in the NumPy 2.0 release. Use `np.inf` instead. AttributeError: `np.Inf` was removed in the NumPy 2.0 release. Use `np.inf` instead.
1 parent e6ff6f9 commit d392abf

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

ot/da.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ class label
497497

498498
if (ys is not None) and (yt is not None):
499499

500-
if self.limit_max != np.infty:
500+
if self.limit_max != np.inf:
501501
self.limit_max = self.limit_max * nx.max(self.cost_)
502502

503503
# missing_labels is a (ns, nt) matrix of {0, 1} such that
@@ -519,7 +519,7 @@ class label
519519
cost_correction = label_match * missing_labels * self.limit_max
520520
# this operation is necessary because 0 * Inf = NAN
521521
# thus is irrelevant when limit_max is finite
522-
cost_correction = nx.nan_to_num(cost_correction, -np.infty)
522+
cost_correction = nx.nan_to_num(cost_correction, -np.inf)
523523
self.cost_ = nx.maximum(self.cost_, cost_correction)
524524

525525
# distribution estimation
@@ -1067,7 +1067,7 @@ class SinkhornTransport(BaseTransport):
10671067
method from :ref:`[66]
10681068
<references-sinkhorntransport>` and :ref:`[19]
10691069
<references-sinkhorntransport>`.
1070-
limit_max: float, optional (default=np.infty)
1070+
limit_max: float, optional (default=np.inf)
10711071
Controls the semi supervised mode. Transport between labeled source
10721072
and target samples of different classes will exhibit an cost defined
10731073
by this variable
@@ -1109,7 +1109,7 @@ def __init__(self, reg_e=1., method="sinkhorn_log", max_iter=1000,
11091109
tol=10e-9, verbose=False, log=False,
11101110
metric="sqeuclidean", norm=None,
11111111
distribution_estimation=distribution_estimation_uniform,
1112-
out_of_sample_map='continuous', limit_max=np.infty):
1112+
out_of_sample_map='continuous', limit_max=np.inf):
11131113

11141114
if out_of_sample_map not in ['ferradans', 'continuous']:
11151115
raise ValueError('Unknown out_of_sample_map method')
@@ -1417,7 +1417,7 @@ class SinkhornLpl1Transport(BaseTransport):
14171417
The kind of out of sample mapping to apply to transport samples
14181418
from a domain into another one. Currently the only possible option is
14191419
"ferradans" which uses the method proposed in :ref:`[6] <references-sinkhornlpl1transport>`.
1420-
limit_max: float, optional (default=np.infty)
1420+
limit_max: float, optional (default=np.inf)
14211421
Controls the semi supervised mode. Transport between labeled source
14221422
and target samples of different classes will exhibit a cost defined by
14231423
limit_max.
@@ -1450,7 +1450,7 @@ def __init__(self, reg_e=1., reg_cl=0.1,
14501450
tol=10e-9, verbose=False,
14511451
metric="sqeuclidean", norm=None,
14521452
distribution_estimation=distribution_estimation_uniform,
1453-
out_of_sample_map='ferradans', limit_max=np.infty):
1453+
out_of_sample_map='ferradans', limit_max=np.inf):
14541454
self.reg_e = reg_e
14551455
self.reg_cl = reg_cl
14561456
self.max_iter = max_iter

ot/regpath.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ def semi_relaxed_path(a: np.array, b: np.array, C: np.array, reg=1e-4,
762762
active_index.append(i * m + j)
763763
gamma_list = []
764764
t_list = []
765-
current_gamma = np.Inf
765+
current_gamma = np.inf
766766
augmented_H0 = construct_augmented_H(active_index, m, Hc, HrHr)
767767
add_col = np.array([])
768768
id_pop = -1

0 commit comments

Comments
 (0)