Skip to content

Commit

Permalink
fix lookup for related variables when indexing with a scalar
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander-Barth committed Dec 8, 2023
1 parent 7ca6b69 commit 3209c79
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/subvariable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ groupname(ds::SubDataset) = groupname(ds.ds)


function dataset(v::SubVariable)
indices = (;((Symbol(d),i) for (d,i) in zip(dimnames(v),v.indices))...)
indices = (;((Symbol(d),i) for (d,i) in zip(dimnames(v.parent),v.indices))...)
return SubDataset(dataset(v.parent),indices)
end

Expand Down
1 change: 0 additions & 1 deletion test/test_attrib.jl
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ defVar(ds,:temperature2,data,(:lon,:lat),
attrib = OrderedDict(:long_name => "Temperature",
:test_vector_attrib => [1,2,3]))


defVar(ds,:temperature3,data,(:lon,:lat),
attrib = Dict(:long_name => "Temperature",
:test_vector_attrib => [1,2,3]))
Expand Down
19 changes: 19 additions & 0 deletions test/test_subvariable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,22 @@ close(ds_slice)
@test TDS(fname_slice)["lon"][:] == 2:3

close(ds)



#

fname = tempname()
ds = TDS(fname,"c")

nclon = defVar(ds,"lon", 1:7, ("lon",))
nclat = defVar(ds,"lat", 1:10, ("lat",))
nctime = defVar(ds,"time", [DateTime(2000,1,1)], ("time",))
ncsst = defVar(ds,"sst", ones(7,10,1), ("lon", "lat", "time"))

ncsst3 = @select(ncsst,lon 2 && lat 3)

ss = ncsst3["time"]
@test ss[1] == DateTime(2000,1,1)

close(ds)

0 comments on commit 3209c79

Please sign in to comment.