Skip to content

Commit

Permalink
Upgrade to numpy>=2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
moeyensj committed Sep 17, 2024
1 parent 941e3fb commit d992f84
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ dependencies = [
"healpy",
"jax",
"jaxlib",
"numpy>=1.20,<1.25",
"numpy<2.0.0",
"pyarrow>=13.0.0",
"pandas",
"ray",
Expand Down
6 changes: 3 additions & 3 deletions src/adam_core/coordinates/cartesian.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def rotate(
Rotated Cartesian coordinates and their covariances.
"""
# Extract coordinate values into a masked array and mask NaNss
masked_coords = np.ma.masked_array(self.values, fill_value=np.NaN)
masked_coords = np.ma.masked_array(self.values, fill_value=np.nan)
masked_coords.mask = np.isnan(masked_coords.data)

# Rotate coordinates
Expand All @@ -223,7 +223,7 @@ def rotate(
rotation_matrix @ masked_covariances.filled() @ rotation_matrix.T
)
# Reset the mask to the original mask
covariances_rotated[masked_covariances.mask] = np.NaN
covariances_rotated[masked_covariances.mask] = np.nan

# Check if any covariance elements are near zero, if so set them to zero
near_zero = len(
Expand Down Expand Up @@ -284,7 +284,7 @@ def translate(
raise ValueError(f"Expected vector to have shape (6,) or ({N}, 6).")

# Extract coordinate values into a masked array and mask NaNss
masked_coords = np.ma.masked_array(self.values, fill_value=np.NaN)
masked_coords = np.ma.masked_array(self.values, fill_value=np.nan)
masked_coords.mask = np.isnan(masked_coords.data)

# Translate coordinates
Expand Down
2 changes: 1 addition & 1 deletion src/adam_core/coordinates/covariances.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

logger = logging.getLogger(__name__)

COVARIANCE_FILL_VALUE = np.NaN
COVARIANCE_FILL_VALUE = np.nan


def sigmas_to_covariances(sigmas: np.ndarray) -> np.ndarray:
Expand Down
4 changes: 2 additions & 2 deletions src/adam_core/coordinates/tests/test_covariances.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,13 @@ def test_CoordinateCovariances_to_from_matrix():
covariances = [None, np.ones((6, 6)).flatten()]
cov = CoordinateCovariances.from_kwargs(values=covariances)
cov_expected = np.ones((2, 6, 6))
cov_expected[0, :, :] = np.NaN
cov_expected[0, :, :] = np.nan
np.testing.assert_equal(cov.to_matrix(), cov_expected)

# Test when covariances are only None
covariances = [None, None]
cov = CoordinateCovariances.from_kwargs(values=covariances)
cov_expected = np.full((2, 6, 6), np.NaN)
cov_expected = np.full((2, 6, 6), np.nan)
np.testing.assert_equal(cov.to_matrix(), cov_expected)


Expand Down
12 changes: 6 additions & 6 deletions src/adam_core/coordinates/tests/test_residuals.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ def test_batch_coords_and_covariances_single_batch_missing_values():
# Single batch, one dimension has no values
coords = np.array(
[
[1.0, np.NaN, 3.0],
[2.0, np.NaN, 4.0],
[1.0, np.nan, 3.0],
[2.0, np.nan, 4.0],
]
)
covariances = np.array(
Expand Down Expand Up @@ -178,8 +178,8 @@ def test_batch_coords_and_covariances_single_batch_missing_values():
# Single batch, two dimensions have no values
coords = np.array(
[
[np.NaN, np.NaN, 3.0],
[np.NaN, np.NaN, 4.0],
[np.nan, np.nan, 3.0],
[np.nan, np.nan, 4.0],
]
)
covariances = np.array(
Expand Down Expand Up @@ -212,8 +212,8 @@ def test_batch_coords_and_covariances_multiple_batches():
# Multiple batches, different rows have different missing values
coords = np.array(
[
[1.0, np.NaN, 3.0],
[np.NaN, 3.0, 4.0],
[1.0, np.nan, 3.0],
[np.nan, 3.0, 4.0],
]
)
covariances = np.array(
Expand Down
4 changes: 2 additions & 2 deletions src/adam_core/coordinates/tests/test_spherical.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ def test_SphericalCoordinates_to_unit_sphere():
# that have NaN values for rho will be set to 1.0 and coordinates
# that have NaN values for vrho will be set to 0.0.
coords = SphericalCoordinates.from_kwargs(
rho=[1.0, np.NaN, 3.0],
rho=[1.0, np.nan, 3.0],
lon=[30.0, 45.0, 60.0],
lat=[-60, 0.0, 60.0],
vrho=[np.NaN, 0.002, -0.01],
vrho=[np.nan, 0.002, -0.01],
vlon=[0.005, 0.006, 0.007],
vlat=[-0.0005, 0.0006, -0.007],
origin=Origin.from_kwargs(code=["SUN", "SUN", "SUN"]),
Expand Down

0 comments on commit d992f84

Please sign in to comment.