YAXArrays.jl
YAXArrays.jl copied to clipboard
Allow Dataset indexing using Sets
trafficstars
Currently, indexing by Sets isn't supported:
using EarthDataLab
ds = esdd()
a = [:cot, :ctt]
ds[a] # Works fine
s = Set(a)
ds[s] #No method matching getindex(DataSet, Set)
# Workaround
ds[collect(s)] # Turns s into an array
This may make issues like #321 simpler by using setdiff; example:
using EarthDataLab
ds = esdd()
bad_vars = [:cot, :ctt] # Variables we don't want
ds[setdiff(keys(ds.cubes), bad_vars)]
Also noticed that dataset indexing does not accept duplicates:
a = [:cot, :cot]
ds[a] # Gives a Dataset with only one variable
Meaning that the getindex(Dataset, Set) implementation could be "simpler" than just an override with collect.
Sets are not ordered, so indexing with them will be in a random order. Usually we dont want that.