Skip to content

Commit 87508ae

Browse files
committed
fix broadcasting
1 parent 50fe9f7 commit 87508ae

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
- rewrite internals to work better with AD (especially Zygote)
66

7+
- fix broadcasting (`Ref(transformation)` no longer necessary)
8+
79
# 0.3.4
810

911
- make `inverse(::ArrayTransform)` accept `AbstractArray`

src/generic.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ The user interface consists of
108108
"""
109109
abstract type AbstractTransform end
110110

111+
Base.broadcastable(t::AbstractTransform) = Ref(t)
112+
111113
"""
112114
$(TYPEDEF)
113115

test/runtests.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,3 +449,16 @@ end
449449
t = as(Array, 2, 3)
450450
@test inverse(t, ones(SMatrix{2,3})) == ones(6)
451451
end
452+
453+
####
454+
#### broadcasting
455+
####
456+
457+
@testset "broadcasting" begin
458+
@test as𝕀.([0, 0]) == [0.5, 0.5]
459+
460+
t = UnitVector(3)
461+
d = dimension(t)
462+
x = [zeros(d), zeros(d)]
463+
@test t.(x) == map(t, x)
464+
end

0 commit comments

Comments
 (0)