Skip to content

Commit

Permalink
size and ndims for applied vec
Browse files Browse the repository at this point in the history
  • Loading branch information
jishnub committed Dec 6, 2023
1 parent 8c7ad30 commit 2e96cb4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/lazyconcat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -972,4 +972,6 @@ searchsorted(f::Vcat{<:Any,1}, x) = searchsortedfirst(f, x):searchsortedlast(f,x
###

@inline applied_eltype(::typeof(vec), a) = eltype(a)
@inline applied_axes(::typeof(vec), a) = (oneto(length(a)),)
@inline applied_axes(::typeof(vec), a) = (oneto(length(a)),)
@inline applied_ndims(::typeof(vec), a) = 1

Check warning on line 976 in src/lazyconcat.jl

View check run for this annotation

Codecov / codecov/patch

src/lazyconcat.jl#L975-L976

Added lines #L975 - L976 were not covered by tests
@inline applied_size(::typeof(vec), a) = (length(a),)
10 changes: 10 additions & 0 deletions test/applytests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ import ArrayLayouts: StridedLayout
end
end

@testset "vec" begin
A = zeros(2,2)
v = applied(vec, A)
w = vec(A)
@test size(v) == size(w) == (4,)
@test axes(v) == axes(w) == (Base.OneTo(4),)
@test ndims(v) == ndims(w) == 1
@test eltype(v) == eltype(w) == Float64
end

@testset "view" begin
a = ApplyArray(+,[1,2,3],[3,4,5])
v = view(a,1:2)
Expand Down

0 comments on commit 2e96cb4

Please sign in to comment.