From 4d1d62283175e6268d9ecaa3a2c6021e11b508f9 Mon Sep 17 00:00:00 2001 From: Max Freudenberg Date: Sun, 22 Oct 2023 09:33:08 +0200 Subject: [PATCH] use dims keyword --- src/methods/crop_extend.jl | 7 ++----- test/sources/gdal.jl | 6 +++--- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/methods/crop_extend.jl b/src/methods/crop_extend.jl index e19e4220b..94f977651 100644 --- a/src/methods/crop_extend.jl +++ b/src/methods/crop_extend.jl @@ -92,10 +92,7 @@ function _crop_to(x, to; kw...) return _crop_to(x, ext; kw...) end end -function _crop_to(A, to::RasterStackOrArray; kw...) - target_dims = get(kw, :dims, name.(dims(to))) - return _crop_to(A, dims(to, target_dims); kw...) -end +_crop_to(A, to::RasterStackOrArray; dims=DD.dims(to), kw...) = _crop_to(A, DD.dims(to, dims); kw...) function _crop_to(x, to::DimTuple; kw...) # We can only crop to sampled dims (e.g. not categorical dims like Band) sampled = reduce(to; init=()) do acc, d @@ -103,7 +100,7 @@ function _crop_to(x, to::DimTuple; kw...) end return _crop_to(x, Extents.extent(to); kw...) end -function _crop_to(x, to::Extents.Extent; touches=false, kw...) +function _crop_to(x, to::Extents.Extent; touches=false) ds = dims(x, map(key2dim, keys(to))) # Take a view over the bounds _without_mapped_crs(x) do x1 diff --git a/test/sources/gdal.jl b/test/sources/gdal.jl index 7c52efbf8..635e4d4b6 100644 --- a/test/sources/gdal.jl +++ b/test/sources/gdal.jl @@ -109,13 +109,13 @@ gdalpath = maybedownload(url) @testset "other fields" begin # This file has an inorrect missing value - @test missingval(gdalarray) == nothing + @test missingval(gdalarray) === nothing @test metadata(gdalarray) isa Metadata{GDALsource,Dict{String,Any}} @test basename(metadata(gdalarray)["filepath"]) == "cea.tif" metadata(gdalarray)["filepath"] @test name(gdalarray) == :test @test label(gdalarray) == "test" - @test units(gdalarray) == nothing + @test units(gdalarray) === nothing @test crs(dims(gdalarray, Y)) isa WellKnownText @test crs(dims(gdalarray, X)) isa WellKnownText @test crs(gdalarray) isa WellKnownText @@ -256,7 +256,7 @@ gdalpath = maybedownload(url) @test dims(geoA) isa Tuple{<:X,Y} @test refdims(geoA) isa Tuple{<:Band} @test metadata(geoA) == metadata(gdalarray) - @test missingval(geoA) == nothing + @test missingval(geoA) === nothing @test name(geoA) == :test end