Mixed

class ase2sprkkr.common.grammar_types.Mixed(prefix=None, postfix=None, format='', default_value=None, condition=None, after_convert=None, description='')[source]

A variant value to be used in input files (in unknown - custom - options)

Class hierarchy

Inheritance diagram of ase2sprkkr.common.grammar_types.Mixed

Constructor

Parameters
  • prefix (Optional[str]) –

  • postfix (Optional[str]) –

  • format (str) –

  • default_value (Any) –

  • condition (Optional[Callable[[Any], Union[bool, str]]]) –

  • after_convert (Optional[Callable[[Any], Any]]) –

__init__(prefix=None, postfix=None, format='', default_value=None, condition=None, after_convert=None, description='')

Create the object.

Parameters
  • prefix (Optional[str]) – The string, that will be printed before the value

  • postfix (Optional[str]) – The string, that will be printed after the value

  • format (str) – The (python) format string, that will be used for printing the value. The format is passed as format argument to str.format routine.

  • default_value (Optional[Any]) – The default value of the options of this type. None means no default value.

  • condition (Optional[Callable[[Any], Union[bool, str]]]) – Function, that check the validity of the value. It should return True for a valid value, and False or string for invalid. The string is interpreted as an error message that explains the invalidity of the value.

  • after_convert (Optional[Callable[[Any], Any]]) – Function, that - if it is given - is applied to the (entered or parsed) value. The function is applied on the result of the convert method

classmethod _initialize()[source]

Have to be called later, after the used types are instantiated

missing_value()[source]

Is the configuraion value a flag? I.e., can be =<value> ommited in the configuration?

Returns

  • can_be_ommited (bool) – Is an ommision of the value possible, e.g. the option is given as Flag (only by name of the option)

  • default_value – The value used if the value is ommitted

  • do_not_output_the_option – The value, for which the variable should not be outputed at all (e.g. False for a flag)

static is_the_same_value(a, b)

The numpy arrays cannot be compared by =, that’s why this method. However, the method is still far from to be perfect, it can not compare nested numpy arrays.

I = <Mixed>
string_type = <QString>

Type of string grammar_type to be used. To be redefined in the descendants.

types = [<Energy>, <Real>, <Integer>, <SetOf>, <SetOf>, <QString>, <Flag>]