Skip to content

Commit c56da1e

Browse files
committed
tests: enforce numpy arrays for accuracy checks
1 parent 5d6b610 commit c56da1e

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

‎tests/test_interpolation.py‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
from math import sin, floor
2-
31
import numpy as np
2+
from numpy import sin, floor
43
import pytest
54
from sympy import Float
65

@@ -93,8 +92,8 @@ def precompute_linear_interpolation(points, grid, origin, r=2):
9392
9493
Allow larger radius with zero weights for testing.
9594
"""
96-
gridpoints = [tuple(floor((point[i]-origin[i])/grid.spacing[i])
97-
for i in range(len(point))) for point in points]
95+
gridpoints = np.array([tuple(floor((point[i]-origin[i])/grid.spacing[i])
96+
for i in range(len(point))) for point in points])
9897

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

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

122121
def init(data):
123122
# This is data with halo so need to shift to match the m.data expectations
123+
print(grid.spacing)
124124
for i in range(data.shape[0]):
125125
for j in range(data.shape[1]):
126126
data[i, j] = sin(grid.spacing[0]*(i-r)) + sin(grid.spacing[1]*(j-r))
@@ -638,7 +638,7 @@ def test_msf_interpolate():
638638
with a TimeFunction
639639
"""
640640
shape = (101, 101)
641-
points = [(.05, .9), (.01, .8), (0.07, 0.84)]
641+
points = np.array([(.05, .9), (.01, .8), (0.07, 0.84)])
642642
origin = (0, 0)
643643

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

‎tests/test_sparse.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ def _precompute_linear_interpolation(self, points, grid, origin):
2121
precomputes gridpoints and coefficients according to a linear
2222
scheme to be used in PrecomputedSparseFunction.
2323
"""
24-
gridpoints = [
24+
gridpoints = np.array([
2525
tuple(
2626
floor((point[i] - origin[i]) / grid.spacing[i]) for i in range(len(point))
2727
)
2828
for point in points
29-
]
29+
])
3030

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

4242
def test_precomputed_interpolation(self):
4343
shape = (101, 101)
44-
points = [(0.05, 0.9), (0.01, 0.8), (0.07, 0.84)]
44+
points = np.array([(0.05, 0.9), (0.01, 0.8), (0.07, 0.84)])
4545
origin = (0, 0)
4646

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

0 commit comments

Comments
 (0)