cf.Partition

class cf.Partition(**kwargs)[source]

Bases: object

A partition of a partition matrix.

Initialization

Parameters :
subarray : numpy array-like, optional

The sub-array for the partition. Must be a numpy array or any array storing object with a similar interface.

directions : dict or bool, optional

The direction of each dimension of the partition’s sub-array. It is a boolean if the partition’s sub-array is a scalar array, otherwise it is a dictionary keyed by the dimensions’ identities as found in dimensions.

location : list, optional

The location of the partition’s data array in the master array.

dimensions : list, optional

The identities of the dimensions of the partition’s sub-array. If the partition’s sub-array a scalar array then it is an empty list.

part : list, optional

The part of the partition’s sub-array which comprises its data array. If the partition’s data array is to the whole sub-array then part may be an empty list.

shape : list, optional

The shape of the partition’s data array as a subspace of the master array. If the master array is a scalar array then shape is an empty list. By default the shape is inferred from location.

Units : Units, optional

The units of the partition’s sub-array.

Examples

>>> p = Partition(subarray   = numpy.arange(20).reshape(2,5,1),
...               directions = {'dim0', True, 'dim1': False, 'dim2': True},
...               location   = [(0, 6), (1, 3), (4, 5)],
...               dimensions = ['dim1', 'dim0', 'dim2'],
...               part       = [],
...               Units      = cf.Units('K'))
>>> p = Partition(subarray       = numpy.arange(20).reshape(2,5,1),
...               directions = {'dim0', True, 'dim1': False, 'dim2': True},
...               location   = [(0, 6), (1, 3), (4, 5)],
...               dimensions = ['dim1', 'dim0', 'dim2'],
...               shape      = [5, 2, 1],
...               part       = [slice(None, None, -1), [0,1,3,4], slice(None)],
...               Units      = cf.Units('K'))
>>> p = Partition(subarray       = numpy.array(4),
...               directions = True,
...               location   = [(4, 5)],
...               dimensions = ['dim1'],
...               part       = [],
...               Units      = cf.Units('K'))

Partition attributes

_original
_save
dimensions
directions
in_memory True if and only if the partition’s sub-array is in memory as opposed to on disk.
indices The indices of the master array which correspond to this partition’s data array.
isscalar True if and only if the partition’s data array and sub-array are both a scalar arrays.
location
on_disk True if and only if the partition’s sub-array is on disk as opposed to in memory.
part
shape
size Number of elements in the partition’s data array.
subarray

Partition methods

change_dimension_names asdasdasdasds
close Close the partition after it has been conformed.
copy Return a deep copy.
dataarray Returns the partition’s data array.
file_close Close all file containing the sub-array, if there is one.
flat Return an iterator that yields the partition itself.
iterarray_indices Return an iterator over indices of the partition’s data array.
itermaster_indices Return an iterator over indices of the master array which are spanned by the conformed array.
new_part Return the part attribute updated for new indices of the master array.
to_disk Store the partition’s sub-array in a temporary file on disk in place.
update_from Completely update the partition with another partition’s attributes in place.

Table Of Contents

Previous topic

cf.FieldList.unsqueeze

Next topic

cf.Partition._original

This Page