Skip to content

Commit 5b34c17

Browse files
authored
Replace reduce(hcat, ...) by stack(...) (#1159)
1 parent 3b30a9f commit 5b34c17

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/transforms/smoothing.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function _smooth(mesh, L, n, λ, μ; revert=false)
4747
points = eachvertex(mesh)
4848

4949
# matrix with coordinates (nvertices x ndims)
50-
X = reduce(hcat, to.(points)) |> transpose
50+
X = stack(to, points, dims=1)
5151

5252
# choose between apply and revert mode
5353
λ₁, λ₂ = revert ? (-μ, -λ) : (λ, μ)

src/utils/misc.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ See <https://math.stackexchange.com/a/99317>.
4646
function svdbasis(p::AbstractVector{<:Point})
4747
checkdim(first(p), 3)
4848
= lentype(eltype(p))
49-
X = reduce(hcat, to.(p))
49+
X = stack(to, p)
5050
μ = sum(X, dims=2) / size(X, 2)
5151
Z = X .- μ
5252
U = usvd(Z).U

test/partitioning.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ end
152152
# all points in p1 are below those in p2
153153
pts1 = [centroid(p1, i) for i in 1:nelements(p1)]
154154
pts2 = [centroid(p2, i) for i in 1:nelements(p2)]
155-
X1 = reduce(hcat, to.(pts1))
156-
X2 = reduce(hcat, to.(pts2))
155+
X1 = stack(to, pts1)
156+
X2 = stack(to, pts2)
157157
M1 = maximum(X1, dims=2)
158158
m2 = minimum(X2, dims=2)
159159
@test all(X1[2, j] < m2[2] for j in 1:size(X1, 2))
@@ -185,8 +185,8 @@ end
185185
# all points in p1 are to the left of p2
186186
pts1 = [centroid(p1, i) for i in 1:nelements(p1)]
187187
pts2 = [centroid(p2, i) for i in 1:nelements(p2)]
188-
X1 = reduce(hcat, to.(pts1))
189-
X2 = reduce(hcat, to.(pts2))
188+
X1 = stack(to, pts1)
189+
X2 = stack(to, pts2)
190190
M1 = maximum(X1, dims=2)
191191
m2 = minimum(X2, dims=2)
192192
@test all(X1[1, j] < m2[1] for j in 1:size(X1, 2))

0 commit comments

Comments
 (0)