Skip to content

Commit fcb5017

Browse files
committed
Update compat
1 parent 6c468e0 commit fcb5017

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "TableTransforms"
22
uuid = "0d432bfd-3ee1-4ac1-886a-39f05cc69a3e"
33
authors = ["Júlio Hoffimann <[email protected]> and contributors"]
4-
version = "1.36.0"
4+
version = "1.36.1"
55

66
[deps]
77
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
@@ -26,7 +26,7 @@ Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
2626

2727
[compat]
2828
AbstractTrees = "0.4"
29-
CategoricalArrays = "0.10"
29+
CategoricalArrays = "1.0"
3030
CoDa = "1.2"
3131
ColumnSelectors = "1.0"
3232
DataScienceTraits = "1.0"

src/transforms/onehot.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,14 @@ assertions(transform::OneHot) = [scitypeassert(Categorical, transform.selector)]
3030

3131
isrevertible(::Type{<:OneHot}) = true
3232

33-
_categ(x) = categorical(x), identity
34-
function _categ(x::CategoricalArray)
35-
l, o = levels(x), isordered(x)
36-
revfun = y -> categorical(y, levels=l, ordered=o)
37-
x, revfun
38-
end
39-
4033
function applyfeat(transform::OneHot, feat, prep)
4134
cols = Tables.columns(feat)
4235
names = Tables.columnnames(cols) |> collect
4336
columns = Any[Tables.getcolumn(cols, nm) for nm in names]
4437

4538
name = selectsingle(transform.selector, names)
4639
ind = findfirst(==(name), names)
47-
x, revfun = _categ(columns[ind])
40+
x, revfun = _categorical(columns[ind])
4841

4942
xlevels = levels(x)
5043
onehot = map(xlevels) do l
@@ -89,3 +82,10 @@ function revertfeat(::OneHot, newfeat, fcache)
8982
𝒯 = (; zip(names, columns)...)
9083
𝒯 |> Tables.materializer(newfeat)
9184
end
85+
86+
_categorical(x) = x, identity
87+
function _categorical(x::CategoricalArray)
88+
l, o = levels(x), isordered(x)
89+
revfun = y -> categorical(y, levels=l, ordered=o)
90+
x, revfun
91+
end

0 commit comments

Comments
 (0)