lib.theory.base.ModelCollection

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

Bases: cosmopipe.lib.utils.BaseOrderedCollection

Class representing a collection of models.

Note

When adding a model with same ProjectionBasis than 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

bases

Return model bases as ProjectionBasisCollection.

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

Return model with ProjectionBasis basis.

get_by_proj

Return model corresponding to ProjectionName.

index

Return index of model with ProjectionBasis basis.

is_mpi_broadcast

is_mpi_gathered

is_mpi_root

is_mpi_scattered

items

Yield tuples of model basis and model.

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

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 basis selection.

set

Set input model (with basis attribute).

unique

Return list of unique attribute key of collection items.

Attributes

logger

models

Return models.

mpiattrs

MPI attributes

mpicomm

mpiroot

mpistate

__add__(other)

Addition of two collections is defined as concatenation.

bases()

Return model bases as ProjectionBasisCollection.

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(basis)

Return model with ProjectionBasis basis.

get_by_proj(*args, **kwargs)

Return model corresponding to ProjectionName. Same arguments as ProjectionBasisCollection.get_by_proj().

index(basis)

Return index of model with ProjectionBasis basis.

items()

Yield tuples of model basis and model.

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.

property models

Return models.

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 basis selection. Same arguments (ProjectionBasis attributes) as ProjectionBasisCollection.select().

set(model)

Set input model (with basis attribute).

unique(key)

Return list of unique attribute key of collection items.