Skip to content

Commit 37f8d24

Browse files
authored
Condense constantspace maxspace (#451)
* condense constantspace maxspace * preserve rangetype
1 parent bf0f889 commit 37f8d24

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/Space.jl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -649,10 +649,7 @@ end
649649
# domainscompatible check.
650650
for OP in (:maxspace,:(union))
651651
@eval begin
652-
$OP(A::ConstantSpace{AnyDomain},B::ConstantSpace{AnyDomain}) = A
653-
$OP(A::ConstantSpace{AnyDomain},B::ConstantSpace) = B
654-
$OP(A::ConstantSpace,B::ConstantSpace{AnyDomain}) = A
655-
$OP(A::ConstantSpace,B::ConstantSpace) = ConstantSpace(domain(A) domain(B))
652+
$OP(A::ConstantSpace{<:Any,R1}, B::ConstantSpace{<:Any,R2}) where {R1,R2} = ConstantSpace(promote_type(R1,R2), domain(A) domain(B))
656653
end
657654
end
658655

test/SpacesTest.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using ApproxFunBase
22
using Test
3-
using ApproxFunBase: PointSpace, HeavisideSpace, PiecewiseSegment, dimension, SVector, checkpoints
3+
using ApproxFunBase: PointSpace, HeavisideSpace, PiecewiseSegment, dimension, SVector, checkpoints, AnyDomain
44
using StaticArrays
55
using BandedMatrices: rowrange, colrange, BandedMatrix
66
using LinearAlgebra
@@ -303,6 +303,11 @@ using LinearAlgebra
303303
@test g > f
304304
@test g >= f
305305
@test 1 < f < 3
306+
307+
@test maxspace(ConstantSpace(Point(1)), ConstantSpace(Point(2))) == ConstantSpace(Point(1) Point(2))
308+
@test maxspace(ConstantSpace(Point(1)), ConstantSpace(AnyDomain())) == ConstantSpace(Point(1))
309+
@test maxspace(ConstantSpace(AnyDomain()), ConstantSpace(Point(2))) == ConstantSpace(Point(2))
310+
@test maxspace(ConstantSpace(AnyDomain()), ConstantSpace(AnyDomain())) == ConstantSpace(AnyDomain())
306311
end
307312

308313
@testset "promotion" begin

0 commit comments

Comments
 (0)