Skip to content

Rename Slice5D to Interval5D and disallow undefined (slice(None)) axes#12

Draft
Tomaz-Vieira wants to merge 6 commits intoilastik:mainfrom
Tomaz-Vieira:interval5d
Draft

Rename Slice5D to Interval5D and disallow undefined (slice(None)) axes#12
Tomaz-Vieira wants to merge 6 commits intoilastik:mainfrom
Tomaz-Vieira:interval5d

Conversation

@Tomaz-Vieira
Copy link
Copy Markdown
Collaborator

@Tomaz-Vieira Tomaz-Vieira commented Dec 15, 2020

Slice5D was giving the wrong impressions by having all of its axes be native slices; Since it interprets negative indices as "out of bounds to the 'left' " instead of "counting backwards from the end" and does not allow for arbitrary step lengths, it has been renamed to Interval5D, with each of its axes being Tuple[int, int] instead of slice.

Not allowing axes to represent "all" means that a lot of the code is simplified and that all methods are always valid (e.g.: before you couldn't call split() on a Slice5D that had some of its axes set to slice(None)).

This also removes floats from the code, since inf was being used for undefined slices, which are no longer permitted.

To make up for the loss of flexibility, Array5D.cut, Array5D.clamp and other similar methods now take an Interval5D as well as optional overrides for each axis. These overrides can be a Tuple[int, int] or an instance of All, meaning that the cut is supposed to override that axis of the provided interval will the full size of the Array5D. The following example cuts my_array with interval my_interval, but overrides c so that the resulting Array5D has all channels of my_array:

my_array: Array5D = ...
my_interval = Interval5D.zero(x=(10, 20), y=(30, 40), c=1)
piece = my_array.cut(my_interval, c=All())
assert piece.shape.c == my_array.shape.c

Using the opportunity to rename things associated with slices, the "slice backed by data" classDataSourceSlice has been renamed to DataRoi, which is more succinct and probably expresses its concept better.

@Tomaz-Vieira Tomaz-Vieira changed the title Rename Slice5D to Interval5D and disallow undefined (slice(None)) axis Rename Slice5D to Interval5D and disallow undefined (slice(None)) axes Dec 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant