Closed rhattersley closed 7 years ago
Suggested syntax (using an arbitrary step & trim operation as an example):
class MyArray(biggus.SliceTransformArray):
def validate(self, array, axes):
assert len(axes) == 2
def transform_affected_shape(self, src_shape_subset):
return (src_shape_subset[0] + 1) // 2,
src_shape_subset[1] - 2)
def transform_data(self, data):
return data[::2, 1:-1]
With the usage being:
>>> a = biggus.zeros((21, 500, 70, 768, 1024))
>>> MyArray(a, axes=[3, 1])
<Array shape=(21, 498, 70, 384, 1024) dtype=dtype('float64')>
Note: neither of the user-provided transform methods have to deal with dimension ordering.
cc @bjlittle.
Provide a relatively simple way for end-users to define their own transformations which need to operate on one or more complete dimensions.
For example, a filtering or regridding algorithm which operates on a 2D slice.