bayesbay.State

class bayesbay.State(param_values=<factory>, temperature=1, cache=<factory>, extra_storage=<factory>)

Data structure that stores a Markov chain state, including all the necessary information to perform the forward operation

Parameters:
  • param_values (Dict[str, Union[ParameterSpaceState, DataNoiseState]]) – dictionary containing parameter values, e.g. {"voronoi": ParameterSpaceState(3, {"voronoi": np.array([1,2,3]), "vs": np.array([4,5,6])}), "rayleigh": DataNoiseState(std=0.01, correlation=None)}

  • temperature (float) – the temperature of the Markov chain associated with this state

  • cache (Dict[str, Any], optional) – cache for storing intermediate results

  • extra_storage (Dict[str, Any], optional) – extra storage that will be saved into results (e.g. when one calls BayesianInversion.get_results())

Raises:

TypeError – when param_values is not a dict

Reference Details

temperature = 1
param_values
cache
extra_storage
copy(keep_dpred=False)

Creates a clone of the current State itself

The following will be (deep-)copied over:

And the following won’t be copied at all:

If keep_dpred is True, then the dpred in cache will be referred to in the new instance. Note that this is not a deep copy, since we assume no changes will be performed on predicted data for a certain state.

Parameters:

keep_dpred (bool, optional) – whether to copy over the predicted data (stored in cache)

Returns:

the clone of self

Return type:

State

get_param_values(param_name)

Get the value(s) of a parameter

Parameters:

param_name (str) – the parameter name (i.e. the key in the param_values dict)

Returns:

the value(s) of the given param_name

Return type:

Union[ParameterSpaceState, DataNoiseState]

items()

Key-value pairs of all the values in the current state, expanding all parameter values, excluding cache

Returns:

the key-value dict pairs of all the attributes

Return type:

dict_items

load_from_cache(name)

Load the cached value for the given name

Parameters:

name (str) – the cache name to look up

Returns:

the cache stored for the given name

Return type:

Any

load_from_extra_storage(name)

Load the extra_storage value for the given name

Parameters:

name (str) – the extra_storage name to look up

Returns:

the extra_storage stored for the given name

Return type:

Any

save_to_cache(name, value)

Store the given value to cache

Parameters:
  • name (str) – the cache name to store

  • value (Any) – the cache value to store

save_to_extra_storage(name, value)

Store the given value to extra_storage

Parameters:
  • name (str) – the extra_storage name to store

  • value (Any) – the extra_storage value to store

saved_in_cache(name)

Indicates whether there is cache value stored for the given name

Parameters:

name (str) – the cache name to look up

Returns:

whether there is cache stored for the given name

Return type:

bool

saved_in_extra_storage(name)

Indicates whether there is an extra_storage value stored for the given name

Parameters:

name (str) – the extra_storage name to look up

Returns:

whether there is extra_storage stored for the given name

Return type:

bool

set_param_values(param_name, values)

Changes the value(s) of a parameter

Parameters:
  • param_name (str) – the parameter name (i.e. the key in the param_values)

  • values (Union[ParameterSpaceState, DataNoiseState]) – the value(s) to be set for the given param_name

back to top