From f9d07825761ba5aa95f57172acbc63b51d5f4bf9 Mon Sep 17 00:00:00 2001 From: "Anthony D. Blaom" Date: Fri, 30 Apr 2021 16:37:59 +1200 Subject: [PATCH 1/3] bump compat CategoricalArrays = "0.9, 0.10"; level -> levelcode --- Project.toml | 2 +- src/interface/data_utils.jl | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index 75f581bd..b36de076 100644 --- a/Project.toml +++ b/Project.toml @@ -28,7 +28,7 @@ StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" [compat] -CategoricalArrays = "0.8.1, 0.9" +CategoricalArrays = "0.9, 0.10" ComputationalResources = "0.3" Distributions = "0.22, 0.23, 0.24" InvertedIndices = "1" diff --git a/src/interface/data_utils.jl b/src/interface/data_utils.jl index ea95a75b..a5eb3bc2 100644 --- a/src/interface/data_utils.jl +++ b/src/interface/data_utils.jl @@ -19,7 +19,8 @@ MMI.int(::FI, x::AbstractArray) = int.(x) # first line is no good because it promotes type to higher ineger type: # MMI.int(::FI, x::CategoricalValue) = CategoricalArrays.levelcode(x) -MMI.int(::FI, x::CategoricalValue) = CategoricalArrays.level(x) +MMI.int(::FI, x::CategoricalValue{<:Any,R}) where R = + R(CategoricalArrays.levelcode(x)) # ------------------------------------------------------------------------ # classes From ebc5241031344191fb5aac97048e24d00d0119b3 Mon Sep 17 00:00:00 2001 From: "Anthony D. Blaom" Date: Sat, 1 May 2021 07:30:15 +1200 Subject: [PATCH 2/3] levelcode -> refcode; remove some depwarns in testing oops --- src/interface/data_utils.jl | 5 ++--- test/resampling.jl | 5 ++++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/interface/data_utils.jl b/src/interface/data_utils.jl index a5eb3bc2..92764cc7 100644 --- a/src/interface/data_utils.jl +++ b/src/interface/data_utils.jl @@ -17,10 +17,9 @@ MMI.int(::FI, x) = throw( MMI.int(::FI, x::Missing) = missing MMI.int(::FI, x::AbstractArray) = int.(x) -# first line is no good because it promotes type to higher ineger type: +# first line is no good because it promotes type to larger integer type: # MMI.int(::FI, x::CategoricalValue) = CategoricalArrays.levelcode(x) -MMI.int(::FI, x::CategoricalValue{<:Any,R}) where R = - R(CategoricalArrays.levelcode(x)) +MMI.int(::FI, x::CategoricalValue) = CategoricalArrays.refcode(x) # ------------------------------------------------------------------------ # classes diff --git a/test/resampling.jl b/test/resampling.jl index 1e432f34..7eb81a25 100644 --- a/test/resampling.jl +++ b/test/resampling.jl @@ -321,7 +321,10 @@ end @test pairs != pairs_random # wrong target type throws error: - @test_throws Exception MLJBase.train_test_pairs(scv, rows, get.(y)) + @test_throws(Exception, + MLJBase.train_test_pairs(scv, + rows, + CategoricalArrays.unwrap.(y))) # check class distribution is preserved in a larger randomized example: N = 30 From c9fc6f3d5bc5629c3f1d41966b38a2bed98eb71c Mon Sep 17 00:00:00 2001 From: "Anthony Blaom, PhD" Date: Sat, 1 May 2021 08:54:11 +1200 Subject: [PATCH 3/3] bump 0.18.3 --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index b36de076..b4dd7242 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "MLJBase" uuid = "a7f614a8-145f-11e9-1d2a-a57a1082229d" authors = ["Anthony D. Blaom "] -version = "0.18.2" +version = "0.18.3" [deps] CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597"