array icon indicating copy to clipboard operation
array copied to clipboard

Cropping via ranges results in an array with the same indices as the old array

Open dsharlet opened this issue 5 years ago • 1 comments

In numpy and many other systems, b = a(interval(5, 12)) results in an array where b(x) == a(x + 5) and b has an extent of 7 (and a min of 0).

In array, this doesn't happen. b(x) == a(x), where b has a min of x.min() + 5 and an extent of 7. The only other system that is similar that I'm aware of is Halide.

This is very convenient for tiling algorithms transparently, but may not be what people would prefer to see in other use cases.

I lean towards the current behavior (which enables transparent tiling of algorithms), but it would be good to find a way to seamlessly enable the numpy style as well.

dsharlet avatar Jul 07 '20 03:07 dsharlet

I wonder if you can make operator()(interval i) a template template <enum CropBehavior> operator()(interval i).

jiawen avatar Dec 21 '22 17:12 jiawen