Skip to content

Commit

Permalink
Use package extensions, not Requires, to v12 (#63)
Browse files Browse the repository at this point in the history
* Use package extensions, not Requires

* Fix url
  • Loading branch information
JeffFessler authored May 17, 2024
1 parent 68dab1e commit a88f7ac
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 31 deletions.
13 changes: 9 additions & 4 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
name = "LinearMapsAA"
uuid = "599c1a8e-b958-11e9-0d14-b1e6b2ecea07"
authors = ["fessler <[email protected]>"]
version = "0.11.0"
version = "0.12"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
LinearMaps = "7a12625a-238d-50fd-b39a-03d52299707e"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[compat]
LinearMaps = "3.7"
Requires = "1.2"
julia = "1.9"
LinearOperators = "2.8"
julia = "1.10"

[weakdeps]
LinearOperators = "5c8ed15e-5a4c-59e4-a42b-c7e8811fb125"

[extensions]
LinearMapsAA_LinearOperators = "LinearOperators"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ Submit an issue or make a PR if there are other operator types
that one would like to have supported.
To minimize package dependencies,
the wrapping code for a `LinearOperator` uses
[Requires.jl](https://github.com/JuliaPackaging/Requires.jl).
[package extensions](https://docs.julialang.org/en/v1/manual/code-loading/#man-extensions).


## Multiplication properties
Expand Down
18 changes: 11 additions & 7 deletions src/wrap-linop.jl → ext/LinearMapsAA_LinearOperators.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# wrap-linop.jl
# LinearMapsAA_LinearOperators.jl
# Wrap a LinearMapAA around a LinearOperator or vice-versa

using .LinearOperators: LinearOperator
import .LinearOperators: LinearOperator
module LinearMapsAA_LinearOperators

export LinearMapAA
export LinearOperator
# extended here
import LinearMapsAA: LinearMapAA, LinearOperator_from_AA

using LinearMapsAA: LinearMapAX, mul!
using LinearOperators: LinearOperator


"""
Expand All @@ -22,12 +24,12 @@ end


"""
L = LinearOperator(A::LinearMapAX; symmetric, hermitian)
L = LinearOperator_from_AA(A::LinearMapAX; symmetric, Hermitian)
Wrap a `LinearOperator` around a `LinearMapAX`.
The options `symmetric` and `hermitian` are `false` by default.
"""
function LinearOperator(
function LinearOperator_from_AA(
A::LinearMapAX;
symmetric::Bool = false,
hermitian::Bool = false,
Expand All @@ -43,3 +45,5 @@ function LinearOperator(
back!,
)
end

end # module
8 changes: 1 addition & 7 deletions src/LinearMapsAA.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ or "Ann Arbor" version of `LinearMap` objects
"""
module LinearMapsAA

using Requires: @require

export LinearMapAA, LinearMapAM, LinearMapAO, LinearMapAX

Indexer = AbstractVector{Int}
Expand All @@ -22,10 +20,6 @@ include("getindex.jl")
include("block_diag.jl")
include("lm-aa.jl")
include("identity.jl")

# support LinearOperators iff user has loaded that package
function __init__()
@require LinearOperators = "5c8ed15e-5a4c-59e4-a42b-c7e8811fb125" include("wrap-linop.jl")
end
include("exts.jl")

end # module
6 changes: 6 additions & 0 deletions src/exts.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# exts.jl

# methods defined in the extension(s)
export LinearOperator_from_AA

LinearOperator_from_AA() = throw("First run `using LinearOperators`")
2 changes: 1 addition & 1 deletion test/ambiguity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ using LinearAlgebra: Adjoint, Transpose, Symmetric
using LinearAlgebra: TransposeAbsVec, AdjointAbsVec
using LinearAlgebra: givens
import LinearAlgebra
using LinearMapsAA
using LinearMapsAA: LinearMapAA
using Test: @test, @testset, @test_throws


Expand Down
2 changes: 1 addition & 1 deletion test/block_diag.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# block_diag.jl
# test

using LinearMapsAA: LinearMapAA, LinearMapAM, LinearMapAO
using LinearMapsAA: LinearMapAA, LinearMapAM, LinearMapAO, block_diag
using SparseArrays: blockdiag, sparse
using Test: @test, @testset

Expand Down
2 changes: 1 addition & 1 deletion test/multiply.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#export LinearMapAA_test_vmul # testing
#export LinearMapAA_test_mul # testing
using LinearMapsAA
using LinearMapsAA: LinearMapAA, LinearMapAM, LinearMapAO, mul!
using Test: @test, @testset


Expand Down
22 changes: 19 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
# test/runtests.jl

using LinearMapsAA
using LinearMapsAA: LinearMapsAA
using Test: @test, @testset, @test_broken, detect_ambiguities

function test_ambig(str::String)
@testset "ambiguities-$str" begin
tmp = detect_ambiguities(LinearMapsAA)
# @show tmp
@test length(tmp) == 0
end
end

include("multiply.jl")

list = [
Expand All @@ -15,7 +23,6 @@ list = [
"block_diag"
"tests"
"wrap-linop"
"cuda"
]

for file in list
Expand All @@ -24,8 +31,17 @@ for file in list
end
end

test_ambig("before cuda")

#=
using CUDA causes an import of StaticArrays that leads to a method ambiguity
=#
@testset "cuda" begin
include("cuda.jl")
end

@testset "ambiguities" begin
tmp = detect_ambiguities(LinearMapsAA)
@show tmp # todo
@show tmp # todo
@test_broken length(tmp) == 0
end
2 changes: 1 addition & 1 deletion test/setindex.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# setindex.jl
# test setindex! (deprecated)

using LinearMapsAA
using LinearMapsAA: LinearMapAA, LinearMapAM
using Test: @test


Expand Down
11 changes: 6 additions & 5 deletions test/wrap-linop.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# wrap-linop.jl
# test wrapping of a LinearMapAX in a LinearOperator and vice-versa

using LinearMapsAA: LinearMapAA, LinearMapAM
using LinearMapsAA: LinearMapAA, LinearMapAM, LinearOperator_from_AA
using LinearOperators: LinearOperator
using Test: @test, @testset

Expand All @@ -10,9 +10,10 @@ back! = (x, y) -> reverse!(cumsum!(x, reverse!(copyto!(x, y))))

N = 9
T = Float32
L = LinearOperator(T, N, N, false, false, forw!,
nothing, # transpose mul!
back!,
L = LinearOperator(
T, N, N, false, false, forw!,
nothing, # transpose mul!
back!,
)

x = rand(N)
Expand All @@ -26,7 +27,7 @@ A = LinearMapAA(L) # wrap LinearOperator
@test A * x == cumsum(x)

B = LinearMapAA(forw!, back!, (N, N); T)
L = LinearOperator(B) # wrap LinearMapAM
L = LinearOperator_from_AA(B) # wrap LinearMapAM
@test L isa LinearOperator
@test Matrix(L)' == Matrix(L')
@test L * x == cumsum(x)

2 comments on commit a88f7ac

@JeffFessler
Copy link
Owner Author

Choose a reason for hiding this comment

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

@JuliaRegistrator() register

@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/107108

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.12.0 -m "<description of version>" a88f7ac0a0fc5ab5382f183d75e3727773f4e565
git push origin v0.12.0

Please sign in to comment.