Working with the Configuration

The pseudopeople configuration contains a very large number of settings. It may be easier in some situations to interact with the configuration programmatically in Python, rather than by creating a configuration dictionary or YAML file by hand. For example, if you wanted to double the cell probability parameter of every noise type in every column, or set all noise types to zero except one to isolate the effect of a specific type of noise, it would be easier to access the defaults as a data structure in Python and modify them that way.

We currently have one function that facilitates this kind of use of the configuration, shown below. We may add more functionality in this area in a future release of pseudopeople.

pseudopeople.get_config(overrides=None)[source]

Function that returns the pseudopeople configuration containing all default values. To get the default probability of nonresponse in the Decennial Census dataset:

>>> import pseudopeople as psp
>>> psp.get_config()['decennial_census']['row_noise']['do_not_respond']
{'row_probability': 0.0145}

To view that same part of the configuration after applying a user override:

>>> overrides = {'decennial_census': {'row_noise': {'do_not_respond': {'row_probability': 0.1}}}}
>>> psp.get_config(overrides)['decenial_census']['row_noise']['do_not_respond']
{'row_probability': 0.1}
Parameters:

overrides (Path | str | Dict) – An optional set of overrides to the default configuration. Can be a (nested) Python dictionary mapping noise type parameters to the desired override values, a path to a YAML file with the same nested structure (see the configuration structure section of the documentation for details), or the special sentinel value pseudopeople.NO_NOISE, which will return a configuration in which all configurable noise is set to zero. When passing a dictionary or YAML file, it is not necessary to provide a complete configuration; any configuration parameters not specified in overrides will be filled in with the default values.

Returns:

A complete configuration dictionary.

Raises:

ConfigurationError – An invalid configuration is passed with overrides.

Return type:

Dict