Skip to content

Commit f49e91b

Browse files
authored
Add quality assurance tests, fix ambiguity (#135)
1 parent a87d647 commit f49e91b

File tree

6 files changed

+27
-16
lines changed

6 files changed

+27
-16
lines changed

Project.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "LinearMaps"
22
uuid = "7a12625a-238d-50fd-b39a-03d52299707e"
3-
version = "3.2.0"
3+
version = "3.2.1"
44

55
[deps]
66
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
@@ -10,6 +10,7 @@ SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
1010
julia = "1"
1111

1212
[extras]
13+
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
1314
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
1415
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
1516
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
@@ -18,4 +19,4 @@ SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
1819
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
1920

2021
[targets]
21-
test = ["LinearAlgebra", "SparseArrays", "Test", "BenchmarkTools", "InteractiveUtils", "Quaternions"]
22+
test = ["Aqua", "BenchmarkTools", "InteractiveUtils", "LinearAlgebra", "Quaternions", "SparseArrays", "Test"]

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ The only requirement for a `LinearMap` is that it can act on a vector (by multip
77

88
| **Documentation** | **Build Status** |
99
|:-------------------------------------------------------------------------------:|:-----------------------------------------------------------------------------------------------:|
10-
| [![stable docs][docs-stable-img]][docs-stable-url] [![dev docs][docs-dev-img]][docs-dev-url] | [![build status][build-img]][build-url] [![coverage][codecov-img]][codecov-url] [![license][license-img]][license-url] |
10+
| [![stable docs][docs-stable-img]][docs-stable-url] [![dev docs][docs-dev-img]][docs-dev-url] | [![build status][build-img]][build-url] [![coverage][codecov-img]][codecov-url] [![Aqua QA][aqua-img]][aqua-url] [![license][license-img]][license-url] |
1111

1212
## Installation
1313

@@ -38,3 +38,6 @@ julia> import Pkg; Pkg.add("LinearMaps")
3838

3939
[license-img]: http://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat
4040
[license-url]: LICENSE.md
41+
42+
[aqua-img]: https://img.shields.io/badge/Aqua.jl-%F0%9F%8C%A2-aqua.svg
43+
[aqua-url]: https://github.com/JuliaTesting/Aqua.jl

src/LinearMaps.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,6 @@ include("show.jl") # show methods for LinearMap objects
260260
LinearMap(A::LinearMap; kwargs...)::WrappedMap
261261
LinearMap(A::AbstractMatrix; kwargs...)::WrappedMap
262262
LinearMap(J::UniformScaling, M::Int)::UniformScalingMap
263-
LinearMap(λ::Number, M::Int, N::Int) = FillMap(λ, (M, N))::FillMap
264-
LinearMap(λ::Number, dims::Dims{2}) = FillMap(λ, dims)::FillMap
265263
LinearMap{T=Float64}(f, [fc,], M::Int, N::Int = M; kwargs...)::FunctionMap
266264
267265
Construct a linear map object, either from an existing `LinearMap` or `AbstractMatrix` `A`,

src/composition.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ function Base.:(*)(A₁::CompositeMap, A₂::CompositeMap)
116116
T = promote_type(eltype(A₁), eltype(A₂))
117117
return CompositeMap{T}(tuple(A₂.maps..., A₁.maps...))
118118
end
119+
# needed for disambiguation
120+
Base.:(*)(A₁::ScaledMap, A₂::CompositeMap) = A₁.λ * (A₁.lmap * A₂)
121+
Base.:(*)(A₁::CompositeMap, A₂::ScaledMap) = (A₁ * A₂.lmap) * A₂.λ
119122

120123
# special transposition behavior
121124
LinearAlgebra.transpose(A::CompositeMap{T}) where {T} =

test/composition.jl

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ using Test, LinearMaps, LinearAlgebra, SparseArrays
1414
M = @inferred 1 * LinearMap(A)
1515
N = @inferred LinearMap(B)
1616
v = rand(ComplexF64, 10)
17+
α = rand(ComplexF64)
1718
@test FCM * v == F * v
1819
@test @inferred (F * F) * v == @inferred F * (F * v)
1920
@test @inferred (F * A) * v == @inferred F * (A * v)
@@ -52,17 +53,20 @@ using Test, LinearMaps, LinearAlgebra, SparseArrays
5253
R1 = rand(ComplexF64, 10, 10); L1 = LinearMap(R1)
5354
R2 = rand(ComplexF64, 10, 10); L2 = LinearMap(R2)
5455
R3 = rand(ComplexF64, 10, 10); L3 = LinearMap(R3)
55-
CompositeR = prod(LinearMap, [R1, R2, R3])
56-
@test @inferred L1 * L2 * L3 == CompositeR
56+
CompositeR = *(R1, R2, R3)
57+
CompositeL = prod(LinearMap, [R1, R2, R3])
58+
@test @inferred L1 * L2 * L3 == CompositeL
5759
@test Matrix(L1 * L2) sparse(L1 * L2) R1 * R2
58-
@test @inferred transpose(CompositeR) == transpose(L3) * transpose(L2) * transpose(L1)
59-
@test @inferred adjoint(CompositeR) == L3' * L2' * L1'
60-
@test @inferred adjoint(adjoint((CompositeR))) == CompositeR
61-
@test transpose(transpose((CompositeR))) == CompositeR
62-
Lt = @inferred transpose(LinearMap(CompositeR))
63-
@test Lt * v transpose(R3) * transpose(R2) * transpose(R1) * v
64-
Lc = @inferred adjoint(LinearMap(CompositeR))
65-
@test Lc * v R3' * R2' * R1' * v
60+
@test Matrix(@inferred((α * L1) * (L2 * L3))::LinearMaps.ScaledMap) α * CompositeR
61+
@test Matrix(@inferred((L1 * L2) * (L3 * α))::LinearMaps.ScaledMap) α * CompositeR
62+
@test @inferred transpose(CompositeL) == transpose(L3) * transpose(L2) * transpose(L1)
63+
@test @inferred adjoint(CompositeL) == L3' * L2' * L1'
64+
@test @inferred adjoint(adjoint((CompositeL))) == CompositeL
65+
@test transpose(transpose((CompositeL))) == CompositeL
66+
Lt = @inferred transpose(LinearMap(CompositeL))
67+
@test Lt * v transpose(CompositeR) * v
68+
Lc = @inferred adjoint(LinearMap(CompositeL))
69+
@test Lc * v adjoint(CompositeR) * v
6670

6771
# convert to AbstractMatrix
6872
for A in (LinearMap(sprandn(10, 10, 0.3)), LinearMap(rand()*I, 10))

test/runtests.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
using Test, LinearMaps
1+
using Test, LinearMaps, Aqua
22
import LinearMaps: FiveArg, ThreeArg
33

44
const matrixstyle = VERSION v"1.3.0-alpha.115" ? FiveArg() : ThreeArg()
55

66
const testallocs = VERSION v"1.4-"
77

8+
Aqua.test_all(LinearMaps)
9+
810
include("linearmaps.jl")
911

1012
include("transpose.jl")

0 commit comments

Comments
 (0)