Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/ZArray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,16 @@ end
Base.eltype(::ZArray{T}) where {T} = T
Base.ndims(::ZArray{<:Any,N}) where {N} = N
Base.size(z::ZArray) = z.metadata.shape[]
Base.size(z::ZArray,i) = z.metadata.shape[][i]
function Base.size(z::ZArray,i)
len = length(z.metadata.shape[])
if 0 < i <= len
z.metadata.shape[][i]
elseif i > len
1
else
error("arraysize: dimension out of range: Got index $i, but the array has only $len dimensions")
end
end
Base.length(z::ZArray) = prod(z.metadata.shape[])
Base.lastindex(z::ZArray,n) = size(z,n)
Base.lastindex(z::ZArray{<:Any,1}) = size(z,1)
Expand Down
8 changes: 8 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ using Dates
@test ndims(z) === 2
@test size(z) === (2, 3)
@test size(z, 2) === 3
@test size(z,300) === 1
@test_throws ErrorException size(z, -1)
@inferred size(z)
@inferred size(z, 2)
@test length(z) === 2 * 3
Expand Down Expand Up @@ -211,6 +213,12 @@ end
@test_throws ArgumentError resize!(a,(-1,2))
end

@testset "concatenate" begin
a = zzeros(Int64, 10, 10, chunks = (5,2), fill_value=-1)
ca = cat(a, a, dims=3)
@test size(ca) == (10,10,2)
end

@testset "string/Char array getindex/setindex" begin
aa = ["this", "is", "all ", "ascii"]
bb = ["And" "Unicode"; "ματριξ" missing]
Expand Down
Loading