lib.utils.BaseOrderedCollection¶
- class lib.utils.BaseOrderedCollection(items=None)¶
Bases:
lib.utils.BaseClassClass holding an ordered, unique list of items.
Note
When adding a item 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.
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_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 selection of items whose attribute match input values.
Set item in collection.
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.
- 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.
- 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.
- unique(key)¶
Return list of unique attribute
keyof collection items.