Parameters

class uncertainpy.Parameters(parameters={}, distribution=None)[source]

A collection of parameters.

Has all standard dictionary methods implemented, such as items, value, contains and similar implemented. As such, behaves as an ordered dictionary.

Parameters:
  • parameters ({dict {name: parameter_object}, dict of {name: value or Chaospy distribution}, …], list of Parameter instances, list [[name, value or Chaospy distribution], …], list [[name, value, Chaospy distribution or callable that returns a Chaospy distribution],…],}) – List or dictionary of the parameters that should be created. On the form parameters =

    • {name_1: parameter_object_1, name: parameter_object_2, ...}
    • {name_1:  value_1 or Chaospy distribution, name_2:  value_2 or Chaospy distribution, ...}
    • [parameter_object_1, parameter_object_2, ...],
    • [[name_1, value_1 or Chaospy distribution], ...].
    • [[name_1, value_1, Chaospy distribution or callable that returns a Chaospy distribution], ...]
  • distribution ({None, multivariate Chaospy distribution}, optional) – A multivariate distribution of all parameters, if it exists, it is used instead of individual distributions. Defaults to None.

Variables:
  • parameters (dict) – A dictionary of parameters with name as key and Parameter object as value.
  • distribution ({None, multivariate Chaospy distribution}, optional) – A multivariate distribution of all parameters, if it exists, it is used instead of individual distributions. Defaults to None.

Notes

Both parameter values and parameter distributions must be set if uncertainpy.UncertaintyQuantification.quantify is run with single=True, meaning the uncertainty quantification should be performed with only one uncertain parameter at the time.

__delitem__(name)[source]

Delete parameter with name.

Parameters:name (str) – Name of parameter.
__getitem__(name)[source]

Return Parameter object with name.

Parameters:name (str) – Name of parameter.
Returns:The parameter object with name.
Return type:Parameter object
__iter__()[source]

Iterate over the parameter objects.

Yields:Parameter object – A parameter object.
__len__()[source]

Get the number of parameters.

Returns:The number of parameters.
Return type:int
__setitem__(name, parameter)[source]

Set parameter with name.

Parameters:
  • name (str) – Name of parameter.
  • parameter (Parameter object) – The parameter object of name.
__str__()[source]

Convert all parameters to a readable string.

Returns:A readable string of all parameter objects.
Return type:str
clear() → None. Remove all items from D.
get(attribute=u'name', parameter_names=None)[source]

Return attributes from all parameters.

Return a list of attributes (name, value, or distribution) from each parameters (parameters that have a distribution).

Parameters:
  • attribute ({“name”, “value”, “distribution”}, optional) – The name of the attribute to be returned from each uncertain parameter. Default is name.
  • parameter_names ({None, list, str}, optional) – A list of all parameters of which attribute should be returned, or a string for a single parameter. If None, the attribute all parameters are returned. Default is None.
Returns:

List containing the attribute of each parameters.

Return type:

list

get_from_uncertain(attribute=u'name')[source]

Return attributes from uncertain parameters.

Return a list of attributes (name, value, or distribution) from each uncertain parameters (parameters that have a distribution).

Parameters:attribute ({“name”, “value”, “distribution”}, optional) – The name of the attribute to be returned from each uncertain parameter. Default is name.
Returns:List containing the attribute of each uncertain parameters.
Return type:list
items() → list of D's (key, value) pairs, as 2-tuples
iteritems() → an iterator over the (key, value) items of D
iterkeys() → an iterator over the keys of D
itervalues() → an iterator over the values of D
keys() → list of D's keys
pop(k[, d]) → v, remove specified key and return the corresponding value.

If key is not found, d is returned if given, otherwise KeyError is raised.

popitem() → (k, v), remove and return some (key, value) pair

as a 2-tuple; but raise KeyError if D is empty.

reset_parameter_file(filename)[source]

Set all parameters to their value in a parameter file.

For all parameters, search filename for occurrences of parameter_name = number and replace number with value of that parameter.

Parameters:filename (str) – Name of file.
set_all_distributions(distribution)[source]

Set the distribution of all parameters.

Parameters:distribution ({None, Chaospy distribution, Function that returns a Chaospy distribution}) – The distribution of the parameter.
set_distribution(parameter, distribution)[source]

Set the distribution of a parameter.

Parameters:
  • parameter (str) – Name of parameter.
  • distribution ({None, Chaospy distribution, Function that returns a Chaospy distribution}) – The distribution of the parameter.
set_parameters_file(filename, parameters)[source]

Set listed parameters to their value in a parameter file.

For each parameter listed in parameters, search filename for occurrences of parameter_name = number and replace number with value of that parameter.

Parameters:
  • filename (str) – Name of file.
  • parameters (list) – List of parameter names.
setdefault(k[, d]) → D.get(k,d), also set D[k]=d if k not in D
update([E, ]**F) → None. Update D from mapping/iterable E and F.

If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v

values() → list of D's values