From 81b2489571553527424a6a6b931d7b772f528445 Mon Sep 17 00:00:00 2001 From: Felix Cremer Date: Tue, 5 Sep 2023 11:39:34 +0200 Subject: [PATCH 01/10] Replace subsetcube in tutorial with getindex --- docs/src/tutorials/esdl/examples_from_esdl_study_1.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/src/tutorials/esdl/examples_from_esdl_study_1.jl b/docs/src/tutorials/esdl/examples_from_esdl_study_1.jl index 601aef973..9d3653dde 100644 --- a/docs/src/tutorials/esdl/examples_from_esdl_study_1.jl +++ b/docs/src/tutorials/esdl/examples_from_esdl_study_1.jl @@ -46,6 +46,7 @@ vars = ["gross_primary_productivity", "air_temperature_2m", "surface_moisture"] time_overlap = Date("2001-01-01")..Date("2020-12-31") # So we "virtually get" the cube data virtually: +cube_subset = cube_handle[Variable=At(vars), time=At(time_overlap)] cube_subset = subsetcube(cube_handle, variable=vars, time=time_overlap) # The next function estimates the median seasonal cycle. This changes the dimension of the cube, as the time domain is replaced by day of year (doy); Eq. 9 in the manuscript: From 84f68278782eba0552e8e2526e572fb907449982 Mon Sep 17 00:00:00 2001 From: Felix Cremer Date: Tue, 5 Sep 2023 14:18:21 +0200 Subject: [PATCH 02/10] Delete getCubeDes This is not used anymore, because the show methods of DimensionalData are used. --- src/Cubes/Cubes.jl | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Cubes/Cubes.jl b/src/Cubes/Cubes.jl index fd0b6b553..62bcee95d 100644 --- a/src/Cubes/Cubes.jl +++ b/src/Cubes/Cubes.jl @@ -502,10 +502,6 @@ end cubesize(c::YAXArray{T}) where {T} = (sizeof(T)) * prod(map(length, caxes(c))) cubesize(::YAXArray{T,0}) where {T} = sizeof(T) -getCubeDes(::DD.Dimension) = "Cube axis" -getCubeDes(::YAXArray) = "YAXArray" -getCubeDes(::Type{T}) where {T} = string(T) - loadingstatus(x) = "loaded in memory" loadingstatus(x::DiskArrays.AbstractDiskArray) = "loaded lazily" From 163be8e40ecc2aa7cce3bbec142c9dcaef346766 Mon Sep 17 00:00:00 2001 From: Felix Cremer Date: Tue, 5 Sep 2023 14:23:28 +0200 Subject: [PATCH 03/10] Remove commented interpretsubset --- src/Cubes/Cubes.jl | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/src/Cubes/Cubes.jl b/src/Cubes/Cubes.jl index 62bcee95d..d81fddaad 100644 --- a/src/Cubes/Cubes.jl +++ b/src/Cubes/Cubes.jl @@ -419,24 +419,6 @@ end sorted(x, y) = x < y ? (x, y) : (y, x) -#TODO move everything that is subset-related to its own file or to axes.jl -#= -interpretsubset(subexpr::Union{CartesianIndices{1},LinearIndices{1}}, ax) = - subexpr.indices[1] -interpretsubset(subexpr::CartesianIndex{1}, ax) = subexpr.I[1] -interpretsubset(subexpr, ax) = axVal2Index(ax, subexpr, fuzzy=true) -function interpretsubset(subexpr::NTuple{2,Any}, ax) - x, y = sorted(subexpr...) - Colon()(sorted(axVal2Index_lb(ax, x), axVal2Index_ub(ax, y))...) -end -interpretsubset(subexpr::NTuple{2,Int}, ax::RangeAxis{T}) where {T<:TimeType} = - interpretsubset(map(T, subexpr), ax) -interpretsubset(subexpr::UnitRange{<:Integer}, ax::RangeAxis{T}) where {T<:TimeType} = - interpretsubset(T(first(subexpr)) .. T(last(subexpr) + 1), ax) -interpretsubset(subexpr::Interval, ax) = interpretsubset((subexpr.left, subexpr.right), ax) -interpretsubset(subexpr::AbstractVector, ax::CategoricalAxis) = - axVal2Index.(Ref(ax), subexpr, fuzzy=true) -=# function _subsetcube(z, subs; kwargs...) kwargs = Dict{Any,Any}(kwargs) From 50ed8eb93f6347eb101aa4a99a04188a002aa3a0 Mon Sep 17 00:00:00 2001 From: Felix Cremer Date: Tue, 5 Sep 2023 14:24:13 +0200 Subject: [PATCH 04/10] Remove old renameaxis code --- src/Cubes/Cubes.jl | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/src/Cubes/Cubes.jl b/src/Cubes/Cubes.jl index d81fddaad..6d54515db 100644 --- a/src/Cubes/Cubes.jl +++ b/src/Cubes/Cubes.jl @@ -391,24 +391,6 @@ _iscompressed(c) = YAXArrayBase.iscompressed(c) # lift renameaxis functionality from Axes.jl to YAXArrays renameaxis!(c::YAXArray, p::Pair) = DD.set(c, Symbol(first(p)) => last(p)) -#= -function renameaxis!(c::YAXArray, p::Pair) - #This needs to be deleted, because DimensionalData cannot update the axlist - # Because this is a tuple instead of a vector - axlist = caxes(c) - i = findAxis(p[1], axlist) - axlist[i] = renameaxis(axlist[i], p[2]) - c -end -function renameaxis!(c::YAXArray, p::Pair{<:Any,<:CubeAxis}) - i = findAxis(p[1], caxes(c)) - i === nothing && throw(ArgumentError("$(p[1]) Axis not found")) - length(caxes(c)[i].values) == length(p[2].values) || - throw(ArgumentError("Length of replacement axis must equal length of old axis")) - caxes(c)[i] = p[2] - c -end -=# function _subsetcube end function subsetcube(z::YAXArray{T}; kwargs...) where {T} From 6609513e28a0ed2bed8275ca921a93df690253c6 Mon Sep 17 00:00:00 2001 From: Felix Cremer Date: Tue, 5 Sep 2023 14:24:41 +0200 Subject: [PATCH 05/10] Remove commented getindex --- src/Cubes/Cubes.jl | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/Cubes/Cubes.jl b/src/Cubes/Cubes.jl index 6d54515db..143c766ce 100644 --- a/src/Cubes/Cubes.jl +++ b/src/Cubes/Cubes.jl @@ -272,16 +272,6 @@ cubechunks(c) = approx_chunksize(eachchunk(c)) DiskArrays.eachchunk(c::YAXArray) = c.chunks getindex_all(a) = getindex(a, ntuple(_ -> Colon(), ndims(a))...).data -#= -function Base.getindex(x::YAXArray, i...) - if length(i)==1 && istable(first(i)) - batchextract(x,first(i)) - else - getdata(x)[i...] - end -end -=# - function batchextract(x,i) # This function should be documented and moved to DimensionalData From 44d45837f8baf5ee2a4529d8f3ce209b73fab146 Mon Sep 17 00:00:00 2001 From: Felix Cremer Date: Tue, 5 Sep 2023 14:25:26 +0200 Subject: [PATCH 06/10] Remove commented Axes module definition --- src/Cubes/Cubes.jl | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/src/Cubes/Cubes.jl b/src/Cubes/Cubes.jl index 143c766ce..2001c24e4 100644 --- a/src/Cubes/Cubes.jl +++ b/src/Cubes/Cubes.jl @@ -27,31 +27,6 @@ function subsetcube end "Returns the axes of a Cube" function caxes end -# TODO: Give Axes an own module in YAXArrays -#= -include("Axes.jl") -using .Axes: - CubeAxis, - RangeAxis, - CategoricalAxis, - findAxis, - getAxis, - axVal2Index, - axname, - axsym, - axVal2Index_lb, - axVal2Index_ub, - renameaxis, - axcopy - -""" -The `Axes` module handles the Axes of a data cube. -It provides the following exports: - -$(EXPORTS) -""" -Axes -=# """ mutable struct CleanMe From 0a88a009ac5b5a8e836a6f04806c053029f1bea6 Mon Sep 17 00:00:00 2001 From: Felix Cremer Date: Tue, 5 Sep 2023 14:28:19 +0200 Subject: [PATCH 07/10] Remove commented imports of Axes module --- src/DAT/DAT.jl | 2 - src/DAT/dciterators.jl | 1 - src/DAT/registration.jl | 1 - src/DAT/tablestats.jl | 1 - src/DatasetAPI/Datasets.jl | 3 +- test/Cubes/axes.jl | 108 ------------------------------------- test/Datasets/datasets.jl | 3 -- test/runtests.jl | 1 - 8 files changed, 1 insertion(+), 119 deletions(-) delete mode 100644 test/Cubes/axes.jl diff --git a/src/DAT/DAT.jl b/src/DAT/DAT.jl index a9677424f..6904822f6 100644 --- a/src/DAT/DAT.jl +++ b/src/DAT/DAT.jl @@ -18,8 +18,6 @@ using Distributed: import ..Cubes: cubechunks, iscompressed, chunkoffset, YAXArray, caxes import ..Cubes: cubechunks, iscompressed, chunkoffset, YAXArray, caxes import ..YAXArrays: findAxis, getOutAxis, getAxis -#import ..Cubes.Axes: -# AxisDescriptor, axname, ByInference, axsym, getOutAxis, getAxis, findAxis, match_axis import ..Datasets: Dataset, createdataset using ..YAXArrays: ByInference, YAXArrays import ...YAXArrays.workdir diff --git a/src/DAT/dciterators.jl b/src/DAT/dciterators.jl index 76314f923..9ebef24f2 100644 --- a/src/DAT/dciterators.jl +++ b/src/DAT/dciterators.jl @@ -1,6 +1,5 @@ import YAXArrays.DAT: DATConfig import YAXArrays.YAXTools: PickAxisArray -#using YAXArrays.Cubes.Axes: axcopy using DiskArrays: GridChunks, AbstractDiskArray using Tables: Tables, Schema, AbstractColumns diff --git a/src/DAT/registration.jl b/src/DAT/registration.jl index 242c74fa8..9d83f317c 100644 --- a/src/DAT/registration.jl +++ b/src/DAT/registration.jl @@ -1,5 +1,4 @@ export InDims, OutDims, MovingWindow -#using ..Cubes.Axes: get_descriptor, findAxis, Axes import ..YAXArrays: get_descriptor, findAxis, AxisDescriptor using ..YAXArrays: YAXDefaults using YAXArrayBase: yaxcreate diff --git a/src/DAT/tablestats.jl b/src/DAT/tablestats.jl index 163de965c..0d4ef3d82 100644 --- a/src/DAT/tablestats.jl +++ b/src/DAT/tablestats.jl @@ -1,5 +1,4 @@ import OnlineStats: OnlineStat, Extrema, fit!, value, HistogramStat, Ash -#import ...Cubes.Axes: CategoricalAxis, RangeAxis import IterTools using WeightedOnlineStats using Distributed: nworkers diff --git a/src/DatasetAPI/Datasets.jl b/src/DatasetAPI/Datasets.jl index 8ad7112ef..c296c5dcf 100644 --- a/src/DatasetAPI/Datasets.jl +++ b/src/DatasetAPI/Datasets.jl @@ -1,6 +1,5 @@ module Datasets -#import ..Cubes.Axes: axsym, axname, CubeAxis, findAxis, CategoricalAxis, RangeAxis, caxes -import ..Cubes: Cubes, YAXArray, concatenatecubes, CleanMe, subsetcube, copy_diskarray, setchunks, caxes, readcubedata, cubesize, formatbytes +import ..Cubes: Cubes, YAXArray, concatenatecubes, CleanMe, subsetcube, copy_diskarray, setchunks, caxes using ...YAXArrays: YAXArrays, YAXDefaults, findAxis using DataStructures: OrderedDict, counter using Dates: Day, Hour, Minute, Second, Month, Year, Date, DateTime, TimeType, AbstractDateTime, Period diff --git a/test/Cubes/axes.jl b/test/Cubes/axes.jl deleted file mode 100644 index d539e3b25..000000000 --- a/test/Cubes/axes.jl +++ /dev/null @@ -1,108 +0,0 @@ -@testset "Axes" begin - - using Dates - using YAXArrays.Cubes.Axes: - axVal2Index, axVal2Index_lb, axVal2Index_ub, findAxis, axname, axsym, renameaxis - using YAXArrayBase: dimname, dimvals, iscontdim - - axestotest = [ - (CategoricalAxis, "CatAxis", ["One", "Two", "Three"], nothing), - (RangeAxis, "IntRange", 1:10, 1), - (RangeAxis, "FloatRange", 1.0:-0.1:0.1, 0.1), - ( - RangeAxis, - "MonthTimeRange", - Date(2001, 1, 1):Month(1):Date(2002, 12, 31), - Day(30), - ), - ( - RangeAxis, - "DayTimeRange", - DateTime(2002, 1, 1):Day(1):DateTime(2002, 1, 31), - Hour(24), - ), - (RangeAxis, "Single_IntRange", 1:1, 0), - - #This is currently not used, because we need to design, how this should behave. - ( - RangeAxis, - "IrregularTimeAxis", - [DateTime("2016-10-03T10:12:28"), DateTime("2016-10-15T10:12:28"), - DateTime("2016-10-27T10:12:28"), DateTime("2016-11-08T10:12:28"), - DateTime("2016-11-20T10:12:28"), DateTime("2016-12-02T10:12:28"), - DateTime("2016-12-14T10:12:27"), DateTime("2016-12-26T10:12:27"), - DateTime("2017-01-07T10:12:25"), DateTime("2017-01-19T10:12:25"), - DateTime("2017-01-31T10:12:25"), DateTime("2017-02-24T10:12:24")], - Day(1) - ), - (RangeAxis, "PureArray", [0.0, 0.2, 0.4, 0.6], 0.2), - (CategoricalAxis, "CatAxis", ["One", "Two", "Three", "Four", "Five", - "Six", "Seven", "Eight", "Nine", "Ten", "Eleven"], nothing), - ] - - for (axt, axn, axv, axstep) in axestotest - ax = axt(axn, axv) - @test size(ax) == size(axv) - @test size(ax, 1) == size(axv, 1) - @test ndims(ax) == 1 - @test length(ax) == length(axv) - ax2 = YAXArrays.Cubes.Axes.axcopy(ax, axv) - ax3 = YAXArrays.Cubes.Axes.axcopy(ax) - @test typeof(ax2) == typeof(ax) - @test ax2.values == ax.values - @test typeof(ax3) == typeof(ax) - @test ax3.values == ax.values - b = IOBuffer() - show(b, ax) - @test caxes(ax) == [ax] - @test YAXArrays.Cubes.Axes.axname(ax) == axn - @test YAXArrays.Cubes.Axes.axname(typeof(ax)) == axn - @test YAXArrays.Cubes.axsym(ax) == Symbol(axn) - @test dimname(ax, 1) == axn - @test dimvals(ax, 1) == axv - #Test axVal2Index separately - if ax isa CategoricalAxis - for (i, v) in enumerate(axv) - @test axVal2Index(ax, v) == i - @test axVal2Index(ax, v[1:2], fuzzy=true) == i - end - @test iscontdim(ax, 1) == false - else - for (i, v) in enumerate(axv) - @test axVal2Index(ax, v) == i - #@test axVal2Index_ub(ax, v + axstep / 2, fuzzy = true) == i - #@test axVal2Index_lb(ax, v - axstep / 2, fuzzy = true) == i - end - @test iscontdim(ax, 1) == true - end - ax3 = renameaxis(ax, "Test") - ax4 = renameaxis(ax, :Test) - @test axname(ax3) == "Test" - @test axsym(ax3) == :Test - - # test getindex method - for i in eachindex(axv) - @test ax[i] == axv[i] - end - end - axlist = map(i -> i[1](i[2], i[3]), axestotest) - @test findAxis("Int", axlist) == 2 - @test findAxis(RangeAxis("FloatRange", 1.0:-0.1:0.1), axlist) == 3 - @test getAxis(RangeAxis("FloatRange", 1.0:-0.1:0.1), axlist) == - RangeAxis("FloatRange", 1.0:-0.1:0.1) - #Test whether multiple axes with same name throw an error - @test_throws ErrorException findAxis("CatAxis", axlist) - - multiplevalax = CategoricalAxis("MultVal", ["One", "Two", "One"]) - @test_throws ErrorException axVal2Index(multiplevalax, "one", fuzzy=true) - @testset "Hashtests" begin - catax = CategoricalAxis("Catax", [1, 2]) - catay = CategoricalAxis("Catay", [1, 2]) - catax2 = CategoricalAxis("Catax", [2, 2]) - cataxfloat = CategoricalAxis("Catax", [1.0, 2.0]) - @test hash(catax) == hash(cataxfloat) - @test hash(catax) != hash(catay) - @test hash(catax) != hash(catax2) - end - -end diff --git a/test/Datasets/datasets.jl b/test/Datasets/datasets.jl index 87b0480ba..45ef2a71d 100644 --- a/test/Datasets/datasets.jl +++ b/test/Datasets/datasets.jl @@ -193,16 +193,13 @@ end @testset "collectdims" begin dcollect = YAXArrays.Datasets.collectdims(m) @test dcollect["time"].ax isa DD.Dimension - #@test YAXArrays.Cubes.Axes.axname(dcollect["time"].ax) == "time" @test DD.lookup(dcollect["time"].ax) == DateTime(2001, 1, 4):Day(1):DateTime(2001, 1, 13) @test dcollect["time"].offs == 2 @test dcollect["d2"].ax isa DD.Dimension - #@test YAXArrays.Cubes.Axes.axname(dcollect["d2"].ax) == "d2" @test DD.lookup(dcollect["d2"].ax) == 0.1:0.1:0.5 @test dcollect["d2"].offs == 0 @test dcollect["d3"].ax isa DD.Dimension - #@test YAXArrays.Cubes.Axes.axname(dcollect["d3"].ax) == "d3" @test DD.lookup(dcollect["d3"].ax) == ["One", "Two"] @test dcollect["d3"].offs == 0 a1 = [0.1, 0.2, 0.3, 0.4] diff --git a/test/runtests.jl b/test/runtests.jl index dd8f12bd6..75fcebd17 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -8,7 +8,6 @@ using YAXArrays: YAXArrays as YAX @run_package_tests include("tools.jl") -#include("Cubes/axes.jl") include("Cubes/cubes.jl") include("Cubes/transformedcubes.jl") include("Cubes/batchextraction.jl") From 8a9874eef8516e9dd76742a124e5e3ca625867f4 Mon Sep 17 00:00:00 2001 From: Felix Cremer Date: Wed, 6 Sep 2023 15:16:26 +0200 Subject: [PATCH 08/10] Remove usage of subsetcube from docs --- docs/src/tutorials/esdl/examples_from_esdl_study_1.jl | 3 +-- docs/src/tutorials/intro.jl | 9 ++++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/src/tutorials/esdl/examples_from_esdl_study_1.jl b/docs/src/tutorials/esdl/examples_from_esdl_study_1.jl index 9d3653dde..7dfc28769 100644 --- a/docs/src/tutorials/esdl/examples_from_esdl_study_1.jl +++ b/docs/src/tutorials/esdl/examples_from_esdl_study_1.jl @@ -46,8 +46,7 @@ vars = ["gross_primary_productivity", "air_temperature_2m", "surface_moisture"] time_overlap = Date("2001-01-01")..Date("2020-12-31") # So we "virtually get" the cube data virtually: -cube_subset = cube_handle[Variable=At(vars), time=At(time_overlap)] -cube_subset = subsetcube(cube_handle, variable=vars, time=time_overlap) +cube_subset = cube_handle[Variable=At(vars), time=time_overlap] # The next function estimates the median seasonal cycle. This changes the dimension of the cube, as the time domain is replaced by day of year (doy); Eq. 9 in the manuscript: # $$ diff --git a/docs/src/tutorials/intro.jl b/docs/src/tutorials/intro.jl index 6561002ab..7ad688332 100644 --- a/docs/src/tutorials/intro.jl +++ b/docs/src/tutorials/intro.jl @@ -3,6 +3,7 @@ # In this tutorial we will explore the features of the YAXArrays package. using YAXArrays, EarthDataLab, Zarr, NetCDF +using DimensionalData: Where # ## Use data larger than RAM# # @@ -19,8 +20,10 @@ c = esdc(res="low") # ## Subsets happen lazily -europe = subsetcube(c, region="Europe", time=2000:2016, - Variable=["air_temperature_2m", "net_ecosystem", "soil_moisture"]) - plot(europe.time.values,europe[Variable="air_temperature_2m", lat=50, lon=11].data) +europe = c[region="Europe", time=2000:2016, + Variable=Where( x-> any(contains.((x,),["air_temperature_2m", "net_ecosystem", "moisture"])))] + + +plot(lookup(europe, Ti).data,europe[Variable=At("air_temperature_2m"), lat=50, lon=11].data) From 27d91e3d4d541efa1861ad5949a48d95620caf47 Mon Sep 17 00:00:00 2001 From: Felix Cremer Date: Wed, 6 Sep 2023 15:36:32 +0200 Subject: [PATCH 09/10] Remove subsetcube function This function is not used anymore, because the indexing is now handled in DimensionalData. --- src/Cubes/Cubes.jl | 47 +------------------------------------- src/DatasetAPI/Datasets.jl | 3 +-- test/Cubes/cubes.jl | 25 +------------------- 3 files changed, 3 insertions(+), 72 deletions(-) diff --git a/src/Cubes/Cubes.jl b/src/Cubes/Cubes.jl index 2001c24e4..f29c10ff6 100644 --- a/src/Cubes/Cubes.jl +++ b/src/Cubes/Cubes.jl @@ -19,10 +19,6 @@ import DimensionalData: name export concatenatecubes, caxes, subsetcube, readcubedata, renameaxis!, YAXArray, setchunks, cache -""" -This function calculates a subset of a cube's data -""" -function subsetcube end "Returns the axes of a Cube" function caxes end @@ -353,53 +349,12 @@ _iscompressed(c::DiskArrays.PermutedDiskArray) = _iscompressed(c.a.parent) _iscompressed(c::DiskArrays.SubDiskArray) = _iscompressed(c.v.parent) _iscompressed(c) = YAXArrayBase.iscompressed(c) -# lift renameaxis functionality from Axes.jl to YAXArrays +# lift renameaxis functionality from DimensionalData to YAXArrays renameaxis!(c::YAXArray, p::Pair) = DD.set(c, Symbol(first(p)) => last(p)) -function _subsetcube end - -function subsetcube(z::YAXArray{T}; kwargs...) where {T} - newaxes, substuple = _subsetcube(z, collect(Any, map(Base.OneTo, size(z))); kwargs...) - newdata = view(getdata(z), substuple...) - YAXArray(newaxes, newdata, z.properties, cleaner=z.cleaner) -end - sorted(x, y) = x < y ? (x, y) : (y, x) -function _subsetcube(z, subs; kwargs...) - kwargs = Dict{Any,Any}(kwargs) - for f in YAXDefaults.subsetextensions - f(kwargs) - end - newaxes = deepcopy(collect(DD.Dimension, caxes(z))) - foreach(kwargs) do kw - axdes, subexpr = kw - axdes = string(axdes) - iax = findAxis(axdes, caxes(z)) - if isa(iax, Nothing) - throw(ArgumentError("Axis $axdes not found in cube")) - else - oldax = newaxes[iax] - subinds = interpretsubset(subexpr, oldax) - subs2 = subs[iax][subinds] - subs[iax] = subs2 - if !isa(subinds, AbstractVector) && !isa(subinds, AbstractRange) - newaxes[iax] = axcopy(oldax, oldax.values[subinds:subinds]) - else - newaxes[iax] = axcopy(oldax, oldax.values[subinds]) - end - end - end - substuple = ntuple(i -> subs[i], length(subs)) - inewaxes = findall(i -> isa(i, AbstractVector), substuple) - newaxes = newaxes[inewaxes] - @assert length.(newaxes) == - map(length, filter(i -> isa(i, AbstractVector), collect(substuple))) - newaxes, substuple -end - - function Base.getindex(a::YAXArray, args::DD.Dimension...; kwargs...) kwargsdict = Dict{Any,Any}(kwargs...) for ext in YAXDefaults.subsetextensions diff --git a/src/DatasetAPI/Datasets.jl b/src/DatasetAPI/Datasets.jl index c296c5dcf..9fb7bd4ae 100644 --- a/src/DatasetAPI/Datasets.jl +++ b/src/DatasetAPI/Datasets.jl @@ -1,5 +1,5 @@ module Datasets -import ..Cubes: Cubes, YAXArray, concatenatecubes, CleanMe, subsetcube, copy_diskarray, setchunks, caxes +import ..Cubes: Cubes, YAXArray, concatenatecubes, CleanMe, copy_diskarray, setchunks, caxes using ...YAXArrays: YAXArrays, YAXDefaults, findAxis using DataStructures: OrderedDict, counter using Dates: Day, Hour, Minute, Second, Month, Year, Date, DateTime, TimeType, AbstractDateTime, Period @@ -478,7 +478,6 @@ function open_dataset(g; skip_keys=(), driver = :all) Dataset(allcubes, sdimlist,gatts) end end -#Base.getindex(x::Dataset; kwargs...) = subsetcube(x; kwargs...) YAXDataset(; kwargs...) = Dataset(YAXArrays.YAXDefaults.cubedir[]; kwargs...) diff --git a/test/Cubes/cubes.jl b/test/Cubes/cubes.jl index 7b436cdc7..43747d8b8 100644 --- a/test/Cubes/cubes.jl +++ b/test/Cubes/cubes.jl @@ -95,6 +95,7 @@ using DimensionalData @test YAXArrayBase.iscompressed(a) == false end + @testset "cubesize" begin @test Cubes.cubesize(a) == 160 a32 = map(Float32, a) @@ -104,28 +105,4 @@ using DimensionalData @test endswith(Cubes.formatbytes(1205), "KB") @test endswith(Cubes.formatbytes(1200000), "MB") end -#= - @testset "Subsets" begin - s = YAXArrays.Cubes.subsetcube(a, X = 1.5..3.5) - @test s.data == [2 6 10 14 18; 3 7 11 15 19] - @test s.axes[1] == X(2.0:3.0) - @test s.axes[2] == Y([1, 2, 3, 4, 5]) - ax = a.axes[1] - @test YAXArrays.Cubes.interpretsubset(CartesianIndices((1:2,)), ax) == 1:2 - @test YAXArrays.Cubes.interpretsubset(CartesianIndex((2,)), ax) == 2 - @test YAXArrays.Cubes.interpretsubset(2.1, ax) == 2 - @test YAXArrays.Cubes.interpretsubset((3.5, 1.5), ax) == 2:3 - @test YAXArrays.Cubes.interpretsubset(0.8..2.2, ax) == 1:2 - tax = RangeAxis("ADate", Date(2001):Day(1):Date(2003, 2, 28)) - @test YAXArrays.Cubes.interpretsubset((Date(2001, 1, 2), Date(2001, 1, 5)), tax) == - 2:4 - @test YAXArrays.Cubes.interpretsubset(2001:2002, tax) == 1:730 - @test YAXArrays.Cubes.interpretsubset([1, 3, 5], a.axes[2]) == [1, 3, 5] - - s2 = a[X = 0.5..3.5, Y = [1, 5, 4]] - @test s2.data == [1 17 13; 2 18 14; 3 19 15] - @test s2.axes[1] == X(1.0:3.0) - @test s2.axes[2] == Y([1, 5, 4]) - end -=# end From 2fee3253d835e8c7e9fc77a78a0e44d898bfcfa0 Mon Sep 17 00:00:00 2001 From: Felix Cremer Date: Wed, 22 Oct 2025 12:38:46 +0200 Subject: [PATCH 10/10] Fix imports in Datasets.jl --- src/DatasetAPI/Datasets.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DatasetAPI/Datasets.jl b/src/DatasetAPI/Datasets.jl index 9fb7bd4ae..8caa13cef 100644 --- a/src/DatasetAPI/Datasets.jl +++ b/src/DatasetAPI/Datasets.jl @@ -1,5 +1,5 @@ module Datasets -import ..Cubes: Cubes, YAXArray, concatenatecubes, CleanMe, copy_diskarray, setchunks, caxes +import ..Cubes: Cubes, YAXArray, concatenatecubes, CleanMe, copy_diskarray, setchunks, caxes, readcubedata, cubesize, formatbytes using ...YAXArrays: YAXArrays, YAXDefaults, findAxis using DataStructures: OrderedDict, counter using Dates: Day, Hour, Minute, Second, Month, Year, Date, DateTime, TimeType, AbstractDateTime, Period