Skip to content

Commit

Permalink
Fix np.Inf for numpy 2 (#347)
Browse files Browse the repository at this point in the history
This patch replaces instances of np.Inf with np.inf, which is needed for
numpy 2 compatibility.
  • Loading branch information
boomanaiden154 authored Jul 25, 2024
1 parent 5eaad6c commit 9b648b4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions compiler_opt/es/blackbox_optimizers.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ def __init__(self, function_object: QuadraticModel,
self.params = {}
self.x = np.copy(x_init)
self.k = 0 # iteration counter
self.x_diff_norm = np.Inf # L2 norm of x^+ - x
self.x_diff_norm = np.inf # L2 norm of x^+ - x

def run_step(self) -> None:
"""Take a single step of projected gradient descent.
Expand All @@ -698,7 +698,7 @@ def run_step(self) -> None:
# SciPy enforces after v. 1.12 that this parameter is in (0,1). 0.9 is
# default.
# https://github.com/scipy/scipy/blob/87c46641a8b3b5b47b81de44c07b840468f7ebe7/scipy/optimize/_linesearch.py#L29
c2 = self.params.get('c2', -np.Inf if _IS_SCIPI_PRE_12 else 0.9)
c2 = self.params.get('c2', -np.inf if _IS_SCIPI_PRE_12 else 0.9)
# since we have negative curvature, ignore Wolfe condition
search_direction = -grad(self.x)
ls_result = sp_opt.line_search(
Expand Down

0 comments on commit 9b648b4

Please sign in to comment.