From 9f3ebf2043bf70fb01477c5e7b72d22e434bf874 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Jul 2026 07:36:07 +0000 Subject: [PATCH 1/4] Bump actions/checkout from 4 to 7 Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 7. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v4...v7) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: '7' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b48ba3d..07e577c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,7 +24,7 @@ jobs: arch: aarch64 version: 1 steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v7 - uses: julia-actions/setup-julia@v2 with: version: ${{ matrix.version }} @@ -41,7 +41,7 @@ jobs: name: Documentation runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v7 - uses: julia-actions/julia-buildpkg@latest - uses: julia-actions/julia-docdeploy@latest env: From ed21196006b461043c4123f2b7c0bf21c859363d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Jul 2026 07:36:10 +0000 Subject: [PATCH 2/4] Bump codecov/codecov-action from 6 to 7 Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 6 to 7. - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/codecov/codecov-action/compare/v6...v7) --- updated-dependencies: - dependency-name: codecov/codecov-action dependency-version: '7' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b48ba3d..dae940e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,7 +33,7 @@ jobs: - uses: julia-actions/julia-buildpkg@v1 - uses: julia-actions/julia-runtest@v1 - uses: julia-actions/julia-processcoverage@v1 - - uses: codecov/codecov-action@v6 + - uses: codecov/codecov-action@v7 with: files: lcov.info token: ${{ secrets.CODECOV_TOKEN }} From 82497357e03becdd3a16d67290b85442c553b9c0 Mon Sep 17 00:00:00 2001 From: "Anthony D. Blaom" Date: Tue, 29 Sep 2026 12:10:01 +1300 Subject: [PATCH 3/4] add methods to coerce to Textual --- src/coerce.jl | 4 ++++ src/convention/coerce.jl | 18 ++++++++++++++++++ test/coerce.jl | 1 - test/convention/coerce.jl | 29 ++++++++++++++++------------- 4 files changed, 38 insertions(+), 14 deletions(-) diff --git a/src/coerce.jl b/src/coerce.jl index 6ba40df..847c9bd 100644 --- a/src/coerce.jl +++ b/src/coerce.jl @@ -37,6 +37,10 @@ both the `OldScitype` and `Union{Missing,OldScitype}` cases): where `ColKey = Union{Symbol,AbstractString}`. +When the element type of `X` is `Union{Missing,T}` but no `missing` value is present, it +may be that `Missing` persists in the output element type. To force tightening of the +element type to exclude `Missing`, set `tight=true`. + ### Examples Specifying `column_name=>Scitype` pairs: diff --git a/src/convention/coerce.jl b/src/convention/coerce.jl index f2698f3..7876e45 100644 --- a/src/convention/coerce.jl +++ b/src/convention/coerce.jl @@ -17,6 +17,23 @@ coerce(X::AbstractArray, ::Type{T}; kw...) where {T} = "scientific type. ")) +# ------------------------------------------------------------------------ +# TEXTUAL + +# Arr{T} -> Textual +function coerce( + y::Arr{T}, + T2::Type{<:Union{Missing,Textual}}; + verbosity::Int=1, + tight::Bool=false, + ) where T + y = map(y) do η + ismissing(η) ? η : string(η) + end + _check_eltype(y, T2, verbosity) + return y +end + # ------------------------------------------------------------------------ # FINITE @@ -125,6 +142,7 @@ function coerce(y::Arr{T}, T2::Type{<:Union{Missing,C}}; end ## ARRAY OF ANY + # Note: in the categorical case, we don't care, because we broadcast anyway. # see CArr --> C above. # diff --git a/test/coerce.jl b/test/coerce.jl index 15e7ec4..55706d0 100644 --- a/test/coerce.jl +++ b/test/coerce.jl @@ -2,7 +2,6 @@ X = (x=10:10:44, y=1:4, z=collect("abcd")) @test_throws ScientificTypes.CoercionError coerce(X, :x=>Float64) - @test_throws ScientificTypes.CoercionError coerce(X, :x=>Textual) types = Dict(:x => Continuous, :z => Multiclass) X_coerced = coerce(X, types) diff --git a/test/convention/coerce.jl b/test/convention/coerce.jl index c8036f8..79a2f2b 100644 --- a/test/convention/coerce.jl +++ b/test/convention/coerce.jl @@ -1,14 +1,18 @@ -# ----------------------------------------------------------------------------------------- -############## -## Basic (Behavioural tests) -############## +@testset "coerce arrays" begin -# ---------------------------------------------------------------------------------------------------------------------- -############### -## Detailed Tests -############### + # coercing to Textual and resolution of #193: + y = [1, 2, 3, missing] + yout = @test_logs( + (:info, r"^Trying to"), + coerce(y, Textual) + ) + @test yout[1:3] == ["1", "2", "3"] + @test ismissing(yout[end]) + y = [1, 2, 3] + yout = coerce(y, Textual) + @test yout == ["1", "2", "3"] + @test coerce(yout, Textual) == yout -@testset "coerce arrays" begin A = rand(Int, 2, 3) z = rand(Char, 2, 3) y = Any[1.0 2; 3 4] @@ -16,11 +20,10 @@ @test scitype_union(coerce(A, OrderedFactor)) <: OrderedFactor @test scitype_union(coerce(z, Multiclass)) <: Multiclass @test scitype_union(coerce(y, Count)) === Count - - # test fix for issue 39 + + # test fix for https://github.com/JuliaAI/MLJScientificTypes.jl/issues/39 y = collect(Int64, 1:5) @test_throws ScientificTypes.CoercionError coerce(y, Float64) - @test_throws ScientificTypes.CoercionError coerce(y, Textual) @testset "coersion of Real->OrderedFactor" begin v = [0.1, 0.2, 0.2, 0.3, missing, 0.1] @@ -155,4 +158,4 @@ end c = coerce(x, OrderedFactor, tight=true) @test c == categorical([1,2]) @test !(eltype(c) >: Missing) -end \ No newline at end of file +end From 38ad5a0faaa2861473f47370c8943c2e5e9b5626 Mon Sep 17 00:00:00 2001 From: "Anthony D. Blaom" Date: Tue, 29 Sep 2026 12:26:24 +1300 Subject: [PATCH 4/4] bump 0.3.4 --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 9d6ef17..0a44c48 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "ScientificTypes" uuid = "321657f4-b219-11e9-178b-2701a2544e81" authors = ["Anthony D. Blaom "] -version = "3.3.0" +version = "3.4.0" [deps] CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597"