Skip to content

Commit e1e1653

Browse files
avoid name collisions of meshgrid (#42)
* avoid name collisions of `meshgrid`
1 parent ba8e3b4 commit e1e1653

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/numericalnim/rbf.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ proc constructMeshedPatches*[T](grid: RbfGrid[T]): Tensor[float] =
7272
if grid.gridSize == 1:
7373
@[@[0.5].cycle(grid.gridDim)].toTensor
7474
else:
75-
meshgrid(@[arraymancer.linspace(0 + grid.gridDelta / 2, 1 - grid.gridDelta / 2, grid.gridSize)].cycle(grid.gridDim))
75+
utils.meshgrid(@[arraymancer.linspace(0 + grid.gridDelta / 2, 1 - grid.gridDelta / 2, grid.gridSize)].cycle(grid.gridDim))
7676

7777
template dist2(p1, p2: Tensor[float]): float =
7878
var result = 0.0

tests/test_interpolate.nim

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -481,25 +481,25 @@ test "Trilinear f = x*y*z T: Tensor[float]":
481481
check abs(spline.eval(i, j, k)[2] - 1) < 1e-16
482482

483483
test "rbfBase f=x*y*z":
484-
let pos = meshgrid(arraymancer.linspace(0.0, 1.0, 5), arraymancer.linspace(0.0, 1.0, 5), arraymancer.linspace(0.0, 1.0, 5))
484+
let pos = numericalnim.meshgrid(arraymancer.linspace(0.0, 1.0, 5), arraymancer.linspace(0.0, 1.0, 5), arraymancer.linspace(0.0, 1.0, 5))
485485
let vals = pos[_, 0] *. pos[_, 1] *. pos[_, 2]
486486
let rbfObj = newRbfBase(pos, vals)
487487

488488
# We want test points in the interior to avoid the edges
489-
let xTest = meshgrid(arraymancer.linspace(0.1, 0.9, 10), arraymancer.linspace(0.1, 0.9, 10), arraymancer.linspace(0.1, 0.9, 10))
489+
let xTest = numericalnim.meshgrid(arraymancer.linspace(0.1, 0.9, 10), arraymancer.linspace(0.1, 0.9, 10), arraymancer.linspace(0.1, 0.9, 10))
490490
let yTest = rbfObj.eval(xTest)
491491
let yCorrect = xTest[_, 0] *. xTest[_, 1] *. xTest[_, 2]
492492
for x in abs(yCorrect - yTest):
493493
check x < 0.16
494494
check mean_squared_error(yTest, yCorrect) < 2e-4
495495

496496
test "rbf f=x*y*z":
497-
let pos = meshgrid(arraymancer.linspace(0.0, 1.0, 5), arraymancer.linspace(0.0, 1.0, 5), arraymancer.linspace(0.0, 1.0, 5))
497+
let pos = numericalnim.meshgrid(arraymancer.linspace(0.0, 1.0, 5), arraymancer.linspace(0.0, 1.0, 5), arraymancer.linspace(0.0, 1.0, 5))
498498
let vals = pos[_, 0] *. pos[_, 1] *. pos[_, 2]
499499
let rbfObj = newRbf(pos, vals)
500500

501501
# We want test points in the interior to avoid the edges
502-
let xTest = meshgrid(arraymancer.linspace(0.1, 0.9, 10), arraymancer.linspace(0.1, 0.9, 10), arraymancer.linspace(0.1, 0.9, 10))
502+
let xTest = numericalnim.meshgrid(arraymancer.linspace(0.1, 0.9, 10), arraymancer.linspace(0.1, 0.9, 10), arraymancer.linspace(0.1, 0.9, 10))
503503
let yTest = rbfObj.eval(xTest)
504504
let yCorrect = xTest[_, 0] *. xTest[_, 1] *. xTest[_, 2]
505505
for x in abs(yCorrect - yTest):

tests/test_utils.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ test "meshgrid":
8888
let x = [0, 1].toTensor
8989
let y = [2, 3].toTensor
9090
let z = [4, 5].toTensor
91-
let grid = meshgrid(x, y, z)
91+
let grid = numericalnim.meshgrid(x, y, z)
9292
check grid == [[0, 2, 4], [1, 2, 4], [0, 3, 4], [1, 3, 4], [0, 2, 5], [1, 2, 5], [0, 3, 5], [1, 3, 5]].toTensor
9393

9494
test "chi2 Tensor":

0 commit comments

Comments
 (0)