Skip to content

Promote types of transforms #186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions .github/workflows/downstream.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: IntegrationTest
on:
push:
branches: [master]
tags: [v*]
paths-ignore:
- 'LICENSE'
- 'README.md'
- '.github/workflows/TagBot.yml'
pull_request:
paths-ignore:
- 'LICENSE'
- 'README.md'
- '.github/workflows/TagBot.yml'

concurrency:
group: build-${{ github.event.pull_request.number || github.ref }}-${{ github.workflow }}
cancel-in-progress: true

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: ClassicalOrthogonalPolynomials.jl, group: JuliaApproximation}
- {repo: HarmonicOrthogonalPolynomials.jl, group: JuliaApproximation}
- {repo: MultivariateOrthogonalPolynomials.jl, group: JuliaApproximation}
- {repo: PiecewiseOrthogonalPolynomials.jl, group: JuliaApproximation}
- {repo: SemiclassicalOrthogonalPolynomials.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@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: lcov.info
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "ContinuumArrays"
uuid = "7ae1f121-cc2c-504b-ac30-9b923412ae5c"
version = "0.18.2"
version = "0.18.3"

[deps]
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"
Expand Down
1 change: 1 addition & 0 deletions src/ContinuumArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ include("maps.jl")

const QInfAxes = Union{Inclusion,AbstractAffineQuasiVector}

# TODO: the following break some tests in QuasiArrays.jl when loaded, when `QInfAxes` are finite dimensional

sub_materialize(_, V::AbstractQuasiArray, ::Tuple{QInfAxes}) = V
sub_materialize(_, V::AbstractQuasiArray, ::Tuple{QInfAxes,QInfAxes}) = V
Expand Down
8 changes: 6 additions & 2 deletions src/bases/bases.jl
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,12 @@
MappedFactorization(factorize(view(P,:,jr), dims...; kws...), invmap(parentindices(L)[1]))
end

plan_ldiv(A, B::AbstractQuasiVector) = factorize(A)
plan_ldiv(A, B::AbstractQuasiMatrix) = factorize(A, size(B,2))

_any_eltype(B::AbstractQuasiArray{Any}) = typeof(first(B)) # assume types are same
_any_eltype(B) = eltype(B)

Check warning on line 277 in src/bases/bases.jl

View check run for this annotation

Codecov / codecov/patch

src/bases/bases.jl#L276-L277

Added lines #L276 - L277 were not covered by tests

plan_ldiv(A, B::AbstractQuasiVector) = factorize(convert(AbstractQuasiMatrix{promote_type(eltype(A), _any_eltype(B))}, A))
plan_ldiv(A, B::AbstractQuasiMatrix) = factorize(convert(AbstractQuasiMatrix{promote_type(eltype(A), _any_eltype(B))}, A), size(B,2))

Check warning on line 280 in src/bases/bases.jl

View check run for this annotation

Codecov / codecov/patch

src/bases/bases.jl#L279-L280

Added lines #L279 - L280 were not covered by tests

transform_ldiv_size(_, A::AbstractQuasiArray{T}, B::AbstractQuasiArray{V}) where {T,V} = plan_ldiv(A, B) \ B
transform_ldiv(A, B) = transform_ldiv_size(size(A), A, B)
Expand Down
2 changes: 1 addition & 1 deletion src/bases/basisconcat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,4 @@
end


diff(H::ApplyQuasiMatrix{<:Any,typeof(hcat)}; dims::Integer) = hcat((diff.(H.args; dims=dims))...)
diff(H::ApplyQuasiMatrix{<:Any,typeof(hcat)}; dims::Integer=1) = hcat((diff.(H.args; dims=dims))...)

Check warning on line 115 in src/bases/basisconcat.jl

View check run for this annotation

Codecov / codecov/patch

src/bases/basisconcat.jl#L115

Added line #L115 was not covered by tests
5 changes: 5 additions & 0 deletions src/bases/splines.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
Spline{o}(pts::AbstractVector{T}) where {o,T} = Spline{o,float(T)}(pts)
Spline{o}(S::Spline) where {o} = Spline{o}(S.points)

convert(::Type{AbstractQuasiArray{T}}, S::Spline{λ,T}) where {λ,T} = S
convert(::Type{AbstractQuasiMatrix{T}}, S::Spline{λ,T}) where {λ,T} = S
convert(::Type{AbstractQuasiArray{T}}, S::Spline{λ}) where {λ,T} = Spline{λ,T}(S.points)
convert(::Type{AbstractQuasiMatrix{T}}, S::Spline{λ}) where {λ,T} = convert(AbstractQuasiArray{T}, S)

Check warning on line 15 in src/bases/splines.jl

View check run for this annotation

Codecov / codecov/patch

src/bases/splines.jl#L12-L15

Added lines #L12 - L15 were not covered by tests

for Typ in (:LinearSpline, :HeavisideSpline)
STyp = string(Typ)
@eval function show(io::IO, L::$Typ)
Expand Down
19 changes: 19 additions & 0 deletions test/test_splines.jl
Original file line number Diff line number Diff line change
Expand Up @@ -609,4 +609,23 @@ import ContinuumArrays: basis, AdjointBasisLayout, ExpansionLayout, BasisLayout,
@test sum(u) == 10
@test cumsum(u)[5-4eps()] == 10
end

@testset "complex" begin
L = LinearSpline([1,2,3])
x = axes(L,1)
@test L \ exp.(im*x) == LinearSpline{ComplexF64}([1,2,3]) \ exp.(im*x) == transform(L, x -> exp(im*x))
@test expand(L, x -> exp(im*x))[2.0] ≈ exp(im*2.0)
end

@testset "convert" begin
L = LinearSpline([1,2,3])
@test L ≡ convert(AbstractQuasiArray{Float64}, L) ≡ convert(AbstractQuasiMatrix{Float64}, L)
@test convert(AbstractQuasiArray{ComplexF64}, L) == convert(AbstractQuasiMatrix{ComplexF64}, L) == LinearSpline{ComplexF64}([1,2,3])
end

@testset "any eltype" begin
L = LinearSpline([-1,0,1])
f = x -> abs(x) ≤ 1 ? 1 : "hi"
@test expand(L,f)[0.1] ≈ 1
end
end
Loading