From 4e1c3642c6901457a9414a1e623431be9f613841 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlio=20Hoffimann?= Date: Tue, 14 Jan 2025 18:47:39 -0300 Subject: [PATCH] Replace reduce(hcat, ...) by stack(...) --- src/transforms/smoothing.jl | 2 +- src/utils/misc.jl | 2 +- test/partitioning.jl | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/transforms/smoothing.jl b/src/transforms/smoothing.jl index f707bf947..5bb003ea3 100644 --- a/src/transforms/smoothing.jl +++ b/src/transforms/smoothing.jl @@ -47,7 +47,7 @@ function _smooth(mesh, L, n, λ, μ; revert=false) points = eachvertex(mesh) # matrix with coordinates (nvertices x ndims) - X = reduce(hcat, to.(points)) |> transpose + X = stack(to, points, dims=1) # choose between apply and revert mode λ₁, λ₂ = revert ? (-μ, -λ) : (λ, μ) diff --git a/src/utils/misc.jl b/src/utils/misc.jl index f10a3d786..bb9b42829 100644 --- a/src/utils/misc.jl +++ b/src/utils/misc.jl @@ -46,7 +46,7 @@ See . function svdbasis(p::AbstractVector{<:Point}) checkdim(first(p), 3) ℒ = lentype(eltype(p)) - X = reduce(hcat, to.(p)) + X = stack(to, p) μ = sum(X, dims=2) / size(X, 2) Z = X .- μ U = usvd(Z).U diff --git a/test/partitioning.jl b/test/partitioning.jl index 34243513e..38a902fd1 100644 --- a/test/partitioning.jl +++ b/test/partitioning.jl @@ -152,8 +152,8 @@ end # all points in p1 are below those in p2 pts1 = [centroid(p1, i) for i in 1:nelements(p1)] pts2 = [centroid(p2, i) for i in 1:nelements(p2)] - X1 = reduce(hcat, to.(pts1)) - X2 = reduce(hcat, to.(pts2)) + X1 = stack(to, pts1) + X2 = stack(to, pts2) M1 = maximum(X1, dims=2) m2 = minimum(X2, dims=2) @test all(X1[2, j] < m2[2] for j in 1:size(X1, 2)) @@ -185,8 +185,8 @@ end # all points in p1 are to the left of p2 pts1 = [centroid(p1, i) for i in 1:nelements(p1)] pts2 = [centroid(p2, i) for i in 1:nelements(p2)] - X1 = reduce(hcat, to.(pts1)) - X2 = reduce(hcat, to.(pts2)) + X1 = stack(to, pts1) + X2 = stack(to, pts2) M1 = maximum(X1, dims=2) m2 = minimum(X2, dims=2) @test all(X1[1, j] < m2[1] for j in 1:size(X1, 2))