lib.theory.base.ProjectionBasisCollection

class lib.theory.base.ProjectionBasisCollection(items=None)

Bases: cosmopipe.lib.utils.BaseOrderedCollection

Class representing a collection of projection basis.

Note

When adding a basis equal to another already in the collection, the latter will be replaced by the former. Insertion order is conserved.

Initialize BaseOrderedCollection.

Parameters

items (list, object, BaseOrderedCollection) – List of elements to add to the collection. If not list, interpreted as single element. If BaseOrderedCollection instance, update __dict__.

Methods

clear

Empty collection.

concatenate

Concatenate input collections.

copy

Return shallow copy of self.

deepcopy

extend

Extend collection with other.

from_state

Instantiate and initalize class with state dictionary.

get_by_proj

Try to fetch the projection basis that matches the input ProjectionName, by priority order:

index

Return index of item in collection.

is_mpi_broadcast

is_mpi_gathered

is_mpi_root

is_mpi_scattered

load

Load class in numpy binary format from disk.

load_auto

If different formats are possible, this method should between them based on file name extension.

log_critical

log_debug

log_error

log_info

log_warning

modes

Return list of ProjectionBasis.mode.

reorder

Reorder collection following index list indices.

save

Save class to disk.

save_auto

If different formats are possible, this method should between them based on file name extension.

select

Return new collection, after selection of items whose attribute match input values.

set

Set item in collection.

spaces

Return list of ProjectionBasis.space.

unique

Return list of unique attribute key of collection items.

Attributes

logger

mpiattrs

MPI attributes

mpicomm

mpiroot

mpistate

__add__(other)

Addition of two collections is defined as concatenation.

clear()

Empty collection.

classmethod concatenate(*others)

Concatenate input collections. Unique items only are kept.

copy()

Return shallow copy of self.

extend(other)

Extend collection with other. Unique items only are kept.

classmethod from_state(state, mpiroot=0, mpicomm=None)

Instantiate and initalize class with state dictionary.

get_by_proj(*args, **kwargs)

Try to fetch the projection basis that matches the input ProjectionName, by priority order:

Stops as soon as a single match is found. Raises an IndexError if no or several matches are found.

Parameters
  • args (list) – Arguments for ProjectionName.

  • kwargs (dict) – Arguments for ProjectionName.

Returns

basis

Return type

ProjectionBasis

index(item)

Return index of item in collection.

classmethod load(filename, mpiroot=0, mpicomm=None)

Load class in numpy binary format from disk. If the loaded state contains __class__ and that exists in cls._registry, return instance of cls._registry[__class__] (instead of cls).

load_auto(*args, **kwargs)

If different formats are possible, this method should between them based on file name extension.

modes()

Return list of ProjectionBasis.mode.

property mpiattrs

MPI attributes

reorder(indices)

Reorder collection following index list indices.

save(filename)

Save class to disk.

save_auto(*args, **kwargs)

If different formats are possible, this method should between them based on file name extension.

select(*args, **kwargs)

Return new collection, after selection of items whose attribute match input values:

collection.select(name1=value1,name2=value2)

returns collection of items whose attributes name1 and name2` are value1, value2, respectively. Also:

collection.select(dict(name1=value1,name2=value2),dict(name2=value3))

returns collection of items whose attributes name1 and name2` are value1, value2, respectively or attribute name2 is value3.

set(item)

Set item in collection. If already in collection (following criteria defined in item.__eq__), replace this stored item by the input one. Else, append item to collection.

spaces()

Return list of ProjectionBasis.space.

unique(key)

Return list of unique attribute key of collection items.