We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 72ea1f6 commit 190d74dCopy full SHA for 190d74d
src/Spaces/ArraySpace.jl
@@ -18,6 +18,8 @@ const VectorSpace{S,DD,RR,A<:AbstractVector{S}} = ArraySpace{S,1,DD,RR,A}
18
const MatrixSpace{S,DD,RR,A<:AbstractMatrix{S}} = ArraySpace{S,2,DD,RR,A}
19
20
#TODO: Think through domain/domaindominsion
21
+ArraySpace(sp::AbstractArray{SS,N}) where {D,R,SS<:Space{D,R},N} =
22
+ ArraySpace{SS,N,D,R,typeof(sp)}(sp)
23
ArraySpace(sp::AbstractArray{SS,N}, f = first(sp)) where {SS<:Space,N} =
24
ArraySpace{SS,N,domaintype(f),mapreduce(rangetype,promote_type,sp),typeof(sp)}(sp)
25
ArraySpace(S::Space,::Val{n}) where {n} = ArraySpace(@SArray fill(S,n...))
@@ -57,7 +59,7 @@ iterate(f::Fun{<:ArraySpace}) = iterate(components(f))
57
59
58
60
61
Base.reshape(AS::ArraySpace,k...) = ArraySpace(reshape(AS.spaces,k...))
-dimension(AS::ArraySpace) = mapreduce(dimension,+,AS.spaces)
62
+dimension(AS::ArraySpace) = mapreduce(dimension,+,AS.spaces,init=0)
63
64
# TODO: union domain
65
domain(AS::ArraySpace) = domain(AS.spaces[1])
test/SpacesTest.jl
@@ -345,5 +345,10 @@ using LinearAlgebra
345
a = @inferred space(rand(2,2))
346
b = @inferred space(@SArray rand(2,2))
347
@test a == b
348
+
349
+ # empty array space
350
+ A = ApproxFunBase.ArraySpace(empty!([PointSpace(1:3)]))
351
+ @test length(A) == 0
352
+ @test ApproxFunBase.dimension(A) == 0
353
end
354
0 commit comments