`Dataset.unique` showing wrong output after filtering
COLLABORATOR
Hi! It seems like `flatten_indices` (called in `unique`) doesn't know how to handle empty indices mappings. I'm working on the fix.
2022-09-29T15:25:26Z
https://github.com/huggingface/datasets/issues/5038#issuecomment-1262441807
https://api.github.com/repos/huggingface/datasets/issues/5038
IC_kwDODunzps5LP1VP
https://api.github.com/repos/huggingface/datasets/issues/comments/1262441807/reactions
2022-09-29T15:25:26Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1262441807
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
CONTRIBUTOR
Thanks, that was fast!
2022-09-29T16:28:48Z
https://github.com/huggingface/datasets/issues/5038#issuecomment-1262520388
https://api.github.com/repos/huggingface/datasets/issues/5038
IC_kwDODunzps5LQIhE
https://api.github.com/repos/huggingface/datasets/issues/comments/1262520388/reactions
2022-09-29T16:28:48Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1262520388
https://avatars.githubusercontent.com/u/4904985?v=4
https://api.github.com/users/mxschmdt/events{/privacy}
https://api.github.com/users/mxschmdt/followers
https://api.github.com/users/mxschmdt/following{/other_user}
https://api.github.com/users/mxschmdt/gists{/gist_id}
https://github.com/mxschmdt
mxschmdt
MDQ6VXNlcjQ5MDQ5ODU=
https://api.github.com/users/mxschmdt/orgs
https://api.github.com/users/mxschmdt/received_events
https://api.github.com/users/mxschmdt/repos
https://api.github.com/users/mxschmdt/starred{/owner}{/repo}
https://api.github.com/users/mxschmdt/subscriptions
User
https://api.github.com/users/mxschmdt
public
## Describe the bug
After filtering a dataset, and if no samples remain, `Dataset.unique` will return the unique values of the unfiltered dataset.

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

dataset = Dataset.from_dict({'id': [0]})
dataset = dataset.filter(lambda _: False)
print(dataset.unique('id'))
```

## Expected results
The above code should return an empty list since the dataset is empty.

## Actual results
```bash
[0]
```

## Environment info
- `datasets` version: 2.5.1
- Platform: Linux-5.18.19-100.fc35.x86_64-x86_64-with-glibc2.34
- Python version: 3.9.14
- PyArrow version: 7.0.0
- Pandas version: 1.3.5