lib.parameter.ParameterCollection¶
- class lib.parameter.ParameterCollection(data=None, parser=None)¶
Bases:
lib.utils.BaseOrderedCollectionClass holding a collection of parameters.
Initialize
ParameterCollection.- Parameters
data (list, tuple, string, dict, ParameterCollection) –
Can be:
string (string) – If not
None, yaml format string to decode. Added on top ofdata.parser (callable, default=yaml_parser) – Function that parses yaml string into a dictionary. Used when
datais string, orstringis notNone.
Methods
Empty collection.
Concatenate input collections.
Return shallow copy of
self.deepcopyExtend collection with
other.Instantiate and initalize class with state dictionary.
Return parameter of name
namein collection.Return index of parameter
name.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 names of parameters (
ParamNameinstances) in collection.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 parameters whose attribute match input values.
Set parameter
paramin collection.Set parameter
paramin collection if not already in it.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(name)¶
Return parameter of name
namein collection.
- index(name)¶
Return index of parameter
name.
- 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(**kwargs)¶
Return new collection, after selection of parameters whose attribute match input values:
collection.select(fixed=True)
returns collection of fixed parameters. If ‘name’ is provided, consider all matching parameters, e.g.:
collection.select(varied=True,name='a_[0:2]')
returns a collection of varied parameters, with name in
['a_0', 'a_1'].
- set(param)¶
Set parameter
paramin collection. If there is already a parameter with same name in collection, replace this stored parameter by the input one. Else, append parameter to collection.
- setdefault(param)¶
Set parameter
paramin collection if not already in it.
- unique(key)¶
Return list of unique attribute
keyof collection items.