From a53825defc684ecc3d83afd98db8c062ad14dfa5 Mon Sep 17 00:00:00 2001 From: Joaquim Date: Wed, 23 Apr 2025 12:42:03 +0100 Subject: [PATCH 1/2] Fix regression in code dealing with vegetation indices calculations. --- .github/workflows/ci.yml | 14 +++++++------- src/spectral_indices.jl | 18 ++++++++++++------ 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 33cbec1..607da29 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,15 +53,15 @@ jobs: access_token: ${{ github.token }} - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 if: matrix.run_in_pr == true || github.event_name != 'pull_request' - - uses: actions/checkout@v2 - - uses: julia-actions/setup-julia@v1 + - uses: actions/checkout@v4 + - uses: julia-actions/setup-julia@v2 with: version: ${{ matrix.version }} arch: ${{ matrix.arch }} - - uses: actions/cache@v1 + - uses: actions/cache@v2 env: cache-name: cache-artifacts with: @@ -74,7 +74,7 @@ jobs: - uses: julia-actions/julia-buildpkg@v1 - uses: julia-actions/julia-runtest@v1 - uses: julia-actions/julia-processcoverage@v1 - - uses: codecov/codecov-action@v1 + - uses: codecov/codecov-action@v5 with: file: lcov.info @@ -83,8 +83,8 @@ jobs: runs-on: ubuntu-latest #runs-on: ubuntu-18.04 steps: - - uses: actions/checkout@v2 - - uses: julia-actions/setup-julia@v1 + - uses: actions/checkout@v4 + - uses: julia-actions/setup-julia@v2 with: version: '1' - run: | diff --git a/src/spectral_indices.jl b/src/spectral_indices.jl index 6206cb5..8bcba3e 100644 --- a/src/spectral_indices.jl +++ b/src/spectral_indices.jl @@ -535,10 +535,15 @@ function sp_indices(cube::Union{GMT.GMTimage{UInt16, 3}, AbstractArray{<:Abstrac o = sp_indices(@view(cube[:,:,bands[1]]), @view(cube[:,:,bands[2]]), @view(cube[:,:,bands[3]]); index=index, kw...) end if (mask || classes !== nothing) - O = mat2img(o, cube) - O.layout, O.range[5], O.range[6] = "BRPa", 0, (mask) ? 255 : length(classes) + if (isa(o, Matrix{<:Integer})) + # Don't know if this case still happens. It was for old code. Now, for masks, 'o' is already a GMTimage + O = mat2img(o, cube) + O.layout, O.range[5], O.range[6] = "BRPa", 0, (mask) ? 255 : length(classes) + else + O = o + end else - O = mat2grid(o, cube) + O = isa(o, GMT.GMTgrid) ? o : mat2grid(o, cube) end O.names = [index * " index"] (save_name != "") && gmtwrite(save_name, O) @@ -781,13 +786,14 @@ function sp_indices(bnd1, bnd2, bnd3=nothing; index::String="", kwargs...) end end - if (isa(bnd1, GMT.GMTimage) || isa(bnd1, GMT.GMTgrid)) + if (isa(bnd1, GMT.GMTimage) || isa(bnd1, GMT.GMTgrid) || isa(parent(bnd1), GMTimage)) # Last one is when slice is a SubArray{... if (ismask || classes !== nothing) - I = mat2img(mask, proj4=bnd1.proj4, wkt=bnd1.wkt, x=bnd1.x, y=bnd1.y, epsg=bnd1.epsg, layout="BRPa") + I = mat2img(mask, isa(bnd1, GMT.GMTimage) ? bnd1 : parent(bnd1)) + I.layout="BRPa" I.range[5], I.range[6] = 0, (ismask) ? 255 : length(classes) return I else - return mat2grid(img, bnd1) + return mat2grid(img, isa(bnd1, GMT.GItype) ? bnd1 : parent(bnd1)) end else return img From bcf5d1538fafc11ea0b158fe8a41759efebf557f Mon Sep 17 00:00:00 2001 From: Joaquim Date: Wed, 23 Apr 2025 12:48:43 +0100 Subject: [PATCH 2/2] Update cache action version. --- .github/workflows/ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 607da29..0429143 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,7 +26,8 @@ jobs: version: - '1' # Replace this with the minimum Julia version that your package supports. E.g. if your package requires Julia 1.5 or higher, change this to '1.5'. #- '1' # Leave this line unchanged. '1' will automatically expand to the latest stable 1.x release of Julia. - #- 'nightly' + - '~1.10.0-0' + - 'nightly' os: - ubuntu-latest #- ubuntu-20.04 @@ -61,7 +62,7 @@ jobs: with: version: ${{ matrix.version }} arch: ${{ matrix.arch }} - - uses: actions/cache@v2 + - uses: actions/cache@v4 env: cache-name: cache-artifacts with: