Rename Slice5D to Interval5D and disallow undefined (slice(None)) axes #12
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Slice5D
was giving the wrong impressions by having all of its axes be nativeslice
s; 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 toInterval5D
, with each of its axes beingTuple[int, int]
instead ofslice
.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 aSlice5D
that had some of its axes set toslice(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 anInterval5D
as well as optional overrides for each axis. These overrides can be aTuple[int, int]
or an instance ofAll
, meaning that the cut is supposed to override that axis of the provided interval will the full size of theArray5D
. The following example cutsmy_array
with intervalmy_interval
, but overridesc
so that the resultingArray5D
has all channels ofmy_array
:Using the opportunity to rename things associated with slices, the "slice backed by data" class
DataSourceSlice
has been renamed toDataRoi
, which is more succinct and probably expresses its concept better.