|
1 |
| -# TYPE ALIASES |
| 1 | +# # LOCAL TYPE ALIASES |
2 | 2 |
|
3 | 3 | const AbstractRow = Union{AbstractVector{<:Integer}, Colon}
|
4 |
| -const TrainTestPair = Tuple{AbstractRow,AbstractRow} |
5 |
| -const TrainTestPairs = AbstractVector{<:TrainTestPair} |
| 4 | +const TrainTestPair = Tuple{AbstractRow, AbstractRow} |
| 5 | +const TrainTestPairs = Union{ |
| 6 | + Tuple{Vararg{TrainTestPair}}, |
| 7 | + AbstractVector{<:TrainTestPair}, |
| 8 | +} |
6 | 9 |
|
7 | 10 |
|
8 | 11 | # # ERROR MESSAGES
|
@@ -93,6 +96,19 @@ const ERR_NEED_TARGET = ArgumentError(
|
93 | 96 | """
|
94 | 97 | )
|
95 | 98 |
|
| 99 | +const ERR_BAD_RESAMPLING_OPTION = ArgumentError( |
| 100 | + "`resampling` must be an "* |
| 101 | + "`MLJ.ResamplingStrategy` or a vector (or tuple) of tuples "* |
| 102 | + "of the form `(train_rows, test_rows)`" |
| 103 | +) |
| 104 | + |
| 105 | +const ERR_EMPTY_RESAMPLING_OPTION = ArgumentError( |
| 106 | + "`resampling` cannot be emtpy. It must be an "* |
| 107 | + "`MLJ.ResamplingStrategy` or a vector (or tuple) of tuples "* |
| 108 | + "of the form `(train_rows, test_rows)`" |
| 109 | +) |
| 110 | + |
| 111 | + |
96 | 112 | # ==================================================================
|
97 | 113 | ## RESAMPLING STRATEGIES
|
98 | 114 |
|
@@ -1402,10 +1418,6 @@ end
|
1402 | 1418 | # ------------------------------------------------------------
|
1403 | 1419 | # Core `evaluation` method, operating on train-test pairs
|
1404 | 1420 |
|
1405 |
| -const AbstractRow = Union{AbstractVector{<:Integer}, Colon} |
1406 |
| -const TrainTestPair = Tuple{AbstractRow, AbstractRow} |
1407 |
| -const TrainTestPairs = AbstractVector{<:TrainTestPair} |
1408 |
| - |
1409 | 1421 | _view(::Nothing, rows) = nothing
|
1410 | 1422 | _view(weights, rows) = view(weights, rows)
|
1411 | 1423 |
|
@@ -1434,11 +1446,8 @@ function evaluate!(
|
1434 | 1446 | # Note: `rows` and `repeats` are only passed to the final `PeformanceEvaluation`
|
1435 | 1447 | # object to be returned and are not otherwise used here.
|
1436 | 1448 |
|
1437 |
| - if !(resampling isa TrainTestPairs) |
1438 |
| - error("`resampling` must be an "* |
1439 |
| - "`MLJ.ResamplingStrategy` or an vector tuples "* |
1440 |
| - "of the form `(train_rows, test_rows)`") |
1441 |
| - end |
| 1449 | + isempty(resampling) && throw(ERR_EMPTY_RESAMPLING_OPTION) |
| 1450 | + resampling isa TrainTestPairs || throw(ERR_BAD_RESAMPLING_OPTION) |
1442 | 1451 |
|
1443 | 1452 | X = mach.args[1]()
|
1444 | 1453 | y = mach.args[2]()
|
|
0 commit comments