lib.theory.base.ModelCollection¶
- class lib.theory.base.ModelCollection(items=None)¶
Bases:
cosmopipe.lib.utils.BaseOrderedCollectionClass representing a collection of models.
Note
When adding a model with same
ProjectionBasisthan 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
BaseOrderedCollectioninstance, update__dict__.
Methods
Return model bases as
ProjectionBasisCollection.Empty collection.
Concatenate input collections.
Return shallow copy of
self.deepcopyExtend collection with
other.Instantiate and initalize class with state dictionary.
Return model with
ProjectionBasisbasis.Return model corresponding to
ProjectionName.Return index of model with
ProjectionBasisbasis.is_mpi_broadcastis_mpi_gatheredis_mpi_rootis_mpi_scatteredYield tuples of model basis and model.
Load class in numpy binary format from disk.
If different formats are possible, this method should between them based on file name extension.
log_criticallog_debuglog_errorlog_infolog_warningReorder collection following index list
indices.Save class to disk.
If different formats are possible, this method should between them based on file name extension.
Return new collection, after basis selection.
Set input model (with
basisattribute).Return list of unique attribute
keyof collection items.Attributes
loggerReturn models.
MPI attributes
mpicommmpirootmpistate- __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
ProjectionBasisbasis.
- get_by_proj(*args, **kwargs)¶
Return model corresponding to
ProjectionName. Same arguments asProjectionBasisCollection.get_by_proj().
- index(basis)¶
Return index of model with
ProjectionBasisbasis.
- 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 incls._registry, return instance ofcls._registry[__class__](instead ofcls).
- 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 (
ProjectionBasisattributes) asProjectionBasisCollection.select().
- set(model)¶
Set input model (with
basisattribute).
- unique(key)¶
Return list of unique attribute
keyof collection items.