Skip to content

Commit

Permalink
Fix getting(::AbstractTransform)
Browse files Browse the repository at this point in the history
  • Loading branch information
tkf committed Dec 12, 2019
1 parent 688e14f commit 8f74bff
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/transformvariables.jl
Expand Up @@ -6,7 +6,7 @@ getting(xf::AbstractTransform) = _getting(xf)
XFBijection{INV}(xf::T) where {INV, T} = XFBijection{INV, T}(xf)
XFBijection(xf) = XFBijection{false}(xf)

Base.inv(bijection::XFBijection{INV}) where INV = XFBijection{!INF}(bijection.xf)
Base.inv(bijection::XFBijection{INV}) where INV = XFBijection{!INV}(bijection.xf)

Bijection(xf::AbstractTransform) = XFBijection(xf)
tofield(b::XFBijection{false}, x) = transform(b.xf, x)
Expand Down
9 changes: 8 additions & 1 deletion test/test_transformvariables.jl
Expand Up @@ -3,11 +3,18 @@ module TestTransformVariables
include("preamble.jl")
using TransformVariables

@testset begin
@testset "setting(asℝ₊)" begin
l = (@lens _.y[2]) setting(asℝ₊)
obj = (x=0, y=(0, 1, 2))
@test get(obj, l) == 0
@test set(obj, l, -1).y[2] == exp(-1)
end

@testset "getting(as𝕀)" begin
l = (@lens _.y[2]) getting(as𝕀)
obj = (x=0, y=(0, -Inf, 2))
@test get(obj, l) == 0
@test set(obj, l, 0.5).y[2] == 0.0
end

end # module

0 comments on commit 8f74bff

Please sign in to comment.