From 9fea369725e1e52b3db48a1dc05963a154ad006d Mon Sep 17 00:00:00 2001 From: Lazaro Alonso Date: Tue, 29 Oct 2024 10:43:49 +0100 Subject: [PATCH 1/4] replace caxes by dims --- src/Cubes/Cubes.jl | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/Cubes/Cubes.jl b/src/Cubes/Cubes.jl index b8f24eae..58594716 100644 --- a/src/Cubes/Cubes.jl +++ b/src/Cubes/Cubes.jl @@ -204,16 +204,19 @@ function DD.rebuild(A::YAXArray; data=parent(A), dims=DD.dims(A), metadata=DD.me YAXArray(dims, data, metadata; cleaner=A.cleaner) end -function caxes(x) - #@show x - #@show typeof(x) - dims = map(enumerate(dimnames(x))) do a - index, symbol = a - values = YAXArrayBase.dimvals(x, index) - DD.Dim{symbol}(values) - end - (dims... ,) -end +# function caxes(x) +# #@show x +# #@show typeof(x) +# dims = map(enumerate(dimnames(x))) do a +# index, symbol = a +# values = YAXArrayBase.dimvals(x, index) +# DD.Dim{symbol}(values) +# end +# (dims... ,) +# end + +caxes(x) = DD.dims(x) + caxes(c::YAXArray) = getfield(c, :axes) """ caxes From 67709166b6d23ac94c678aa9023e3d192d905e26 Mon Sep 17 00:00:00 2001 From: Lazaro Alonso Date: Tue, 29 Oct 2024 11:10:37 +0100 Subject: [PATCH 2/4] collect --- src/Cubes/Cubes.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cubes/Cubes.jl b/src/Cubes/Cubes.jl index 58594716..db666864 100644 --- a/src/Cubes/Cubes.jl +++ b/src/Cubes/Cubes.jl @@ -215,7 +215,7 @@ end # (dims... ,) # end -caxes(x) = DD.dims(x) +caxes(x) = collect(DD.dims(x)) caxes(c::YAXArray) = getfield(c, :axes) """ From 015144fe009671c9729064fb0028c9a848710359 Mon Sep 17 00:00:00 2001 From: Felix Cremer Date: Tue, 29 Oct 2024 15:18:01 +0100 Subject: [PATCH 3/4] Only replace caxes by dims for AbstractDimArray --- src/Cubes/Cubes.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cubes/Cubes.jl b/src/Cubes/Cubes.jl index db666864..97fa16b9 100644 --- a/src/Cubes/Cubes.jl +++ b/src/Cubes/Cubes.jl @@ -215,7 +215,7 @@ end # (dims... ,) # end -caxes(x) = collect(DD.dims(x)) +caxes(x::DD.AbstractDimArray) = collect(DD.dims(x)) caxes(c::YAXArray) = getfield(c, :axes) """ From 8f356387685b660847b2bea23f7affb1bbc6eb65 Mon Sep 17 00:00:00 2001 From: Felix Cremer Date: Tue, 29 Oct 2024 22:01:45 +0100 Subject: [PATCH 4/4] Reenable fallback caxes --- src/Cubes/Cubes.jl | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Cubes/Cubes.jl b/src/Cubes/Cubes.jl index 97fa16b9..6487b718 100644 --- a/src/Cubes/Cubes.jl +++ b/src/Cubes/Cubes.jl @@ -204,16 +204,16 @@ function DD.rebuild(A::YAXArray; data=parent(A), dims=DD.dims(A), metadata=DD.me YAXArray(dims, data, metadata; cleaner=A.cleaner) end -# function caxes(x) -# #@show x -# #@show typeof(x) -# dims = map(enumerate(dimnames(x))) do a -# index, symbol = a -# values = YAXArrayBase.dimvals(x, index) -# DD.Dim{symbol}(values) -# end -# (dims... ,) -# end +function caxes(x) + #@show x + #@show typeof(x) + dims = map(enumerate(dimnames(x))) do a + index, symbol = a + values = YAXArrayBase.dimvals(x, index) + DD.Dim{symbol}(values) + end + (dims... ,) +end caxes(x::DD.AbstractDimArray) = collect(DD.dims(x))