Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix collect of ConcatDiskArray #427

Merged
merged 2 commits into from
Aug 29, 2024
Merged
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
2 changes: 1 addition & 1 deletion src/Cubes/Cubes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ function Base.propertynames(a::YAXArray, private::Bool=false)
end
end


Base.Generator(f, A::YAXArray) = Base.Generator(f, parent(A))
Base.ndims(a::YAXArray{<:Any,N}) where {N} = N
Base.eltype(a::YAXArray{T}) where {T} = T
function Base.permutedims(c::YAXArray, p)
Expand Down
4 changes: 2 additions & 2 deletions src/YAXTools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct Window
end


function PickAxisArray(parent, indmask, perm = nothing)
function PickAxisArray(parent, indmask, perm=nothing)
f = findall(isequal(true), indmask)
f2 = findall(isequal(Colon()), indmask)
f3 = findall(i -> isa(i, Tuple{Int,Int}), indmask)
Expand Down Expand Up @@ -79,4 +79,4 @@ function Base.eltype(p::PickAxisArray{T}) where {T}
end
end
Base.getindex(p::PickAxisArray, i::CartesianIndex) = p[i.I...]
end
end
19 changes: 18 additions & 1 deletion test/Cubes/transformedcubes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,24 @@
@test caxes(newcube) == (X(1.0:4.0), Y([1, 2, 3, 4, 5]), Z(["A", "B", "C"]))
@test ndims(newcube) == 3
@test size(newcube) == (4, 5, 3)
@test newcube[:, :, :] == cat(data..., dims = 3)
@test newcube[:, :, :] == cat(data..., dims=3)
@test getattributes(newcube) == reduce(merge, props)
end
@testset "ConcatDiskArray" begin
using Zarr
lon_range = X(-180:180)
lat_range = Y(-90:90)
data = [exp(cosd(lon)) + 3 * (lat / 90) for lon in lon_range, lat in lat_range]
a = YAXArray((lon_range, lat_range), data)
ds_ram = Dataset(; properties=Dict(), a)
path = tempname()
savedataset(ds_ram; path=path)
ds_disk = open_dataset(path)
a_ram = cat(ds_ram.a[X=1:100], ds_ram.a[X=101:200], dims=:X)
a_disk = cat(ds_disk.a[X=1:100], ds_disk.a[X=101:200], dims=:X)

@test collect(x for x in a_disk) == collect(x for x in a_ram)

rm(path, recursive=true)
end
end
Loading