lib.theory.base.ProjectionBasisCollection¶
- class lib.theory.base.ProjectionBasisCollection(items=None)¶
Bases:
cosmopipe.lib.utils.BaseOrderedCollectionClass 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
BaseOrderedCollectioninstance, update__dict__.
Methods
Empty collection.
Concatenate input collections.
Return shallow copy of
self.deepcopyExtend collection with
other.Instantiate and initalize class with state dictionary.
Try to fetch the projection basis that matches the input
ProjectionName, by priority order:Return index of
itemin collection.is_mpi_broadcastis_mpi_gatheredis_mpi_rootis_mpi_scatteredLoad 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_warningReturn list of
ProjectionBasis.mode.Reorder 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 selection of items whose attribute match input values.
Set item in collection.
Return list of
ProjectionBasis.space.Return list of unique attribute
keyof collection items.Attributes
loggerMPI attributes
mpicommmpirootmpistate- __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:same
ProjectionBasis.namesame
ProjectionBasis.mode
Stops as soon as a single match is found. Raises an
IndexErrorif no or several matches are found.- Parameters
args (list) – Arguments for
ProjectionName.kwargs (dict) – Arguments for
ProjectionName.
- Returns
basis
- Return type
- index(item)¶
Return index of
itemin 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 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.
- 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
name1and name2` arevalue1,value2, respectively. Also:collection.select(dict(name1=value1,name2=value2),dict(name2=value3))
returns collection of items whose attributes
name1and name2` arevalue1,value2, respectively or attributename2isvalue3.
- 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
keyof collection items.