easyvvuq.utils package

Submodules

easyvvuq.utils.dataset_importer module

easyvvuq.utils.db_benchmark module

easyvvuq.utils.discrete_validation module

Utilities for handling discrete distribution validation in EasyVVUQ.

This module provides enhanced validation capabilities for discrete distributions when used with Stochastic Collocation (SC) and Polynomial Chaos Expansion (PCE) methods.

easyvvuq.utils.discrete_validation.convert_to_integer(value: Any) int | Any[source]

Convert a value to integer if it represents an integer, otherwise return as-is.

Parameters:

value (Any) – The value to convert

Returns:

Integer value if conversion is valid, otherwise the original value

Return type:

Union[int, Any]

easyvvuq.utils.discrete_validation.get_discrete_parameter_info(vary: Dict[str, Any]) Dict[str, bool][source]

Identify which parameters use discrete distributions.

Parameters:

vary (Dict[str, Any]) – Dictionary of parameter names to chaospy distributions

Returns:

Dictionary mapping parameter names to whether they are discrete

Return type:

Dict[str, bool]

easyvvuq.utils.discrete_validation.is_discrete_distribution(distribution) bool[source]

Check if a distribution is discrete.

Parameters:

distribution – A chaospy distribution object

Returns:

True if the distribution is discrete

Return type:

bool

easyvvuq.utils.discrete_validation.is_integer_valued(value: Any) bool[source]

Check if a value represents an integer, even if it’s stored as a float.

This is crucial for handling chaospy output where discrete distributions may return float arrays for numerical consistency with continuous distributions.

Parameters:

value (Any) – The value to check

Returns:

True if the value represents an integer

Return type:

bool

easyvvuq.utils.discrete_validation.process_sampler_output(run_dict: Dict[str, Any], params_spec, vary: Dict[str, Any]) Dict[str, Any][source]

Process sampler output to handle discrete distributions properly.

This function converts float values to integers for parameters that should be integers but were returned as floats by chaospy due to mixed distribution scenarios.

Parameters:
  • run_dict (Dict[str, Any]) – Dictionary of parameter values from the sampler

  • params_spec (ParamsSpecification) – Parameter specification object

  • vary (Dict[str, Any]) – Dictionary of parameter names to chaospy distributions

Returns:

Processed run dictionary with correct types

Return type:

Dict[str, Any]

easyvvuq.utils.discrete_validation.validate_discrete_parameter(value: Any, param_def: Dict[str, Any]) bool[source]

Validate a parameter value for discrete distributions.

This function handles the case where chaospy returns float values for discrete distributions, especially in mixed discrete/continuous scenarios.

Parameters:
  • value (Any) – The parameter value to validate

  • param_def (Dict[str, Any]) – Parameter definition from the campaign

Returns:

True if the value is valid for this parameter

Return type:

bool

easyvvuq.utils.helpers module

easyvvuq.utils.helpers.easyvvuq_deserialize(s)[source]

Takes a serialized objected and reconstructs it.

Parameters:

s (str) – A serialized Python object.

Returns:

A previously serialized Python object.

Return type:

obj

easyvvuq.utils.helpers.easyvvuq_serialize(obj)[source]

Takes an object and returns a string with that object serialized.

Parameters:

obj (obj) – An arbitrary Python object.

Returns:

A string representation of obj.

Return type:

str

easyvvuq.utils.helpers.multi_index_tuple_parser(lst)[source]

Parses a list of strings to tuples if they represent tuples, otherwise leaves them as is.

Parameters:

lst (list of strings)

Returns:

  • a tuple consisting of a list of tuples and/or strings and a bool indicating if

  • the lst contains any tuples

easyvvuq.utils.helpers.remove_start_of_file(filename, delimiter)[source]

Overwrite a file leaving only the portion of it after the delimiter string.

Parameters:
  • filename (str) – the name (and path) of the file to processs

  • delimiter (str) – the string after which the file is copied over

Module contents