the-lay / tiler

N-dimensional NumPy array tiling and merging with overlapping, padding and tapering
https://the-lay.github.io/tiler/
MIT License
65 stars 10 forks source link

Automatically preprend ones in tile_shape to match data_shape #18

Closed alisterburt closed 2 years ago

alisterburt commented 2 years ago

This PR automatically expands the dimensionality of tile_shape to match data_shape following numpy broadcasting semantics

e.g. Tiler(data_shape=(128,128,128), tile_shape=(128, 128)). == Tiler(data_shape=(128,128,128), tile_shape=(1, 128, 128)).

the-lay commented 2 years ago

Sorry for taking long to take a look!

1) One concern that I have is that this doesn't actually follow numpy broadcasting in the same way, specifically it doesn't check if two dimensions are equal or one of them is 1. And it shouldn't, since the tile can be bigger than data. I think this can be an error causing place, so I want to add a warning to make sure users notice what is happening there.

2) Another thing is that this adjustment should happen only when tile_shape is given to recalculate, so I moved this adjustment snippet up a bit.

3) I've also changed comments/documentation a bit and took this as an opportunity to update the docs generator :)

Thank you very much for your contribution!