Skip to content

Commit cd5585f

Browse files
authored
TensorSpace in ProductFun constructor (#541)
* TensorSpace in ProductFun constructor * Promote to maxspace
1 parent d5c812d commit cd5585f

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

src/Multivariate/ProductFun.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,10 @@ true
109109
```
110110
"""
111111
function ProductFun(M::AbstractVector{VFun{S,T}}, dy::V) where {S<:UnivariateSpace,V<:UnivariateSpace,T<:Number}
112-
prodsp = ProductSpace(map(space, M), dy)
113-
ProductFun{S,V,typeof(prodsp),T}(copy(M), prodsp)
112+
sp = mapreduce(space, maxspace, M)
113+
Msp = [Fun(f, sp) for f in M]
114+
prodsp = sp dy
115+
ProductFun{S,V,typeof(prodsp),T}(Msp, prodsp)
114116
end
115117

116118
## Adaptive construction

src/Multivariate/TensorSpace.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,8 @@ domain(f::ProductSpace) = f.domain
435435

436436
factors(d::ProductSpace) = (d.spacesx, d.spacey)
437437

438+
show(io::IO, P::ProductSpace) = print(io, "ProductSpace", factors(P))
439+
438440
## Transforms
439441
function nDtransform_inner!(A, tempv, Rpre, Rpost, dim, plan!)
440442
for indpost in Rpost, indpre in Rpre

test/show.jl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
@testset "ConstantSpace" begin
1212
@test contains(repr(ConstantSpace()), "ConstantSpace")
1313
c = ConstantSpace(0..1)
14-
@test contains(repr(c), "ConstantSpace")
14+
@test startswith(repr(c), "ConstantSpace")
1515
@test contains(repr(c), repr(domain(c)))
1616
end
1717
@testset "TensorSpace" begin
@@ -21,6 +21,13 @@
2121
@test length(v) == 2
2222
@test all(==(repr(S1)), v)
2323
end
24+
@testset "ProductSpace" begin
25+
S1 = PointSpace(1:4)
26+
S2 = PointSpace(1:2)
27+
P = ProductSpace([S1, S1], S2)
28+
@test startswith(repr(P), "ProductSpace")
29+
@test contains(repr(P), string(factors(P)))
30+
end
2431
@testset "SumSpace" begin
2532
S1 = PointSpace(1:3)
2633
S = S1 S1
@@ -32,7 +39,7 @@
3239
p = PointSpace(1:4)
3340
ps = PiecewiseSpace(p)
3441
rpr = repr(ps)
35-
@test contains(rpr, "PiecewiseSpace")
42+
@test startswith(rpr, "PiecewiseSpace")
3643
@test contains(rpr, repr(p))
3744
end
3845
end

0 commit comments

Comments
 (0)