Skip to content

Commit

Permalink
Merge pull request #458 from missing-user/numpy2-NINF-deprecation
Browse files Browse the repository at this point in the history
np.NINF to -np.inf for np2.0 compatibility
  • Loading branch information
landreman authored Nov 18, 2024
2 parents f29bc28 + 0b00a2c commit 9fc2c36
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/simsopt/_core/optimizable.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def __init__(self,
free: Array of boolean values denoting if the DOFs is are free.
False values implies the corresponding DOFs are fixed
lower_bounds: Lower bounds for the DOFs. Meaningful only if
DOF is not fixed. Default is np.NINF
DOF is not fixed. Default is -np.inf
upper_bounds: Upper bounds for the DOFs. Meaningful only if
DOF is not fixed. Default is np.inf
"""
Expand All @@ -106,7 +106,7 @@ def __init__(self,
free = np.asarray(free, dtype=np.bool_)

if lower_bounds is None:
lower_bounds = np.full(len(x), np.NINF)
lower_bounds = np.full(len(x), -np.inf)
else:
lower_bounds = np.asarray(lower_bounds, np.double)

Expand Down
4 changes: 2 additions & 2 deletions tests/core/test_dofs.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def test_lower_bounds(self):
names=np.array(['x', 'y', 'z']),
free=np.array([True, True, False]))
self.assertTrue(np.allclose(dofs.free_lower_bounds,
np.array([np.NINF, np.NINF])))
np.array([-np.inf, -np.inf])))

with self.assertRaises(DofLengthMismatchError):
dofs.free_lower_bounds = np.array([-1000.0, -1001.0, -1002.0])
Expand All @@ -180,7 +180,7 @@ def test_lower_bounds(self):

dofs.unfix_all()
self.assertTrue(np.allclose(dofs.free_lower_bounds,
np.array([-1000.0, -1001.0, np.NINF])))
np.array([-1000.0, -1001.0, -np.inf])))

dofs.free_lower_bounds = np.array([-1000.0, -1001.0, -1002.])
self.assertTrue(np.allclose(dofs.free_lower_bounds,
Expand Down

0 comments on commit 9fc2c36

Please sign in to comment.