chunkblocks.global_offset_array

Module Contents

chunkblocks.global_offset_array.OUT = out
class chunkblocks.global_offset_array.GlobalOffsetArray[source]

Bases:numpy.ndarray, numpy.lib.mixins.NDArrayOperatorsMixin

A simple VIEW CAST of a given ndarray that is addressed via global coordinates. Negative wraparound indices are NOT supported (i.e. used for printing out) and will IGNORE indices out of bounds

See below link for explanations of __new__ and __array_finalize__! https://docs.scipy.org/doc/numpy/user/basics.subclassing.html#slightly-more-realistic-example-attribute-added-to-existing-array

_HANDLED_TYPES
classmethod __new__(cls, input_array, global_offset=None, *args, **kwargs)[source]
__array_finalize__(self, obj)[source]

Called whenever the array is new-ed. Because unpickling does NOT call __array_finalize__, make sure they are equivalent

__reduce__(self)[source]
__setstate__(self, state)[source]

Called when unpickling. Because unpickling does NOT call __array_finalize__, make sure they are equivalent

_to_internal_slices(self, index)[source]

Convert given index into the index used in the internal ndarray. Does NOT support end slicing and wrap around negative indices. Throw an error if computed internal indices are outside the range of the data.

__getitem__(self, index)[source]

Access the array based on global coordinates. If we receive a tuple, it means we are slicing. When we slice, calculate the actual coordinates stored

__setitem__(self, index, value)[source]

Access the array based on global coordinates. If we receive a tuple, it means we are slicing. When we slice, calculate the actual coordinates stored

__str__(self)[source]

Overwrite string conversion to create a view instead of calling super. Super will call with the overridden __getitem__ function which will not work

__repr__(self)[source]

Overwrite string conversion to create a view instead of calling super. Super will call with the overridden __getitem__ function which will not work

bounds(self)[source]

Get slices that are bounds of the available data

calculate_bounds(self)[source]
is_contained_within(self, other)[source]

Check to see if this volume is contained within other

__array_ufunc__(self, ufunc, method, *inputs, **kwargs)[source]

Enable injection of customized indexing for ufunc operations Must defer to the implementation of the ufunc on unwrapped values to avoid infinite loop https://docs.scipy.org/doc/numpy-1.14.0/reference/generated/numpy.lib.mixins.NDArrayOperatorsMixin.html

Standard operators work normally when:
  • global offset and size are the same for both operands
  • one oeprand is fully encapsulated by another (returns a copy of the larger with the smaller added)
In-place operators work normally when: