Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
2b5daf3
Sketch out the idea
Ickaser Feb 18, 2026
bc1271a
Rename to Transform, not Transformation
Ickaser Feb 25, 2026
26928ee
Add ConstructionBase
Ickaser Feb 25, 2026
1be11b9
Try implementing proper methods
Ickaser Feb 25, 2026
ab1ec00
minor fixes
tpapp Feb 25, 2026
125608d
Add methods for tuple, namedtuple, and scalar; add tests for each, wi…
Ickaser Feb 25, 2026
fc619fe
Add printing for tuple and scalar cases
Ickaser Feb 25, 2026
7e7ed63
Make a separate ScalarWrapperTransform
Ickaser Feb 25, 2026
36c4bbd
Eliminate method ambiguity by repeating a StaticArrays method for `as`
Ickaser Feb 25, 2026
da53854
Drop full scalar transform interface for typewrapper, in favor of con…
Ickaser Feb 26, 2026
a258ac8
Make precompile work
Ickaser Feb 28, 2026
35170d1
match namedtuple to struct fields
Ickaser Feb 28, 2026
4c6c116
Switch semantics: NamedTuples unpack as kwargs
Ickaser Mar 2, 2026
e52a6be
Implement inverses which do their best; add inference tests by using …
Ickaser Mar 3, 2026
76a7dd5
Help 1.10 constprop out a little bit to reach full inference, add a c…
Ickaser Mar 5, 2026
ff487e2
Formatting improvements
Ickaser Mar 6, 2026
5aafeab
Dead code
Ickaser Mar 6, 2026
c6500f0
Error for different number of fields than tuple fields, rather than r…
Ickaser Mar 6, 2026
47a4504
Test pretty printing on aggregations, make array of scalars go inline
Ickaser Mar 10, 2026
607ef4c
Add an inline array transform test for longer scalar transform
Ickaser Mar 10, 2026
a2a67a4
Chase coverage on array pretty printing test
Ickaser Mar 10, 2026
786084e
Docs suggestions from review
Ickaser Mar 16, 2026
e23217c
Remove scalar case from struct transforms
Ickaser Mar 16, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/aggregation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -482,3 +482,33 @@ function _domain_label(t::TransformTuple, index::Int)
end
error("internal error")
end

####
#### type wrapper transformation
####

struct TypeWrapperTransformation{T} <: AbstractTransform
inner_transformation::AbstractTransform
end

function as(::Type{T}, transformation) where T
TypeWrapperTransformation{T}(transformation)
end

dimension(t::TypeWrapperTransformation) = dimension(t.inner_transformation)

function transform(t::TypeWrapperTransformation{T}, x) where T
Comment thread
Ickaser marked this conversation as resolved.
Outdated
T(transform(t.inner_transformation, x)...)
Comment thread
Ickaser marked this conversation as resolved.
Outdated
end
# function transform(t::TypeWrapperTransformation{T}, x::VectorTransform) where T
# T(x...)
# end
# function transform(t::TypeWrapperTransformation{T}, x::ScalarTransform) where T
# T(x)
# end
function inverse(t::TypeWrapperTransformation{T}, x::T) where T
fields = [getfield(x, i) for i in 1:nfields(x)]
Comment thread
Ickaser marked this conversation as resolved.
Outdated
inverse(t.inner_transformation, fields)
end


19 changes: 19 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,25 @@ end

end

@testset "transform to custom type" begin
struct CustomType
a::Float64
b::Float64
end

t1 = as((a = asℝ, b = asℝ))
t2 = as(CustomType, t1)
y = transform(t2, [1.0, 2.0])
@test y == CustomType(1.0, 2.0)
@test inverse(t2, y) == [1.0, 2.0]

t3 = as(Vector, asℝ₊, 2)
t4 = as(CustomType, t3)
y = transform(t4, [0.0, 0.0])
@test y == CustomType(1.0, 1.0)
@test inverse(t4, y) == [0.0, 0.0]
end

####
#### log density correctness checks
####
Expand Down
Loading