Bijectors.jl
Bijectors.jl copied to clipboard
Rename `rv` from `forward(b::Bijector, x)` result
At the moment, if you call forward(b, x) you get back a named tuple (rv = b(x), logabsdetjac = logabsdetjac(b, x)). This was introduced in the first PR for the new interface.
When I started out working on this, using rv made sense as the transform was always related to some Distribution. Now a Bijector can be used as a standalone transform to do more than just transform random variables, e.g. constrained-to-unconstrained transformations in optimization. Therefore I suggest we rename rv.
A couple of suggestions (in no particular order):
ysince throughout the entire package it's a recurring theme wherexis "un-transformed" andydenotes transformed. Also, inforward,xis the input. This also corresponds with the(x = x, y = b(x), ...)returned by callingforward(d::TransformedDistribution). Though could also be up for discussion in this issue.valorvalueresorresult
Any suggestions?
I like 1 and 3. The reason I don't like 2 is because val or value doesn't indicate the value is transfomed or not.
I vote 1
Personally I also like 1. One possible issue is that one can also call forward(ib::Inversed{<:Bijector}, y). Should this also return y = ...? We should use the same key in forward for both inversed and not, imo.
Another alternative is output. I guess y isn't such a great name if you consider inverse transformations.
Another alternative is output. I guess y isn't such a great name if you consider inverse transformations.
True. I think I prefer 3 over output but not by much
Similarly, ans is a good choice. It's also Julia's default name holder for results.
➜ ~ julia
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.1.0 (2019-01-21)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
julia> 1 + 1
2
julia> ans
2
I prefer 3.
A final call for votes: @yebai @cpfiffer @mohamed82008 @sharanry
I prefer 3 as well.
Then 3 it is!
People comfortable with renaming rv to result then? I think it's okay to be slightly verbose since you can also do y, logjac = forward(b, x) for that sweet conciseness.
Thumbs up if you agree, thumbs down if you prefer res.