Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps: support numpy 2.0 #2391

Merged
merged 3 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
tests: enforce numpy arrays for accuracy checks
  • Loading branch information
mloubout committed Jun 26, 2024
commit c56da1e5effd62a9cbaa99ea7fa902e311a8fc26
12 changes: 6 additions & 6 deletions tests/test_interpolation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from math import sin, floor

import numpy as np
from numpy import sin, floor
import pytest
from sympy import Float

Expand Down Expand Up @@ -93,8 +92,8 @@ def precompute_linear_interpolation(points, grid, origin, r=2):

Allow larger radius with zero weights for testing.
"""
gridpoints = [tuple(floor((point[i]-origin[i])/grid.spacing[i])
for i in range(len(point))) for point in points]
gridpoints = np.array([tuple(floor((point[i]-origin[i])/grid.spacing[i])
for i in range(len(point))) for point in points])

interpolation_coeffs = np.zeros((len(points), grid.dim, r))
rs = r // 2 - 1
Expand All @@ -114,13 +113,14 @@ def test_precomputed_interpolation(r):
precomputed values for interpolation coefficients
"""
shape = (101, 101)
points = [(.05, .9), (.01, .8), (0.07, 0.84)]
points = np.array([(.05, .9), (.01, .8), (0.07, 0.84)])
origin = (0, 0)

grid = Grid(shape=shape, origin=origin)

def init(data):
# This is data with halo so need to shift to match the m.data expectations
print(grid.spacing)
for i in range(data.shape[0]):
for j in range(data.shape[1]):
data[i, j] = sin(grid.spacing[0]*(i-r)) + sin(grid.spacing[1]*(j-r))
Expand Down Expand Up @@ -638,7 +638,7 @@ def test_msf_interpolate():
with a TimeFunction
"""
shape = (101, 101)
points = [(.05, .9), (.01, .8), (0.07, 0.84)]
points = np.array([(.05, .9), (.01, .8), (0.07, 0.84)])
origin = (0, 0)

grid = Grid(shape=shape, origin=origin)
Expand Down
6 changes: 3 additions & 3 deletions tests/test_sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ def _precompute_linear_interpolation(self, points, grid, origin):
precomputes gridpoints and coefficients according to a linear
scheme to be used in PrecomputedSparseFunction.
"""
gridpoints = [
gridpoints = np.array([
tuple(
floor((point[i] - origin[i]) / grid.spacing[i]) for i in range(len(point))
)
for point in points
]
])

coefficients = np.zeros((len(points), 2, 2))
for i, point in enumerate(points):
Expand All @@ -41,7 +41,7 @@ def _precompute_linear_interpolation(self, points, grid, origin):

def test_precomputed_interpolation(self):
shape = (101, 101)
points = [(0.05, 0.9), (0.01, 0.8), (0.07, 0.84)]
points = np.array([(0.05, 0.9), (0.01, 0.8), (0.07, 0.84)])
origin = (0, 0)

grid = Grid(shape=shape, origin=origin)
Expand Down
Loading