Skip to content

Commit

Permalink
Fix collect of concat arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
danlooo committed Aug 26, 2024
1 parent eb75dfc commit 782146e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
4 changes: 3 additions & 1 deletion 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 @@ -80,3 +80,5 @@ function Base.eltype(p::PickAxisArray{T}) where {T}
end
Base.getindex(p::PickAxisArray, i::CartesianIndex) = p[i.I...]
end

Base.Generator(f, A::YAXArray) = Base.Generator(f, parent(A))
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

0 comments on commit 782146e

Please sign in to comment.