metasyn.config

Module defining configuration classes for creating MetaFrames.

Classes

MetaConfig(var_specs, plugins[, defaults, ...])

Configuration class for creating MetaFrames.

VarSpecAccess(var_spec, meta_config)

Access for variable configuration object.

class metasyn.config.MetaConfig(var_specs, plugins, defaults=None, n_rows=None, file_config=None, config_version='1.2')

Bases: object

Configuration class for creating MetaFrames.

This class is used to create, manipulate, and retrieve configurations for individual variables in a MetaFrame. It also provides methods for loading configurations from .toml files and converting them to dictionaries.

Parameters:
  • var_specs (Union[list[dict], list[VarSpec]]) – List of configurations for individual variables. The order does not matter for variables that are found in the DataFrame, but in the case of variables that are data-free, the order is also the order of columns for the eventual synthesized dataframe. See the VarSpecAccess class on how the dictionary can be constructed.

  • plugins (Union[DistributionRegistry, list[str], str, None]) – Plugins to use when fitting distributions to variables.

  • privacy – Privacy method/level to use as a default setting for the privacy. Can be overridden in the var_spec for a particular column.

  • n_rows (Optional[int]) – Number of rows for synthesization at a later stage. Can be unspecified by leaving the value at None.

  • defaults (Optional[dict])

  • file_config (Optional[dict])

  • config_version (str)

property plugins: DistributionRegistry

Return the plugin list to be used for creating the metaframe.

classmethod from_toml(config_fp)

Create a MetaConfig class from a .toml file.

Parameters:

config_fp (Union[str, Path]) – Path to the file containing the configuration.

Returns:

A fully initialized MetaConfig instance.

Return type:

meta_config

to_dict()

Convert the configuration to a dictionary.

Returns:

Configuration in dictionary form.

Return type:

config_dict

get(name)

Create a VarSpecAccess object pointing to a var with that name.

If the variable does not exist, then a new variable config is created that has the default values.

Parameters:

name (str) – Name of the variable configuration to retrieve.

Returns:

A variable config access object.

Return type:

var_spec

iter_var(exclude=None)

Iterate over all variables in the configuration.

Parameters:

exclude (Optional[list[str]]) – Exclude variables with names in that list.

Returns:

VarSpecAccess class for each of the available variable configurations.

Return type:

var_spec

class metasyn.config.VarSpecAccess(var_spec, meta_config)

Bases: object

Access for variable configuration object.

They take into account what the defaults are from the MetaConfig object. Otherwise they pass through all the attributes as normal and thus behave exactly as a variable config object themselves.

Parameters:
  • var_spec (VarSpec) – The variable configuration to access.

  • meta_config (MetaConfig) – The meta configuration instance to get default values from.