diff --git a/Project.toml b/Project.toml index 62ca2136..cb10fc26 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "ClimateBase" uuid = "35604d93-0fb8-4872-9436-495b01d137e2" authors = ["Datseris ", "Philippe Roy "] -version = "0.14.2" +version = "0.14.3" [deps] Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" diff --git a/src/physical_dimensions/spatial_equalarea.jl b/src/physical_dimensions/spatial_equalarea.jl index cf3073d3..b84ff601 100644 --- a/src/physical_dimensions/spatial_equalarea.jl +++ b/src/physical_dimensions/spatial_equalarea.jl @@ -188,14 +188,15 @@ end # The code here is exclusively a performance optimization that relies # on the fact that we sort coordinates by latitude function coord_latitudes_between(c, l1, l2) + l1, l2 = min(l1, l2), max(l1, l2) idxs, lats = uniquelats(c) i1 = searchsortedfirst(lats, l1) i2 = searchsortedlast(lats, l2) - i1 > i2 && ((i1, i2) = (i2, i1)) # in case bounds are given in reverse order return idxs[i1][1]:idxs[i2][end] end # This modifies what happens on A[Coord(Lat(Between(x,y)))] +# Notice that `Between` is deprecated from DimensionalData.jl. function DimensionalData.selectindices(c::Coord, sel::Tuple{<:Lat{ <: Between}}) l1, l2 = sel[1].val.val return coord_latitudes_between(gnv(c), l1, l2) # this is Vector{Int} @@ -204,6 +205,6 @@ end # This modifies what happens on A[Coord(Lat(x..y))] function DimensionalData.selectindices(c::Coord, sel::Tuple{<:Lat{ <: DimensionalData.LookupArrays.IntervalSets.AbstractInterval}}) - l1 = sel[1].val.left; l2 = sel.val.right + l1 = sel[1].val.left; l2 = sel[1].val.right return coord_latitudes_between(gnv(c), l1, l2) # this is Vector{Int} end \ No newline at end of file diff --git a/test/space_coord_tests.jl b/test/space_coord_tests.jl index af85e5bb..43d1b880 100644 --- a/test/space_coord_tests.jl +++ b/test/space_coord_tests.jl @@ -10,6 +10,9 @@ Atran = transform_to_coord(A) @test hasdim(Atran, Coord) @test lons == sort!(unique!([c[1] for c in gnv(dims(Atran, Coord))])) + + # subsel2 = C[Coord(Lat(8..0))] # DimensionalData.jl is not allowing this to work + # @test subsel2 == subsel end @testset "Zonal mean" begin