amulet.api.partial_3d_array.bounded_partial_3d_array module

class amulet.api.partial_3d_array.BoundedPartial3DArray(dtype, default_value, section_shape, start, stop, step, parent_array)[source]

This class should behave the same as a numpy array in all three axis but the data internally is stored in sections to minimise memory usage. The array has a fixed size in all three axis much like a numpy array.

classmethod from_partial_array(parent_array, start, stop, step)[source]

Create a BoundedPartial3DArray from an UnboundedPartial3DArray and slices.

Parameters
Returns

A new instance of BoundedPartial3DArray that behaves like a view into the parent array.

__init__(dtype, default_value, section_shape, start, stop, step, parent_array)[source]

Construct a BoundedPartial3DArray. This should not be used directly. You should instead use the __getitem__() method of UnboundedPartial3DArray

Parameters
__repr__()[source]

Return repr(self).

__array__(dtype=None)[source]

Get the data contained within as a numpy array.

>>> numpy.array(partial_array)
Parameters

dtype – The dtype of the returned numpy array.

Returns

A numpy array of the contained data.

__eq__(value)[source]

Check equality of this object and another object.

Behaves mostly the same as a numpy array.

>>> bounded_partial_array1 == bounded_partial_array2
Parameters

value – The object to compare to.

Returns

__contains__(item)[source]

Is a section array defined.

>>> 5 in partial_array
True
Parameters

item (int) – The section index to test.

Returns

True if there is an array present for this section. False otherwise

__hash__ = None[source]
__weakref__[source]

list of weak references to the object (if defined)

property default_value: Union[int, bool][source]

The default value to populate undefined sections with. Read Only

property dtype: Type[dtype][source]

The numpy dtype for the arrays. Read Only.

property section_shape: Tuple[int, int, int][source]

The x, y and z size of a section in the original array.

property shape: Tuple[int, Union[int, float], int][source]

The size of the array in the x, y and z axis. Read Only

property size_x: int[source]

The size of the array in the x axis. Read Only

property size_y: Union[int, float][source]

The size of the array in the y axis. Read Only

property size_z: int[source]

The size of the array in the z axis. Read Only

property slice_x: slice[source]

The slice in the x axis into the original array. Read Only

property slice_y: slice[source]

The slice in the y axis into the original array. Read Only

property slice_z: slice[source]

The slice in the z axis into the original array. Read Only

property slices_tuple: Tuple[Tuple[int, int, int], Tuple[int, int, int], Tuple[int, int, int]][source]

The slices data in the x, y and z axis into the original array. Read Only

property start: Tuple[int, int, int][source]

The minimum x, y and z of the slice within the original array. Read Only

property start_x: int[source]

The minimum x value of the slice within the original array. Read Only

property start_y: Optional[int][source]

The minimum y value of the slice within the original array. Read Only

property start_z: int[source]

The minimum z value of the slice within the original array. Read Only

property step: Tuple[int, int, int][source]

The step count of the slice in the x, y and z axis. Read Only

property step_x: int[source]

The step count of the slice in the x axis. Read Only

property step_y: int[source]

The step count of the slice in the y axis. Read Only

property step_z: int[source]

The step count of the slice in the z axis. Read Only

property stop: Tuple[int, int, int][source]

The maximum x value of the slice within the original array. Read Only

property stop_x: int[source]

The maximum x value of the slice within the original array. Read Only

property stop_y: Optional[int][source]

The maximum y value of the slice within the original array. Read Only

property stop_z: int[source]

The maximum z value of the slice within the original array. Read Only

__getitem__(item)[source]

Get a value or sub-section of the unbounded array.

>>> # get the value at a given location
>>> value = partial_array[3, 4, 5]  # an integer
>>> # get a cuboid volume in the array
>>> value = partial_array[2:3, 4:5, 6:7]  # BoundedPartial3DArray
>>> # slice and int can be mixed
>>> value = partial_array[2:3, 4, 6:7]  # BoundedPartial3DArray
Parameters

item – The slices to extract.

Returns

The value or BoundedPartial3DArray viewing into this array.

__setitem__(item, value)[source]

Set a sub-section of the array.

>>> # set the value at a given location
>>> partial_array[3, 4, 5] = 1
>>> # set a cuboid volume in the array
>>> partial_array[2:3, 4:5, 6:7] = 1
>>> # slice and int can be mixed
>>> partial_array[2:3, 4, 6:7] = 1
Parameters
  • slices – The slices or locations that define the volume to set.

  • value – The value to set at the given location. Can be an integer or array.