qml.Configuration

class Configuration(name)[source]

Bases: object

Configuration class.

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

Parameters

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

path

Return the path of the loaded configuration file.

path

Return the path of the loaded configuration file.

Returns

If no configuration is loaded, this returns None.

Return type

str

load(filepath)

Load a configuration file.

safe_get(dct, *keys)

Safely return value from a nested dictionary.

safe_set(dct, value, *keys)

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

save(filepath)

Save a configuration file.

load(filepath)[source]

Load a configuration file.

Parameters

filepath (str) – path to the configuration file.

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.

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.

save(filepath)[source]

Save a configuration file.

Parameters

filepath (str) – path to the configuration file.

Contents

Using PennyLane

Release news

Development

API

Internals