Skip to content

Commit 7453b41

Browse files
authored
revert despecialization of type in zero/one (#162)
1 parent 45f91ff commit 7453b41

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/constructors.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,11 @@ Fun(f::Type, d::Space) = error("Not implemented")
144144

145145
# special case constructors
146146
zeros(S::Space) = zeros(Float64, S)
147-
zeros(T::Type, S::Space) = Fun(S,zeros(T,1))
147+
zeros(::Type{T}, S::Space) where {T<:Number} = Fun(S,zeros(T,1))
148148

149149
# catch all
150150
ones(S::Space) = ones(Float64, S)
151-
ones(T::Type, S::Space) = Fun(x->one(T),S)
151+
ones(::Type{T}, S::Space) where {T<:Number} = Fun(x->one(T),S)
152152

153153
function Fun(::typeof(identity), d::Domain)
154154
cd=canonicaldomain(d)

test/SpacesTest.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ using ApproxFunOrthogonalPolynomials
8080
end
8181
end
8282

83+
f = @inferred (T -> ones(T, PointSpace(1:3)))(Float64)
84+
@test f == Fun(PointSpace(1:3), [1.0, 1.0, 1.0])
85+
f = @inferred (T -> zeros(T, PointSpace(1:3)))(Float64)
86+
@test space(f) == PointSpace(1:3)
87+
@test all(iszero(coefficients(f)))
88+
8389
M = Multiplication(Fun(PointSpace(1:3), [1:3;]), PointSpace(1:3))
8490
@test (@inferred size(M)) == (3,3)
8591
M2 = M + M

0 commit comments

Comments
 (0)