SciTools / biggus

:no_entry: [DEPRECATED] Virtual large arrays and lazy evaluation.
http://biggus.readthedocs.io/
GNU Lesser General Public License v3.0
54 stars 27 forks source link

User-defined per-slice operations #70

Closed rhattersley closed 7 years ago

rhattersley commented 10 years ago

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.

rhattersley commented 10 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.

pelson commented 9 years ago

cc @bjlittle.