Index function refactoring
The current implementations of the index functions contain quite a bit of code duplication, for example in the prepare function for indices with thresholds, or in the selection of numpy/dask pairs for conditions and reducers.
It would be good to reduce this duplication, perhaps using mixin classes or other means of object orientation.