Skip to content

Commit

Permalink
Upgrade to numpy>=2.0.0 (#117)
Browse files Browse the repository at this point in the history
* Upgrade to numpy>=2.0.0
* Remove PYOORB installation from CI
  • Loading branch information
moeyensj authored Sep 18, 2024
1 parent 941e3fb commit 917b1f4
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 26 deletions.
12 changes: 1 addition & 11 deletions .github/workflows/pip-build-lint-test-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,11 @@ jobs:
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip' # caching pip dependencies

- name: Install openorb dependencies
run: |
sudo apt-get update -y
sudo apt-get install -y gfortran liblapack-dev
wget -P /tmp/ https://storage.googleapis.com/oorb-data/oorb_data.tar.gz
mkdir -p /tmp/oorb/
tar -xvf /tmp/oorb_data.tar.gz -C /tmp/oorb/
cache: 'pip' # caching pip dependencies
- name: Install Testing Dependencies
run: |
pip install pip --upgrade
pip install ".[dev]"
# Install pyoorb propagator from source
pip install git+https://github.com/B612-Asteroid-Institute/adam-pyoorb.git@main
- name: Lint
run: pdm run lint
- name: Test with coverage
Expand Down
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 917b1f4

Please sign in to comment.