Minor comment: using `len` works b/c these are 1-D, but may be more numpythonic to check shape instead:

```python
if ids.shape != desired_ids.shape:
    ...
```