From 9a4de2548eb5bc19f085f572dc2f687be75519dd Mon Sep 17 00:00:00 2001 From: HugoGranstrom <5092565+HugoGranstrom@users.noreply.github.com> Date: Fri, 29 Mar 2024 09:49:56 +0100 Subject: [PATCH 1/3] avoid name collisions of `meshgrid` in interpolate test --- tests/test_interpolate.nim | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_interpolate.nim b/tests/test_interpolate.nim index 576efe5..81d92c3 100644 --- a/tests/test_interpolate.nim +++ b/tests/test_interpolate.nim @@ -481,12 +481,12 @@ test "Trilinear f = x*y*z T: Tensor[float]": check abs(spline.eval(i, j, k)[2] - 1) < 1e-16 test "rbfBase f=x*y*z": - let pos = meshgrid(arraymancer.linspace(0.0, 1.0, 5), arraymancer.linspace(0.0, 1.0, 5), arraymancer.linspace(0.0, 1.0, 5)) + 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)) let vals = pos[_, 0] *. pos[_, 1] *. pos[_, 2] let rbfObj = newRbfBase(pos, vals) # We want test points in the interior to avoid the edges - let xTest = meshgrid(arraymancer.linspace(0.1, 0.9, 10), arraymancer.linspace(0.1, 0.9, 10), arraymancer.linspace(0.1, 0.9, 10)) + 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)) let yTest = rbfObj.eval(xTest) let yCorrect = xTest[_, 0] *. xTest[_, 1] *. xTest[_, 2] for x in abs(yCorrect - yTest): @@ -494,12 +494,12 @@ test "rbfBase f=x*y*z": check mean_squared_error(yTest, yCorrect) < 2e-4 test "rbf f=x*y*z": - let pos = meshgrid(arraymancer.linspace(0.0, 1.0, 5), arraymancer.linspace(0.0, 1.0, 5), arraymancer.linspace(0.0, 1.0, 5)) + 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)) let vals = pos[_, 0] *. pos[_, 1] *. pos[_, 2] let rbfObj = newRbf(pos, vals) # We want test points in the interior to avoid the edges - let xTest = meshgrid(arraymancer.linspace(0.1, 0.9, 10), arraymancer.linspace(0.1, 0.9, 10), arraymancer.linspace(0.1, 0.9, 10)) + 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)) let yTest = rbfObj.eval(xTest) let yCorrect = xTest[_, 0] *. xTest[_, 1] *. xTest[_, 2] for x in abs(yCorrect - yTest): From 1586935e37aa36196d84d43da1597864bb592ff4 Mon Sep 17 00:00:00 2001 From: HugoGranstrom <5092565+HugoGranstrom@users.noreply.github.com> Date: Fri, 29 Mar 2024 09:53:42 +0100 Subject: [PATCH 2/3] fix two other refernces --- src/numericalnim/rbf.nim | 2 +- tests/test_utils.nim | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/numericalnim/rbf.nim b/src/numericalnim/rbf.nim index f9ac005..44ce7ba 100644 --- a/src/numericalnim/rbf.nim +++ b/src/numericalnim/rbf.nim @@ -72,7 +72,7 @@ proc constructMeshedPatches*[T](grid: RbfGrid[T]): Tensor[float] = if grid.gridSize == 1: @[@[0.5].cycle(grid.gridDim)].toTensor else: - meshgrid(@[arraymancer.linspace(0 + grid.gridDelta / 2, 1 - grid.gridDelta / 2, grid.gridSize)].cycle(grid.gridDim)) + numericalnim.meshgrid(@[arraymancer.linspace(0 + grid.gridDelta / 2, 1 - grid.gridDelta / 2, grid.gridSize)].cycle(grid.gridDim)) template dist2(p1, p2: Tensor[float]): float = var result = 0.0 diff --git a/tests/test_utils.nim b/tests/test_utils.nim index 0d832d2..97c29c1 100644 --- a/tests/test_utils.nim +++ b/tests/test_utils.nim @@ -88,7 +88,7 @@ test "meshgrid": let x = [0, 1].toTensor let y = [2, 3].toTensor let z = [4, 5].toTensor - let grid = meshgrid(x, y, z) + let grid = numericalnim.meshgrid(x, y, z) 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 test "chi2 Tensor": From b3bdf0124d492f8703b33f64aaad6b4d78ba95dc Mon Sep 17 00:00:00 2001 From: HugoGranstrom <5092565+HugoGranstrom@users.noreply.github.com> Date: Fri, 29 Mar 2024 09:55:43 +0100 Subject: [PATCH 3/3] fix --- src/numericalnim/rbf.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/numericalnim/rbf.nim b/src/numericalnim/rbf.nim index 44ce7ba..1eb7153 100644 --- a/src/numericalnim/rbf.nim +++ b/src/numericalnim/rbf.nim @@ -72,7 +72,7 @@ proc constructMeshedPatches*[T](grid: RbfGrid[T]): Tensor[float] = if grid.gridSize == 1: @[@[0.5].cycle(grid.gridDim)].toTensor else: - numericalnim.meshgrid(@[arraymancer.linspace(0 + grid.gridDelta / 2, 1 - grid.gridDelta / 2, grid.gridSize)].cycle(grid.gridDim)) + utils.meshgrid(@[arraymancer.linspace(0 + grid.gridDelta / 2, 1 - grid.gridDelta / 2, grid.gridSize)].cycle(grid.gridDim)) template dist2(p1, p2: Tensor[float]): float = var result = 0.0