BUG: fix index validation in algos.take
- [x] closes #26976
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [ ] whatsnew entry

Remove unused  maybe_to_sparse unrelated.