Skip to content

Commit

Permalink
Promote types of transforms (#186)
Browse files Browse the repository at this point in the history
* promote types of transforms

* Create downstream.yml

* move downstream

* Update bases.jl

* add test
  • Loading branch information
dlfivefifty authored Jul 8, 2024
1 parent c89c0cb commit 171465a
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 4 deletions.
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 @@ function _factorize(::MappedBasisLayout, L, dims...; kws...)
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)

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))

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 @@ function QuasiArrays._getindex(::Type{IND}, A::HvcatBasis{T}, (x,j)::IND) where
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))...)
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 @@ const HeavisideSpline = Spline{0}
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)

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

2 comments on commit 171465a

@dlfivefifty
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/110698

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.18.3 -m "<description of version>" 171465aca9c1f40efce18af41b79f58dc904f3ea
git push origin v0.18.3

Please sign in to comment.