Combined downsample and upsample in sampling.pyx