Skip to content

Commit

Permalink
Add inverse for identity
Browse files Browse the repository at this point in the history
  • Loading branch information
eliascarv committed Apr 28, 2022
1 parent a80626d commit 1c7cae1
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/transforms/functional.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,17 @@ Functional(pairs::Pair{K}...) where {K<:AbstractString} =
Functional() = throw(ArgumentError("Cannot create a Functional object without arguments."))

# known invertible functions
inverse(::typeof(log)) = exp
inverse(::typeof(exp)) = log
inverse(::typeof(cos)) = acos
inverse(::typeof(acos)) = cos
inverse(::typeof(sin)) = asin
inverse(::typeof(asin)) = sin
inverse(::typeof(log)) = exp
inverse(::typeof(exp)) = log
inverse(::typeof(cos)) = acos
inverse(::typeof(acos)) = cos
inverse(::typeof(sin)) = asin
inverse(::typeof(asin)) = sin
inverse(::typeof(cosd)) = acosd
inverse(::typeof(acosd)) = cosd
inverse(::typeof(sind)) = asind
inverse(::typeof(asind)) = sind
inverse(::typeof(identity)) = identity

# fallback to nothing
inverse(::Any) = nothing
Expand Down Expand Up @@ -88,7 +89,7 @@ function revertfunc(transform::Functional{<:NamedTuple}, cols, nm)
invfunc.(x)
end

function revert(transform::Filter, newtable, cache)
function revert(transform::Functional, newtable, cache)
cols = Tables.columns(newtable)
names = Tables.columnnames(newtable)
ocols = tcollect(revertfunc(transform, cols, nm) for nm in names)
Expand Down

0 comments on commit 1c7cae1

Please sign in to comment.