Configuration

Module: pennylane

class Configuration(name)[source]

Configuration class.

This class is responsible for loading, saving, and storing PennyLane and plugin/device configurations.

Parameters:
  • name (str) – filename of the configuration file.
  • should be a valid TOML file. You may also pass an absolute (This) –
  • a relative file path to the configuration file. (or) –
path

Return the path of the loaded configuration file.

Returns:If no configuration is loaded, this returns None.
Return type:str
load(filepath)[source]

Load a configuration file.

Parameters:filepath (str) – path to the configuration file.
save(filepath)[source]

Save a configuration file.

Parameters:filepath (str) – path to the configuration file.
static safe_set(dct, value, *keys)[source]

Safely set the value of a key from a nested dictionary.

If any key provided does not exist, a dictionary containing the remaining keys is dynamically created and set to the required value.

Parameters:
  • dct (dict) – the dictionary to set the value of.
  • value – the value to set. Can be any valid type.
  • *keys – each additional argument corresponds to a nested key.
static safe_get(dct, *keys)[source]

Safely return value from a nested dictionary.

If any key provided does not exist, an empty dictionary is returned.

Parameters:
  • dct (dict) – the dictionary to set the value of.
  • *keys – each additional argument corresponds to a nested key.
Returns:

value corresponding to dct[keys[0]][keys[1]] etc.