Repository: JuliaAI/MLJBase.jl
Pull request #676 (2021-11-14 00:52:08)

For a 0.18.25
#668 #670 #674


Patch:
diff --git a/.github/workflows/ci_nightly.yml b/.github/workflows/ci_nightly.yml
index dbb29cdf..61f89e70 100644
--- a/.github/workflows/ci_nightly.yml
+++ b/.github/workflows/ci_nightly.yml
@@ -2,12 +2,12 @@ name: CI (Julia nightly)
 on:
   pull_request:
     branches:
-      - master
-      - dev
+      # - master
+      # - dev
   push:
     branches:
-      - master
-      - dev
+      # - master
+      # - dev
     tags: '*'
 env:
   TEST_MLJBASE: "true"
diff --git a/Project.toml b/Project.toml
index d2590b16..98e422ae 100644
--- a/Project.toml
+++ b/Project.toml
@@ -1,7 +1,7 @@
 name = "MLJBase"
 uuid = "a7f614a8-145f-11e9-1d2a-a57a1082229d"
 authors = ["Anthony D. Blaom <anthony.blaom@gmail.com>"]
-version = "0.18.24"
+version = "0.18.25"
 
 [deps]
 CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597"
diff --git a/src/data/data.jl b/src/data/data.jl
index 049e8eab..f0648bfb 100644
--- a/src/data/data.jl
+++ b/src/data/data.jl
@@ -364,10 +364,6 @@ MLJModelInterface.transform(e::CategoricalPool, arg) =
 
 ## SKIPPING MISSING AND NAN: skipinvalid
 
-const ERR_NOTHING_LEFT_TO_AGGREGATE = ErrorException(
-    "Trying to aggregrate an empty collection of measurements. Perhaps all "*
-    "measuresments are `missing` or `NaN`. ")
-
 _isnan(x) = false
 _isnan(x::Number) = isnan(x)
 
@@ -387,12 +383,9 @@ and `B[i]` are both valid (non-`missing` and non-`NaN`). Can also
 called on other iterators of matching length, such as arrays, but
 always returns a vector. Does not remove `Missing` from the element
 types if present in the original iterators.
+
 """
-@inline function skipinvalid(v)
-    ret = v |> skipmissing |> skipnan
-    isempty(ret) && throw(ERR_NOTHING_LEFT_TO_AGGREGATE)
-    return ret
-end
+skipinvalid(v) = v |> skipmissing |> skipnan
 
 isinvalid(x) = ismissing(x) || _isnan(x)
 
diff --git a/src/utilities.jl b/src/utilities.jl
index 98afc535..7109d034 100644
--- a/src/utilities.jl
+++ b/src/utilities.jl
@@ -226,7 +226,8 @@ end
 Return a "sequence" string from the first `n` elements generated
 by `itr`.
 
-    sequence_string(1:10, 3)
+    julia> MLJBase.sequence_string(1:10, 4)
+    "1, 2, 3, 4, ..."
 
 **Private method.**
 
@@ -238,7 +239,7 @@ function sequence_string(itr::Itr, n=3) where Itr
         I isa Base.HasShape ||
         I isa IsInfinite ||
         throw(Argumenterror("Unsupported iterator. "))
-    vals = typeof(first(itr))[]
+    vals = String[]
     i = 0
     earlystop = false
     for x in itr
@@ -247,7 +248,7 @@ function sequence_string(itr::Itr, n=3) where Itr
             earlystop = true
             break
         else
-            push!(vals, x)
+            push!(vals, string(x))
         end
     end
     ret = join(vals, ", ")


Test patch:
diff --git a/test/measures/measures.jl b/test/measures/measures.jl
index 9f3a3ca0..602c3e78 100644
--- a/test/measures/measures.jl
+++ b/test/measures/measures.jl
@@ -127,7 +127,7 @@ end
     v =[1, 2, missing, 5, NaN]
     @test MLJBase.Sum()(v) == 8
     @test MLJBase.RootMeanSquare()(v) ≈ sqrt((1 + 4 + 25)/3)
-    @test_throws MLJBase.ERR_NOTHING_LEFT_TO_AGGREGATE MLJBase.Mean()(Float32[])
+    @test MLJBase.Mean()(Union{Missing,Float32}[]) |> isnan
 end
 
 end
diff --git a/test/runtests.jl b/test/runtests.jl
index bcf9022e..110fbaba 100644
--- a/test/runtests.jl
+++ b/test/runtests.jl
@@ -46,45 +46,57 @@ print("Loading some models for testing...")
 include_everywhere("_models/models.jl")
 print("\r                                           \r")
 
-@testset "misc" begin
-   @test include("utilities.jl")
-   @test include("static.jl")
+# enable conditional testing of modules by providing test_args
+# e.g. `Pkg.test("MLJBase", test_args=["misc"])`
+RUN_ALL_TESTS = isempty(ARGS)
+macro conditional_testset(name, expr)
+    name = string(name)
+    esc(quote 
+        if RUN_ALL_TESTS || $name in ARGS
+            @testset $name $expr
+        end
+    end)
+end
+
+@conditional_testset "misc" begin
+    @test include("utilities.jl")
+    @test include("static.jl")
 end
 
-@testset "interface" begin
+@conditional_testset "interface" begin
     @test include("interface/interface.jl")
     @test include("interface/data_utils.jl")
 end
 
-@testset "univariate finite" begin
+@conditional_testset "univariate finite" begin
     @test include("univariate_finite/methods.jl")
     @test include("univariate_finite/arrays.jl")
 end
 
-@testset "measures" begin
+@conditional_testset "measures" begin
     @test include("measures/measures.jl")
     @test include("measures/measure_search.jl")
 end
 
-@testset "resampling" begin
+@conditional_testset "resampling" begin
     @test include("resampling.jl")
 end
 
-@testset "data" begin
+@conditional_testset "data" begin
     @test include("data/data.jl")
     @test include("data/datasets.jl")
     @test include("data/datasets_synthetic.jl")
 end
 
-@testset "sources" begin
+@conditional_testset "sources" begin
     @test include("sources.jl")
 end
 
-@testset "machines" begin
+@conditional_testset "machines" begin
     @test include("machines.jl")
 end
 
-@testset "composition - learning_networks" begin
+@conditional_testset "composition_learning_networks" begin
     @test include("composition/learning_networks/nodes.jl")
     @test include("composition/learning_networks/inspection.jl")
     @test include("composition/learning_networks/machines.jl")
@@ -92,7 +104,7 @@ end
         @test include("composition/learning_networks/arrows.jl")
 end
 
-@testset "composition - models" begin
+@conditional_testset "composition_models" begin
     @test include("composition/models/methods.jl")
     @test include("composition/models/from_network.jl")
     @test include("composition/models/inspection.jl")
@@ -102,11 +114,11 @@ end
     @test include("composition/models/static_transformers.jl")
 end
 
-@testset "operations.jl" begin
+@conditional_testset "operations" begin
     @test include("operations.jl")
 end
 
-@testset "hyperparam" begin
+@conditional_testset "hyperparam" begin
     @test include("hyperparam/one_dimensional_ranges.jl")
     @test include("hyperparam/one_dimensional_range_methods.jl")
 end
diff --git a/test/utilities.jl b/test/utilities.jl
index 77c87fff..0f356f01 100644
--- a/test/utilities.jl
+++ b/test/utilities.jl
@@ -134,6 +134,8 @@ end
     @test MLJBase.sequence_string(1:10) == "1, 2, 3, ..."
     @test MLJBase.sequence_string(1:3) == "1, 2, 3"
     @test MLJBase.sequence_string(1:2) == "1, 2"
+    @test MLJBase.sequence_string([sin, cos, tan, asin]) ==
+        "sin, cos, tan, ..."
 end
 
 end # module