Skip to content

Commit

Permalink
Export the isinvertible and inverse functions (#287)
Browse files Browse the repository at this point in the history
* Export the 'isinvertible' and 'inverse' functions

* Update docs/src/index.md

---------

Co-authored-by: Júlio Hoffimann <[email protected]>
  • Loading branch information
eliascarv and juliohm authored Jun 21, 2024
1 parent b173f0a commit e4aaa6d
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ using TransformsBase
DocMeta.setdocmeta!(TableTransforms, :DocTestSetup, :(using TableTransforms); recursive=true)

makedocs(;
warnonly=[:missing_docs, :cross_references],
warnonly=[:missing_docs],
modules=[TableTransforms, TransformsBase],
authors="Júlio Hoffimann <[email protected]> and contributors",
repo="https://github.com/JuliaML/TableTransforms.jl/blob/{commit}{path}#{line}",
Expand Down
33 changes: 33 additions & 0 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,39 @@ Using the cache we can revert the transform:
original = revert(transform, newtable, cache)
```

### Inverting transforms

Some transforms have an inverse that can be created with the [`inverse`](@ref) function.
The function [`isinvertible`](@ref) can be used to check if a transform is invertible.

```@docs
inverse
isinvertible
```

Let's exemplify this:

```@example usage
a = [5.1, 1.5, 9.4, 2.4]
b = [7.6, 6.2, 5.8, 3.0]
c = [6.3, 7.9, 7.6, 8.4]
table = (; a, b, c)
```

Choose a transform and check that it is invertible:

```@example usage
transform = Functional(exp)
isinvertible(transform)
```

Now, let's test the inverse transform:

```@example usage
invtransform = inverse(transform)
invtransform(transform(table))
```

### Reapplying transforms

Finally, it is sometimes useful to [`reapply`](@ref) a transform that was
Expand Down
2 changes: 2 additions & 0 deletions src/TableTransforms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ export

# interface
isrevertible,
isinvertible,
apply,
revert,
reapply,
inverse,

# built-in
Assert,
Expand Down

0 comments on commit e4aaa6d

Please sign in to comment.