NDCollection#

class ndcube.NDCollection(key_data_pairs, aligned_axes=None, meta=None, **kwargs)[source]#

Bases: dict

Class for holding and manipulating an unordered collection of NDCubes or NDCubeSequences.

Parameters:
  • data (sequence of tuple of (str, NDCube or NDCubeSequence)) – The names and data cubes/sequences to held in the collection.

  • aligned_axes (tuple of int, tuple of tuple of int, ‘all’, or None, optional) – Axes of each cube/sequence that are aligned in numpy order. If elements are int, then the same axis numbers in all cubes/sequences are aligned. If elements are tuples of ints, then there must be one tuple for every cube/sequence. Each element of each tuple gives the axes of each cube/sequence that are aligned. If ‘all’, all axes are aligned in natural order, i.e. the 0th axes of all cubes are aligned, as are the 1st, and so on. Default is None.

  • meta (dict, optional) – General metadata for the overall collection.

Example

Say the collection holds two NDCubes, each of 3 dimensions.

>>> aligned_axes = (1, 2)  

means that axis 1 (0-based counting) of cube0 is aligned with axis 1 of cube1, and axis 2 of cube0 is aligned with axis 2 of cube1. However, if

>>> aligned_axes = ((0, 1), (2, 1))  

then the first tuple corresponds to cube0 and the second with cube1. This is interpreted as axis 0 of cube0 is aligned with axis 2 of cube1 while axis 1 of cube0 is aligned with axis 1 of cube1.

Attributes Summary

aligned_axes

The axes of each array that are aligned in numpy order.

aligned_axis_physical_types

The physical types common to all members that are associated with each aligned axis.

aligned_dimensions

The lengths of all aligned axes.

Methods Summary

clear()

copy()

fromkeys([value])

Create a new dictionary with keys from iterable and values set to value.

get(key[, default])

Return the value for key if key is in the dictionary, else default.

items()

keys()

pop(key)

Remove a member from the NDCollection and return it.

popitem()

Not supported by NDCollection

setdefault()

Not supported by NDCollection

update(*args)

Merges a new collection with current one replacing objects with common keys.

values()

Attributes Documentation

aligned_axes#

The axes of each array that are aligned in numpy order.

aligned_axis_physical_types#

The physical types common to all members that are associated with each aligned axis.

One tuple is returned for each axis as there can be more than one physical type associated with an aligned axis. If there are no physical types associated with an aligned that is common to all collection members, an empty tuple is returned for that axis.

aligned_dimensions#

The lengths of all aligned axes.

If there are no aligned axes, returns None.

Methods Documentation

clear() None.  Remove all items from D.#
copy() a shallow copy of D[source]#
fromkeys(value=None, /)#

Create a new dictionary with keys from iterable and values set to value.

get(key, default=None, /)#

Return the value for key if key is in the dictionary, else default.

items() a set-like object providing a view on D's items#
keys() a set-like object providing a view on D's keys#
pop(key)[source]#

Remove a member from the NDCollection and return it.

Parameters:

key (str) – The name of the member to remove and return.

popitem()[source]#

Not supported by NDCollection

setdefault()[source]#

Not supported by NDCollection

update(*args)[source]#

Merges a new collection with current one replacing objects with common keys.

Takes either a single input (NDCollection) or two inputs (sequence of key/value pairs and aligned axes associated with each key/value pair.

values() an object providing a view on D's values#