Improve numpy array filtering

- only allocate an index buffer instead of a full ndarray
- works for assignment too
- now pass the periodic_dist test case