Skip to content

Commit

Permalink
fix 1d mapslices (#661)
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaqz committed Mar 5, 2024
1 parent 5cb7e07 commit 9846bfe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/array/methods.jl
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ end
ds = DD.dims(A, _astuple(dims))
# Run one slice with dimensions to get the transformed dim
d_inds = map(d -> rebuild(d, 1), otherdims(A, ds))
example_dims = DD.dims(f(view(A, d_inds...)))
example_dims = length(d_inds) > 0 ? DD.dims(f(view(A, d_inds...))) : ()
replacement_dims = if isnothing(example_dims) || length(example_dims) != length(ds)
map(d -> rebuild(d, NoLookup()), ds)
else
Expand Down
6 changes: 6 additions & 0 deletions test/methods.jl
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,12 @@ end
@test size(y) == size(dims(y))
@test dims(y) == dims(x[2:9, :, :])
end

@testset "single dim" begin
x = X(1:10)
A = DimArray(ones(10), x)
@test mapslices(sum, A; dims=X) == fill(10.0, X(1))
end
end

@testset "cumsum" begin
Expand Down

0 comments on commit 9846bfe

Please sign in to comment.