Skip to content

Commit 731dc5e

Browse files
author
Andy Ferris
committed
Fixed and refined some RowVector/ConjArray tests
1 parent b70aa6e commit 731dc5e

File tree

5 files changed

+53
-45
lines changed

5 files changed

+53
-45
lines changed

base/exports.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ export
5050
Complex64,
5151
Complex32,
5252
ConjArray,
53+
ConjVector,
54+
ConjMatrix,
5355
DenseMatrix,
5456
DenseVecOrMat,
5557
DenseVector,

base/linalg/conjarray.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ end
1414

1515
@inline ConjArray{T,N}(a::AbstractArray{T,N}) = ConjArray{conj_type(T), N, typeof(a)}(a)
1616

17+
typealias ConjVector{T, V <: AbstractVector} ConjArray{T, 1, V}
18+
typealias ConjMatrix{T, M <: AbstractMatrix} ConjArray{T, 2, M}
19+
1720
# This type can cause the element type to change under conjugation - e.g. an array of complex arrays.
1821
@inline conj_type(x) = conj_type(typeof(x))
1922
@inline conj_type{T}(::Type{T}) = promote_op(conj, T)
@@ -23,7 +26,8 @@ end
2326
@inline parent_type{T,N,A}(::Type{ConjArray{T,N,A}}) = A
2427

2528
@inline size(a::ConjArray) = size(a.parent)
26-
linearindexing{CA <: ConjArray}(::Union{CA,Type{CA}}) = linearindexing(parent_type(CA))
29+
linearindexing{CA <: ConjArray}(::CA) = linearindexing(parent_type(CA))
30+
linearindexing{CA <: ConjArray}(::Type{CA}) = linearindexing(parent_type(CA))
2731

2832
@propagate_inbounds getindex{T,N}(a::ConjArray{T,N}, i::Int) = conj(getindex(a.parent, i))
2933
@propagate_inbounds getindex{T,N}(a::ConjArray{T,N}, i::Vararg{Int,N}) = conj(getindex(a.parent, i...))

base/linalg/linalg.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ export
2323
# Types
2424
RowVector,
2525
ConjArray,
26+
ConjVector,
27+
ConjMatrix,
2628
SymTridiagonal,
2729
Tridiagonal,
2830
Bidiagonal,

test/linalg/rowvector.jl

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
@test size(RowVector{Int}(1,3)) === (1,3)
1313
@test size(RowVector{Int}((3,))) === (1,3)
1414
@test size(RowVector{Int}((1,3))) === (1,3)
15-
@test_throws Exception RowVector{Float64, Vector{Int}}(v)
15+
@test_throws ErrorException RowVector{Float64, Vector{Int}}(v)
1616

1717
@test (v.')::RowVector == [1 2 3]
1818
@test (v')::RowVector == [1 2 3]
@@ -25,7 +25,7 @@
2525
@test (rv.')::Vector == [1, 2, 3]
2626
@test (rv')::Vector == [1, 2, 3]
2727
@test (tz.')::Vector == [1+im, 2, 3]
28-
@test (tz')::Vector == [1-im, 2, 3]
28+
@test (tz')::ConjVector == [1-im, 2, 3]
2929

3030
@test conj(rv) === rv
3131
@test conj(tz) == [1-im 2 3]
@@ -59,19 +59,19 @@ end
5959
rv = v.'
6060

6161
@test (rv*d)::RowVector == [2,6,12].'
62-
@test_throws Exception d*rv
62+
@test_throws DimensionMismatch d*rv
6363

6464
@test (d*rv.')::Vector == [2,6,12]
6565

66-
@test_throws Exception rv.'*d
66+
@test_throws DimensionMismatch rv.'*d
6767

6868
@test (d*rv')::Vector == [2,6,12]
6969

70-
@test_throws Exception rv'*d
70+
@test_throws DimensionMismatch rv'*d
7171

7272
@test (rv/d)::RowVector [2/1 3/2 4/3]
7373

74-
@test_throws Exception d \ rv
74+
@test_throws DimensionMismatch d \ rv
7575
end
7676

7777
@testset "Bidiagonal ambiguity methods" begin
@@ -81,7 +81,7 @@ end
8181

8282
@test (rv/bd)::RowVector [2/1 3/2 4/3]
8383

84-
@test_throws Exception bd \ rv
84+
@test_throws DimensionMismatch bd \ rv
8585
end
8686

8787
@testset "hcat" begin
@@ -94,7 +94,7 @@ end
9494
v = [2,3,4]
9595
rv = v.'
9696

97-
@test_throws Exception mat \ rv
97+
@test_throws DimensionMismatch mat \ rv
9898
end
9999

100100
@testset "Multiplication" begin
@@ -104,65 +104,65 @@ end
104104

105105
@test (rv*v) === 14
106106
@test (rv*mat)::RowVector == [1 4 9]
107-
@test_throws Exception [1]*reshape([1],(1,1)) # no longer permitted
108-
@test_throws Exception rv*rv
107+
@test_throws DimensionMismatch [1]*reshape([1],(1,1)) # no longer permitted
108+
@test_throws DimensionMismatch rv*rv
109109
@test (v*rv)::Matrix == [1 2 3; 2 4 6; 3 6 9]
110-
@test_throws Exception v*v # Was previously a missing method error, now an error message
111-
@test_throws Exception mat*rv
110+
@test_throws DimensionMismatch v*v # Was previously a missing method error, now an error message
111+
@test_throws DimensionMismatch mat*rv
112112

113-
@test_throws Exception rv*v.'
113+
@test_throws DimensionMismatch rv*v.'
114114
@test (rv*mat.')::RowVector == [1 4 9]
115-
@test_throws Exception [1]*reshape([1],(1,1)).' # no longer permitted
115+
@test_throws DimensionMismatch [1]*reshape([1],(1,1)).' # no longer permitted
116116
@test rv*rv.' === 14
117-
@test_throws Exception v*rv.'
117+
@test_throws DimensionMismatch v*rv.'
118118
@test (v*v.')::Matrix == [1 2 3; 2 4 6; 3 6 9]
119119
@test (mat*rv.')::Vector == [1,4,9]
120120

121121
@test (rv.'*v.')::Matrix == [1 2 3; 2 4 6; 3 6 9]
122-
@test_throws Exception rv.'*mat.'
122+
@test_throws DimensionMismatch rv.'*mat.'
123123
@test (v.'*mat.')::RowVector == [1 4 9]
124-
@test_throws Exception rv.'*rv.'
124+
@test_throws DimensionMismatch rv.'*rv.'
125125
@test v.'*rv.' === 14
126-
@test_throws Exception v.'*v.'
126+
@test_throws DimensionMismatch v.'*v.'
127127
@test (mat.'*rv.')::Vector == [1,4,9]
128128

129-
@test_throws Exception rv.'*v
130-
@test_throws Exception rv.'*mat
129+
@test_throws DimensionMismatch rv.'*v
130+
@test_throws DimensionMismatch rv.'*mat
131131
@test (v.'*mat)::RowVector == [1 4 9]
132132
@test (rv.'*rv)::Matrix == [1 2 3; 2 4 6; 3 6 9]
133-
@test_throws Exception v.'*rv
133+
@test_throws DimensionMismatch v.'*rv
134134
@test v.'*v === 14
135-
@test_throws Exception mat.'*rv
135+
@test_throws DimensionMismatch mat.'*rv
136136

137137
z = [1+im,2,3]
138138
cz = z'
139139
mat = diagm([1+im,2,3])
140140

141141
@test cz*z === 15 + 0im
142142

143-
@test_throws Exception cz*z'
143+
@test_throws DimensionMismatch cz*z'
144144
@test (cz*mat')::RowVector == [-2im 4 9]
145-
@test_throws Exception [1]*reshape([1],(1,1))' # no longer permitted
145+
@test_throws DimensionMismatch [1]*reshape([1],(1,1))' # no longer permitted
146146
@test cz*cz' === 15 + 0im
147-
@test_throws Exception z*vz'
147+
@test_throws DimensionMismatch z*cz'
148148
@test (z*z')::Matrix == [2 2+2im 3+3im; 2-2im 4 6; 3-3im 6 9]
149149
@test (mat*cz')::Vector == [2im,4,9]
150150

151151
@test (cz'*z')::Matrix == [2 2+2im 3+3im; 2-2im 4 6; 3-3im 6 9]
152-
@test_throws Exception cz'*mat'
152+
@test_throws DimensionMismatch cz'*mat'
153153
@test (z'*mat')::RowVector == [-2im 4 9]
154-
@test_throws Exception cz'*cz'
154+
@test_throws DimensionMismatch cz'*cz'
155155
@test z'*cz' === 15 + 0im
156-
@test_throws Exception z'*z'
156+
@test_throws DimensionMismatch z'*z'
157157
@test (mat'*cz')::Vector == [2,4,9]
158158

159-
@test_throws Exception cz'*z
160-
@test_throws Exception cz'*mat
159+
@test_throws DimensionMismatch cz'*z
160+
@test_throws DimensionMismatch cz'*mat
161161
@test (z'*mat)::RowVector == [2 4 9]
162162
@test (cz'*cz)::Matrix == [2 2+2im 3+3im; 2-2im 4 6; 3-3im 6 9]
163-
@test_throws Exception z'*cz
163+
@test_throws DimensionMismatch z'*cz
164164
@test z'*z === 15 + 0im
165-
@test_throws Exception mat'*cz
165+
@test_throws DimensionMismatch mat'*cz
166166
end
167167

168168
@testset "norm" begin
@@ -202,7 +202,7 @@ end
202202

203203
@test (rv/mat)::RowVector [2/1 3/2 4/3]
204204

205-
@test_throws Exception mat\rv
205+
@test_throws DimensionMismatch mat\rv
206206
end
207207

208208
@testset "AbstractTriangular ambiguity methods" begin
@@ -211,31 +211,31 @@ end
211211
rv = v.'
212212

213213
@test (rv*ut)::RowVector == [2 6 12]
214-
@test_throws Exception ut*rv
214+
@test_throws DimensionMismatch ut*rv
215215

216216
@test (rv*ut.')::RowVector == [2 6 12]
217217
@test (ut*rv.')::Vector == [2,6,12]
218218

219219
@test (ut.'*rv.')::Vector == [2,6,12]
220-
@test_throws Exception rv.'*ut.'
220+
@test_throws DimensionMismatch rv.'*ut.'
221221

222-
@test_throws Exception ut.'*rv
223-
@test_throws Exception rv.'*ut
222+
@test_throws DimensionMismatch ut.'*rv
223+
@test_throws DimensionMismatch rv.'*ut
224224

225225
@test (rv*ut')::RowVector == [2 6 12]
226226
@test (ut*rv')::Vector == [2,6,12]
227227

228-
@test_throws Exception rv'*ut'
228+
@test_throws DimensionMismatch rv'*ut'
229229
@test (ut'*rv')::Vector == [2,6,12]
230230

231-
@test_throws Exception ut'*rv
232-
@test_throws Exception rv'*ut
231+
@test_throws DimensionMismatch ut'*rv
232+
@test_throws DimensionMismatch rv'*ut
233233

234234
@test (rv/ut)::RowVector [2/1 3/2 4/3]
235235
@test (rv/ut.')::RowVector [2/1 3/2 4/3]
236236
@test (rv/ut')::RowVector [2/1 3/2 4/3]
237237

238-
@test_throws Exception ut\rv
238+
@test_throws DimensionMismatch ut\rv
239239
end
240240

241241

test/sparse/sparse.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1642,9 +1642,9 @@ end
16421642

16431643
# Test temporary fix for issue #16548 in PR #16979. Brittle. Expect to remove with `\` revisions.
16441644
# This is broken by the introduction of RowVector... see brittle comment above.
1645-
#@testset "issue #16548" begin
1646-
# @test which(\, (SparseMatrixCSC, AbstractVecOrMat)).module == Base.SparseArrays
1647-
#end
1645+
@testset "issue #16548" begin
1646+
@test_broken which(\, (SparseMatrixCSC, AbstractVecOrMat)).module == Base.SparseArrays
1647+
end
16481648

16491649
@testset "row indexing a SparseMatrixCSC with non-Int integer type" begin
16501650
A = sparse(UInt32[1,2,3], UInt32[1,2,3], [1.0,2.0,3.0])

0 commit comments

Comments
 (0)