Skip to content

Commit

Permalink
Update for latest TableTransforms.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
juliohm committed Jan 25, 2023
1 parent 05112a0 commit 9287c73
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 16 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "CoDa"
uuid = "5900dafe-f573-5c72-b367-76665857777b"
author = "Júlio Hoffimann <julio.hoffimann@gmail.com>"
version = "1.0.6"
version = "1.0.7"

[deps]
AxisArrays = "39de3d68-74b9-583c-8d2d-e117c070f3a9"
Expand All @@ -26,6 +26,6 @@ FillArrays = "0.12, 0.13"
ScientificTypes = "3.0"
StaticArrays = "1.0"
StatsBase = "0.32, 0.33"
TableTransforms = "1.6"
TableTransforms = "1.9"
Tables = "1.1"
julia = "1.6"
1 change: 1 addition & 0 deletions src/CoDa.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import Tables
import ScientificTypes as ST
import TableTransforms: FeatureTransform
import TableTransforms: StatelessFeatureTransform
import TableTransforms: SciTypeAssertion
import TableTransforms: assertions, isrevertible
import TableTransforms: applyfeat, revertfeat
import TableTransforms: preprocess, reapply
Expand Down
9 changes: 2 additions & 7 deletions src/transforms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,11 @@ See also [`ALR`](@ref), [`CLR`](@ref), [`ILR`](@ref).
"""
abstract type LogRatio <: StatelessFeatureTransform end

assertions(::Type{<:LogRatio}) = [TableTransforms.assert_continuous]

isrevertible(::Type{<:LogRatio}) = true

function applyfeat(transform::LogRatio, table, prep)
# basic checks
for assertion in assertions(transform)
assertion(table)
end
assertions(::Type{<:LogRatio}) = [SciTypeAssertion{ST.Continuous}()]

function applyfeat(transform::LogRatio, table, prep)
# original variable names
vars = Tables.columnnames(table)

Expand Down
9 changes: 3 additions & 6 deletions src/transforms/closure.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,16 @@
The transform that applies the closure operation 𝒞
to all rows of the input table. The rows of the
output table sum to one.
See also [`Remainder`](@ref).
"""
struct Closure <: StatelessFeatureTransform end

isrevertible(::Type{Closure}) = true

assertions(::Type{Closure}) = [TableTransforms.assert_continuous]
assertions(::Type{Closure}) = [SciTypeAssertion{ST.Continuous}()]

function applyfeat(transform::Closure, table, prep)
# basic checks
for assertion in assertions(transform)
assertion(table)
end

# original column names
names = Tables.columnnames(table)

Expand Down
4 changes: 3 additions & 1 deletion src/transforms/remainder.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ The transform that takes a table with columns `x₁, x₂, …, xₙ`
and returns a new table with an additional column containing the
remainder value `xₙ₊₁ = total .- (x₁ + x₂ + ⋯ + xₙ)` If the `total`
value is not specified, then default to the maximum sum across rows.
See also [`Closure`](@ref).
"""
struct Remainder <: FeatureTransform
total::Union{Float64,Nothing}
Expand All @@ -18,7 +20,7 @@ Remainder() = Remainder(nothing)

isrevertible(::Type{Remainder}) = true

assertions(::Type{Remainder}) = [TableTransforms.assert_continuous]
assertions(::Type{Remainder}) = [SciTypeAssertion{ST.Continuous}()]

function preprocess(transform::Remainder, table)
# find total across rows
Expand Down

2 comments on commit 9287c73

@juliohm
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/76353

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.0.7 -m "<description of version>" 9287c73127898ea8919dbc553361007341c888a9
git push origin v1.0.7

Please sign in to comment.