Option

class ase2sprkkr.common.options.Option(definition, container=None, value=None)[source]

Class for one option (a configuration value) of SPRKKR - either to be used as a part of InputParameters or Potential configuration. Usage:

>>> from ase2sprkkr.sprkkr.calculator import SPRKKR
>>> calculator = SPRKKR()
>>> conf = calculator.input_parameters
>>> conf.ENERGY.ImE = 5.
>>> conf.ENERGY.ImE()
5.0
>>> conf.ENERGY.ImE.info
'Configuration value ImE'
>>> conf.ENERGY.ImE.help()                     
Configuration value ImE

ImE : Energy (<Real> [Ry|eV]) ≝ 0.0  (optional)
>>> conf.ENERGY.ImE.set_dangerous('1J')
>>> conf.ENERGY.ImE()
'1J'

Class hierarchy

Inheritance diagram of ase2sprkkr.common.options.Option

Constructor

__init__(definition, container=None, value=None)[source]

” :param definition: The value type of the option and its format (in potential and/or task file) :type definition: ValueDefinition :param container: The container, that owns the object :param value: The value of the option. :type value: mixed

is_dangerous()[source]

Return, whether the option is set to a dangerous value, i.e. a value that bypass the validation.

set_dangerous(value, index=None)[source]

Set the option to a dangerous value - i.e. to a value that bypass the type and value checks and enforcing.

However, the type of such value is still checked by the proper mixed type. To completly bypass the check, set the value to an instance of DangerousValue class directly.

_create_dangerous_value(value)[source]
property default_value

Return default value for the option. The function is here, and not in the definition, since the default value can be given by callable, that accepts the Option as argument. This possibility is used in ase2sprkkr, when the default values of some options are generated from the underlined Atoms object

set(value, *, unknown=None)[source]

Set the value of the option.

Parameters
  • value (mixed) – The new value of the option.

  • unknown (str or None) – A dummy argument to make the method compatibile with ase2sprkkr.sprkkr.common.configuration_containers.ConfigurationContainer.set()

_post_set()[source]

Thus should be called after all modifications

_check_array_access()[source]

Check, whether the option is numbered array and thus it can be accessed as array using []

_set_item(name, value)[source]

Set a single item of a numbered array. For internal use - so no sanity checks

_getitem(name)[source]

Get a single item from a numbered array. For internal use - so no sanity checks

_unpack_value(value)[source]

Unpack potentionally dangerous values.

_pack_value(value)[source]

Validate the value, if it’s to be.

get()[source]

Return the value of self

property result

Return the result value.

In some cases, the value of an option have to be translated for the output. E.g. the site can be given as site object, but the integer index is required in the output.

In a such case, this property can be utilized: the value of the option is retained as is and the transformed value is stored in the result.

clear_result()[source]
clear(do_not_check_required=False, call_hooks=True)[source]

Clear the value: set it to None

is_changed()[source]

True, if the value is set and the value differs from the default

Return type

bool

_save_to_file(file)[source]

Write the name-value pair to the given file, if the value is set.

validate(why='save')[source]
property name

Return the name of the option/section. The name is defined by the definition of the object.

Returns

  • name (str)

  • The name of the object.

as_dict(only_changed='basic')[source]

Return the value of self, in the case of container as a dictionary. To be redefined in the descendants.

Parameters

only_changed (Union[bool, str]) – Return only changed values, or all of them? If True, return only the values, that differ from the defaults. If False, return all the values. The default value ‘basic’ means, return all non-expert values and all changed expert values.

value_and_changed()[source]

Return value and whether the value was changed

Returns

  • value (mixed) – The value of the options (return all values for ‘numbered array’)

  • changed (bool) – Whether the value is the same as the default value or not

is_it_the_default_value(value)[source]

Return, whether the given value is the default value. For numbered array, only the wildcard value can be set and this value have to be the same as the default.

_find_value(name)[source]
get_path()[source]