From c8160be9f802e9fea2edf4ab81a8488d5b534fd9 Mon Sep 17 00:00:00 2001 From: lkdvos Date: Wed, 13 May 2026 14:06:30 -0400 Subject: [PATCH 1/2] add support for broadcasting/mapping over HomSpace --- src/spaces/homspace.jl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/spaces/homspace.jl b/src/spaces/homspace.jl index 9ef8a5d51..f1819572e 100644 --- a/src/spaces/homspace.jl +++ b/src/spaces/homspace.jl @@ -56,10 +56,15 @@ const TensorMapSpace{S <: ElementarySpace, N₁, N₂} = HomSpace{ numout(::Type{TensorMapSpace{S, N₁, N₂}}) where {S, N₁, N₂} = N₁ numin(::Type{TensorMapSpace{S, N₁, N₂}}) where {S, N₁, N₂} = N₂ +Base.length(W::HomSpace) = numout(W) + numin(W) function Base.getindex(W::TensorMapSpace{<:IndexSpace, N₁, N₂}, i) where {N₁, N₂} return i <= N₁ ? codomain(W)[i] : dual(domain(W)[i - N₁]) end +Base.Broadcast.broadcastable(W::HomSpace) = + TupleTools.vcat(identity.(codomain(W)), dual.(domain(W))) +Base.map(f, W::HomSpace) = f.(W) + function ←(codom::ProductSpace{S}, dom::ProductSpace{S}) where {S <: ElementarySpace} return HomSpace(codom, dom) end From 193dcef07c8facd4902048ff1c059ef206a1b3a1 Mon Sep 17 00:00:00 2001 From: lkdvos Date: Wed, 13 May 2026 14:09:59 -0400 Subject: [PATCH 2/2] add some tests --- test/symmetries/spaces.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/symmetries/spaces.jl b/test/symmetries/spaces.jl index 0438a7e14..6296bc335 100644 --- a/test/symmetries/spaces.jl +++ b/test/symmetries/spaces.jl @@ -444,6 +444,8 @@ end @test W[3] == V5 @test W[4] == V4 @test W[5] == V3 + @test all(W .== (V1, V2, V5, V4, V3)) + @test @constinferred(map(isdual, W)) == ntuple(i -> isdual(W[i]), length(W)) @test @constinferred(hash(W)) == hash(deepcopy(W)) != hash(W') @test W == deepcopy(W) cod = codomain(W)