Overflowing indices in `select`
COLLABORATOR
Fixed on master (see https://github.com/huggingface/datasets/pull/3719).
2022-02-18T11:36:41Z
https://github.com/huggingface/datasets/issues/3754#issuecomment-1044380044
https://api.github.com/repos/huggingface/datasets/issues/3754
IC_kwDODunzps4-P_mM
https://api.github.com/repos/huggingface/datasets/issues/comments/1044380044/reactions
2022-02-18T11:36:41Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1044380044
https://avatars.githubusercontent.com/u/47462742?v=4
https://api.github.com/users/mariosasko/events{/privacy}
https://api.github.com/users/mariosasko/followers
https://api.github.com/users/mariosasko/following{/other_user}
https://api.github.com/users/mariosasko/gists{/gist_id}
https://github.com/mariosasko
mariosasko
MDQ6VXNlcjQ3NDYyNzQy
https://api.github.com/users/mariosasko/orgs
https://api.github.com/users/mariosasko/received_events
https://api.github.com/users/mariosasko/repos
https://api.github.com/users/mariosasko/starred{/owner}{/repo}
https://api.github.com/users/mariosasko/subscriptions
User
https://api.github.com/users/mariosasko
public
MEMBER
Awesome, I did not find that one! Thanks.
2022-02-18T11:38:23Z
https://github.com/huggingface/datasets/issues/3754#issuecomment-1044381741
https://api.github.com/repos/huggingface/datasets/issues/3754
IC_kwDODunzps4-QAAt
https://api.github.com/repos/huggingface/datasets/issues/comments/1044381741/reactions
2022-02-18T11:38:23Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1044381741
https://avatars.githubusercontent.com/u/8264887?v=4
https://api.github.com/users/lvwerra/events{/privacy}
https://api.github.com/users/lvwerra/followers
https://api.github.com/users/lvwerra/following{/other_user}
https://api.github.com/users/lvwerra/gists{/gist_id}
https://github.com/lvwerra
lvwerra
MDQ6VXNlcjgyNjQ4ODc=
https://api.github.com/users/lvwerra/orgs
https://api.github.com/users/lvwerra/received_events
https://api.github.com/users/lvwerra/repos
https://api.github.com/users/lvwerra/starred{/owner}{/repo}
https://api.github.com/users/lvwerra/subscriptions
User
https://api.github.com/users/lvwerra
public
## Describe the bug
The `Dataset.select` function seems to accept indices that are larger than the dataset size and seems to effectively use `index %len(ds)`.

## Steps to reproduce the bug
```python
from datasets import Dataset

ds = Dataset.from_dict({"test": [1,2,3]})
ds = ds.select(range(5))

print(ds)
print()
print(ds["test"])
```
Result:
```python
Dataset({
    features: ['test'],
    num_rows: 5
})

[1, 2, 3, 1, 2]
```

This behaviour is not documented and can lead to unexpected behaviour when for example taking a sample larger than the dataset and thus creating a lot of duplicates.

## Expected results
It think this should throw an error or at least a very big warning:
```python
IndexError: Invalid key: 5 is out of bounds for size 3
```

## Environment info
- `datasets` version: 1.18.3
- Platform: macOS-12.0.1-x86_64-i386-64bit
- Python version: 3.9.10
- PyArrow version: 7.0.0