Skip to content

Commit f9865dc

Browse files
authored
Tuples in promotespaces (#256)
* Tuples in promotespaces * Add test
1 parent a80ae3c commit f9865dc

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

src/Operators/general/InterlaceOperator.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ function rangespace(A::AbstractVector{T}) where T<:Operator
5151
Space(spl)
5252
end
5353

54-
promotespaces(A::AbstractMatrix{T}) where {T<:Operator} = promotespaces(Matrix(A))
54+
promotespaces(A::AbstractMatrix{<:Operator}) = promotespaces(Matrix(A))
5555

56-
function promotespaces(A::Matrix{T}) where T<:Operator
56+
function promotespaces(A::Matrix{<:Operator})
5757
isempty(A) && return A
5858
ret = similar(A) #TODO: promote might have different Array type
5959
for j=1:size(A,2)

src/Operators/spacepromotion.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,23 +86,23 @@ promotedomainspace(P::Operator,sp::Space,cursp::Space) =
8686

8787

8888

89+
const VectorOrTupleOfOp{O<:Operator} = Union{AbstractVector{O}, Tuple{O, Vararg{O}}}
8990

90-
91-
function promoterangespace(ops::Union{AbstractVector{O}, Tuple{O,Vararg{O}}}) where O<:Operator
91+
function promoterangespace(ops::VectorOrTupleOfOp{O}) where O<:Operator
9292
isempty(ops) && return strictconvert(Vector{Operator{eltype(O)}}, ops)
9393
k=findmaxrangespace(ops)
9494
#TODO: T might be incorrect
9595
T=mapreduce(eltype,promote_type,ops)
9696
Operator{T}[promoterangespace(op,k) for op in ops]
9797
end
98-
function promotedomainspace(ops::Union{AbstractVector{O}, Tuple{O,Vararg{O}}}) where O<:Operator
98+
function promotedomainspace(ops::VectorOrTupleOfOp{O}) where O<:Operator
9999
isempty(ops) && return strictconvert(Vector{Operator{eltype(O)}}, ops)
100100
k=findmindomainspace(ops)
101101
#TODO: T might be incorrect
102102
T=mapreduce(eltype,promote_type,ops)
103103
Operator{T}[promotedomainspace(op,k) for op in ops]
104104
end
105-
function promotedomainspace(ops::Union{AbstractVector{O}, Tuple{O,Vararg{O}}},S::Space) where O<:Operator
105+
function promotedomainspace(ops::VectorOrTupleOfOp{O}, S::Space) where O<:Operator
106106
isempty(ops) && return strictconvert(Vector{Operator{eltype(O)}}, ops)
107107
k=conversion_type(findmindomainspace(ops),S)
108108
#TODO: T might be incorrect
@@ -158,8 +158,8 @@ spacescompatible(A::Operator,B::Operator) =
158158

159159

160160
#It's important that domain space is promoted first as it might impact range space
161-
promotespaces(ops::AbstractVector) = promoterangespace(promotedomainspace(ops))
162-
function promotespaces(ops::AbstractVector,b::Fun)
161+
promotespaces(ops::VectorOrTupleOfOp{<:Operator}) = promoterangespace(promotedomainspace(ops))
162+
function promotespaces(ops::VectorOrTupleOfOp{<:Operator}, b::Fun)
163163
A=promotespaces(ops)
164164
if isa(rangespace(A),AmbiguousSpace)
165165
# try setting the domain space

test/runtests.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,12 @@ end
287287
@test Ar[1:4, 1:4] == diagm(0=>fill(3, 4))
288288
@test Ai[1:4, 1:4] == diagm(0=>fill(-2, 4))
289289
end
290+
@testset "tuples in promotespaces" begin
291+
M = Multiplication(Fun(PointSpace(1:4)), PointSpace(1:4))
292+
A = ApproxFunBase.promotespaces([M, M])
293+
B = ApproxFunBase.promotespaces((M, M))
294+
@test all(((x,y),) -> x == y, zip(A, B))
295+
end
290296
end
291297

292298
@testset "RowVector" begin

0 commit comments

Comments
 (0)