Settings Package

Class CoreSettingsService from the package pyzeal_settings. This module defines a protocol for a generic settings provider pertaining to the core features of PyZEAL.

Authors:

  • Philipp Schuette

class pyzeal.settings.core_settings_service.CoreSettingsService(*args, **kwargs)[source]

Class providing a layer of abstraction for storage and retrieval of PyZEAL core settings. Concrete SettingService implementations can choose freely their data model and persistence layer.

__init__(*args, **kwargs)
property defaultAlgorithm: AlgorithmTypes

Get the default algorithm type.

Returns:

Default algorithm type.

property defaultContainer: ContainerTypes

Get the default container type.

Returns:

Default container type

property defaultEstimator: EstimatorTypes

Get the default estimator type.

Returns:

Default estimator type.

Class SettingsService from the package pyzeal_settings. This module defines a protocol for a generic settings provider.

Authors:

  • Philipp Schuette

class pyzeal.settings.settings_service.SettingsService(*args, **kwargs)[source]

Class providing a layer of abstraction for storage and retrieval of PyZEAL related settings. Concrete SettingService implementations can choose freely their data model and persistence layer.

property logLevel: LogLevel

Get the current LogLevel setting.

Returns:

Current LogLevel

property precision: Tuple[int, int]

Get current precision level as a negative exponent, i.e. a precision of 10^(-3), in real and imaginary parts respectively, corresponds to a precision level of (3, 3).

Returns:

Current precision level

property verbose: bool

Get current verbosity setting.

Returns:

True if verbose mode is enabled.

A simple in-memory implementation of the SettingsService interface. Instances of this service do not persist settings beyond program runtime. Their main use is during testing of components which depend on settings.

Authors:

  • Philipp Schuette

class pyzeal.settings.ram_settings_service.RAMSettingsService(container=ContainerTypes.ROUNDING_CONTAINER, algorithm=AlgorithmTypes.SIMPLE_ARGUMENT, estimator=EstimatorTypes.SUMMATION_ESTIMATOR, logLevel=LogLevel.NOTSET, precision=(0, 0), verbose=False)[source]

Simple, non-persistent implementation of SettingsService.

__init__(container=ContainerTypes.ROUNDING_CONTAINER, algorithm=AlgorithmTypes.SIMPLE_ARGUMENT, estimator=EstimatorTypes.SUMMATION_ESTIMATOR, logLevel=LogLevel.NOTSET, precision=(0, 0), verbose=False)[source]

Initialize a new in-memory settings service with given default values.

:param : :param : :param : :param : :param : :param :

property defaultAlgorithm: AlgorithmTypes

Get the default algorithm type.

Returns:

Default algorithm type.

property defaultContainer: ContainerTypes

Get the default container type.

Returns:

Default container type

property defaultEstimator: EstimatorTypes

Get the default estimator type.

Returns:

Default estimator type.

property logLevel: LogLevel

Get the current LogLevel setting.

Returns:

Current LogLevel

property precision: Tuple[int, int]

Get current precision level as a negative exponent, i.e. a precision of 10^(-3), in real and imaginary parts respectively, corresponds to a precision level of (3, 3).

Returns:

Current precision level

property verbose: bool

Get current verbosity setting.

Returns:

True if verbose mode is enabled.

Class JSONCoreSettingsService from the module pyzeal.settings.

This module provides a straight-forward implementation of the CoreSettingsSerivce based on a json serialization backend.

Authors:

  • Philipp Schuette

class pyzeal.settings.json_core_settings.JSONCoreSettingsService[source]

This class provides a layer of abstraction for storage and retrieval of PyZEAL core settings using JSON for persistence. Any read and/or write access to (core) settings must happen through a service like this one.

__init__()[source]

Create an instance of a new CoreSettingsService. The basis for its properties are the currently persisted (user or default) settings.

property defaultAlgorithm: AlgorithmTypes

Get the default algorithm type.

Returns:

Default algorithm type.

property defaultContainer: ContainerTypes

Get the default container type.

Returns:

Default container type

property defaultEstimator: EstimatorTypes

Get the default estimator type.

Returns:

Default estimator type.

This module provides a straight-forward implementation of the SettingsSerivce based on a json serialization backend.

Authors:

  • Philipp Schuette

class pyzeal.settings.json_settings_service.JSONSettingsService[source]

This class provides a layer of abstraction for storage and retrieval of PyZEAL related settings using JSON for persistence. Any read and/or write access to settings must happen through a service like this one.

__init__()[source]

Create an instance of a new SettingsService. The basis for its properties are the currently persisted (user or default) settings.

property defaultAlgorithm: AlgorithmTypes

Get the default algorithm type.

Returns:

Default algorithm type.

property defaultContainer: ContainerTypes

Get the default container type.

Returns:

Default container type

property defaultEstimator: EstimatorTypes

Get the default estimator type.

Returns:

Default estimator type.

property logLevel: LogLevel

Get the current LogLevel setting.

Returns:

Current LogLevel

property precision: Tuple[int, int]

Get current precision level as a negative exponent, i.e. a precision of 10^(-3), in real and imaginary parts respectively, corresponds to a precision level of (3, 3).

Returns:

Current precision level

property verbose: bool

Get current verbosity setting.

Returns:

True if verbose mode is enabled.

TODO.

Authors:

  • Philipp Schuette

class pyzeal.settings.json_helper.JSONHelper[source]

Static helper class providing methods to read and manipulate json settings.

static createOrUpdateCoreSetting(filename, setting, value)[source]

Update a core setting or create a new one if no value had previously been set.

Parameters:
  • filename (str) – the json file to update

  • setting (Union[Literal['defaultContainer'], Literal['defaultAlgorithm'], Literal['defaultEstimator']]) – setting to create or update

  • value (Union[ContainerTypes, AlgorithmTypes, EstimatorTypes]) – New setting value

Raises:

InvalidSettingException – If the given value is invalid for the specified setting, an InvalidSettingException is raised.

Return type:

None

static createOrUpdateSetting(filename, setting, value)[source]

Update a setting or create a new setting if no value has been set yet.

Parameters:
  • filename (str) – the json file to update

  • setting (Union[Literal['logLevel'], Literal['verbose'], Literal['precision']]) – setting to create or update

  • value (Union[LogLevel, bool, Tuple[int, int]]) – New setting value

Raises:

InvalidSettingException – If the given value is invalid for the specified setting, an InvalidSettingException is raised.

Return type:

None

static loadCoreSettingsFromFile(filename, settings)[source]

Load the settings stored in filename into settings.

Parameters:
  • filename (str) – Settings file to load

  • settings (Dict[str, str]) – Dict to store the read settings in

Return type:

None

static loadSettingsFromFile(filename, settings)[source]

Load the settings stored in filename into settings.

Parameters:
  • filename (str) – File to load

  • settings (Dict[str, Union[str, bool, Tuple[int, int]]]) – Dict to store the read settings in

Return type:

None