Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export the isinvertible and inverse functions #287

Merged
merged 2 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
Loading