|
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 | + NTuple{<:Any,TrainTestPair}, |
| 7 | + AbstractVector{<:TrainTestPair}, |
| 8 | +} |
6 | 9 |
|
7 | 10 |
|
8 | 11 | # # ERROR MESSAGES
|
@@ -93,6 +96,13 @@ 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 | + |
96 | 106 | # ==================================================================
|
97 | 107 | ## RESAMPLING STRATEGIES
|
98 | 108 |
|
@@ -1402,10 +1412,6 @@ end
|
1402 | 1412 | # ------------------------------------------------------------
|
1403 | 1413 | # Core `evaluation` method, operating on train-test pairs
|
1404 | 1414 |
|
1405 |
| -const AbstractRow = Union{AbstractVector{<:Integer}, Colon} |
1406 |
| -const TrainTestPair = Tuple{AbstractRow, AbstractRow} |
1407 |
| -const TrainTestPairs = AbstractVector{<:TrainTestPair} |
1408 |
| - |
1409 | 1415 | _view(::Nothing, rows) = nothing
|
1410 | 1416 | _view(weights, rows) = view(weights, rows)
|
1411 | 1417 |
|
@@ -1434,11 +1440,7 @@ function evaluate!(
|
1434 | 1440 | # Note: `rows` and `repeats` are only passed to the final `PeformanceEvaluation`
|
1435 | 1441 | # object to be returned and are not otherwise used here.
|
1436 | 1442 |
|
1437 |
| - if !(resampling isa TrainTestPairs) |
1438 |
| - error("`resampling` must be an "* |
1439 |
| - "`MLJ.ResamplingStrategy` or tuple of rows "* |
1440 |
| - "of the form `(train_rows, test_rows)`") |
1441 |
| - end |
| 1443 | + resampling isa TrainTestPairs || throw(ERR_BAD_RESAMPLING_OPTION) |
1442 | 1444 |
|
1443 | 1445 | X = mach.args[1]()
|
1444 | 1446 | y = mach.args[2]()
|
|
0 commit comments