From 9102f930ba91914f51ea91f9aa88cc6eec0909c9 Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Tue, 26 Nov 2024 11:27:45 +0000 Subject: [PATCH] Support 2D quasimatrix sum --- .github/downstream.yml | 69 ++++++++++++++++++++++++++++++++++++++++++ Project.toml | 2 +- src/QuasiArrays.jl | 2 +- src/calculus.jl | 7 ++++- test/test_calculus.jl | 1 + 5 files changed, 78 insertions(+), 3 deletions(-) create mode 100644 .github/downstream.yml diff --git a/.github/downstream.yml b/.github/downstream.yml new file mode 100644 index 0000000..65bc343 --- /dev/null +++ b/.github/downstream.yml @@ -0,0 +1,69 @@ +name: IntegrationTest +on: + push: + branches: [master] + tags: [v*] + pull_request: + paths-ignore: + - 'LICENSE' + - 'README.md' + - '.github/workflows/TagBot.yml' + +jobs: + pre_job: + # continue-on-error: true # Uncomment once integration is finished + runs-on: ubuntu-latest + # Map a step output to a job output + outputs: + should_skip: ${{ steps.skip_check.outputs.should_skip }} + steps: + - id: skip_check + uses: fkirc/skip-duplicate-actions@v5 + test: + needs: pre_job + if: needs.pre_job.outputs.should_skip != 'true' + name: ${{ matrix.package.group }}/${{ matrix.package.repo }}/${{ matrix.julia-version }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + julia-version: ['1'] + os: [ubuntu-latest] + package: + - {repo: ContinuumArrays.jl, group: JuliaApproximation} + - {repo: ClassicalOrthogonalPolynomials.jl, group: JuliaApproximation} + + steps: + - uses: actions/checkout@v4 + - uses: julia-actions/setup-julia@v2 + with: + version: ${{ matrix.julia-version }} + arch: x64 + - uses: julia-actions/julia-buildpkg@latest + - name: Clone Downstream + uses: actions/checkout@v4 + with: + repository: ${{ matrix.package.group }}/${{ matrix.package.repo }} + path: downstream + - name: Load this and run the downstream tests + shell: julia --color=yes --project=downstream {0} + run: | + using Pkg + try + # force it to use this PR's version of the package + Pkg.develop(PackageSpec(path=".")) # resolver may fail with main deps + Pkg.update() + Pkg.test(; coverage = true) # resolver may fail with test time deps + catch err + err isa Pkg.Resolve.ResolverError || rethrow() + # If we can't resolve that means this is incompatible by SemVer and this is fine + # It means we marked this as a breaking change, so we don't need to worry about + # Mistakenly introducing a breaking change, as we have intentionally made one + @info "Not compatible with this release. No problem." exception=err + exit(0) # Exit immediately, as a success + end + - uses: julia-actions/julia-processcoverage@v1 + - uses: codecov/codecov-action@v5 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: lcov.info diff --git a/Project.toml b/Project.toml index 693a147..967d684 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "QuasiArrays" uuid = "c4ea9172-b204-11e9-377d-29865faadc5c" authors = ["Sheehan Olver "] -version = "0.11.8" +version = "0.11.9" [deps] ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a" diff --git a/src/QuasiArrays.jl b/src/QuasiArrays.jl index ca8ef25..4eacf6a 100644 --- a/src/QuasiArrays.jl +++ b/src/QuasiArrays.jl @@ -6,7 +6,7 @@ import Base: getindex, size, axes, axes1, length, ==, isequal, iterate, Cartesia isreal, iszero, isempty, empty, isapprox, fill!, getproperty, showarg import Base: @_inline_meta, DimOrInd, OneTo, @_propagate_inbounds_meta, @_noinline_meta, DimsInteger, error_if_canonical_getindex, @propagate_inbounds, _return_type, - safe_tail, tail, _getindex, _maybe_reshape, index_ndims, _unsafe_getindex, + safe_tail, front, tail, _getindex, _maybe_reshape, index_ndims, _unsafe_getindex, index_shape, to_shape, @nloops, @ncall, unalias, _unaliascopy, to_index, to_indices, _to_subscript_indices, _splatmap, dataids, compute_stride1, compute_offset1, fill_to_length diff --git a/src/calculus.jl b/src/calculus.jl index b80d69d..26d0e37 100644 --- a/src/calculus.jl +++ b/src/calculus.jl @@ -33,7 +33,12 @@ end function sum_layout(LAY::ApplyLayout{typeof(*)}, V::AbstractQuasiVector, ::Colon) a = arguments(LAY, V) - first(apply(*, sum(a[1]; dims=1), tail(a)...)) + only(*(sum(a[1]; dims=1), tail(a)...)) +end + +function sum_layout(LAY::ApplyLayout{typeof(*)}, V::AbstractQuasiMatrix, ::Colon) + a = arguments(LAY, V) + only(*(sum(a[1]; dims=1), front(tail(a))..., sum(a[end]; dims=2))) end sum_layout(::MemoryLayout, A, dims) = sum_size(size(A), A, dims) diff --git a/test/test_calculus.jl b/test/test_calculus.jl index 7693719..c7c70a4 100644 --- a/test/test_calculus.jl +++ b/test/test_calculus.jl @@ -17,6 +17,7 @@ using QuasiArrays, IntervalSets, Test @test sum(ApplyQuasiArray(*, A, B)) ≈ sum(A*B) @test sum(ApplyQuasiArray(*, A, B); dims=1) ≈ sum(A*B; dims=1) @test sum(ApplyQuasiArray(*, A, B); dims=2) ≈ sum(A*B; dims=2) + @test sum(ApplyQuasiArray(*, A, B)) ≈ sum(A*B) @test sum(b) ≈ last(cumsum(b)) ≈ cumsum(b)[2] @test cumsum(B)[2:2,:] ≈ cumsum(B; dims=1)[2:2,:] ≈ sum(B; dims=1)