Actually, if I am not mistaken you could just drop that variable and use:

```
sample_indices[:-n_remainder]  = ...
```
and 

```
sample_indices[-index:] = ...
```

instead.