Commit 0bb6a46
committed
Accept numpy integers as train_size / test_size in train_test_split
`Dataset.train_test_split()` decides between "number of rows" and "fraction"
with `isinstance(test_size, int)` / `isinstance(test_size, float)`, and rejects
anything else:
ds.train_test_split(test_size=np.int64(2))
# ValueError: Invalid value for test_size: 2 of type <class 'numpy.int64'>
numpy floats are subclasses of `float` so they already work, but numpy integers
are not subclasses of `int`, which makes the behaviour inconsistent for values
that come out of the same numpy computation.
Convert numpy integers to `int` before the checks.1 parent b7cb10b commit 0bb6a46
2 files changed
Lines changed: 18 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5086 | 5086 | | |
5087 | 5087 | | |
5088 | 5088 | | |
| 5089 | + | |
| 5090 | + | |
| 5091 | + | |
| 5092 | + | |
| 5093 | + | |
| 5094 | + | |
| 5095 | + | |
5089 | 5096 | | |
5090 | 5097 | | |
5091 | 5098 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3694 | 3694 | | |
3695 | 3695 | | |
3696 | 3696 | | |
| 3697 | + | |
| 3698 | + | |
| 3699 | + | |
| 3700 | + | |
| 3701 | + | |
| 3702 | + | |
| 3703 | + | |
| 3704 | + | |
| 3705 | + | |
| 3706 | + | |
| 3707 | + | |
3697 | 3708 | | |
3698 | 3709 | | |
3699 | 3710 | | |
| |||
0 commit comments