grammar_types

Full name: ase2sprkkr.common.grammar_types

Module class hierarchy

Inheritance diagram of ase2sprkkr.common.grammar_types.Array, ase2sprkkr.common.grammar_types.BaseMixed, ase2sprkkr.common.grammar_types.BaseRealWithUnits, ase2sprkkr.common.grammar_types.BaseString, ase2sprkkr.common.grammar_types.Bool, ase2sprkkr.common.grammar_types.Complex, ase2sprkkr.common.grammar_types.Date, ase2sprkkr.common.grammar_types.Energy, ase2sprkkr.common.grammar_types.Flag, ase2sprkkr.common.grammar_types.GrammarType, ase2sprkkr.common.grammar_types.Integer, ase2sprkkr.common.grammar_types.Keyword, ase2sprkkr.common.grammar_types.LineString, ase2sprkkr.common.grammar_types.Mixed, ase2sprkkr.common.grammar_types.Number, ase2sprkkr.common.grammar_types.ObjectNumber, ase2sprkkr.common.grammar_types.PotMixed, ase2sprkkr.common.grammar_types.QString, ase2sprkkr.common.grammar_types.Range, ase2sprkkr.common.grammar_types.Real, ase2sprkkr.common.grammar_types.RealWithUnits, ase2sprkkr.common.grammar_types.Separator, ase2sprkkr.common.grammar_types.Sequence, ase2sprkkr.common.grammar_types.SetOf, ase2sprkkr.common.grammar_types.String, ase2sprkkr.common.grammar_types.Table, ase2sprkkr.common.grammar_types.TypedGrammarType, ase2sprkkr.common.grammar_types.Unsigned

Description

Classes, that represents various value types that can appear in the configuration and problem definitionfiles.

Each grammar type can both parse string containing a value of a given type, and to create the string containing a given value.

Module Attributes

integer

A standard grammar type instance for (signed) integers

unsigned

A standard grammar type instance for unsigned integers

boolean

A standard grammar type instance for booleans in potential files

flag

A standard grammar type instance for booleans in input files

real

A standard grammar type instance for reals

date

A standard instance for the grammar type for dates

string

A standard grammar type instance for strings

qstring

A standard grammar type instance for quoted strings in input files

line_string

A standard grammar type instance for one-line strings in potential files

energy

A standard grammar type instance for energy values (float) for potential files

complex_number

A standard grammar type instance for complex numbers

set_of_integers

A standard grammar type instance for array of integers (of any length, used by variant types)

set_of_reals

A standard grammar type instance for array of reals (of any length, used by variant types)

separator

A standard grammar type instance for separators in potential files

mixed

A standard grammar type instance for variant (mixed) in input files

pot_mixed

A standard grammar type instance for variant (mixed) values in potential files

type_from_type_map

The standard grammar_types for python types.

recognized_set_types

The types, that are recognized as 'list of values' and so that will be accepted as values for array_like type (e.g.

type_from_set_map

Map the python type of a collection member to a grammar type of the collection.

Functions

DefKeyword(default, *others, **kwargs)

A value, that can take values from the predefined set of strings, the first one is the default value.

compare_numpy_values(a, b)

The numpy arrays cannot be compared by =, that's why this method.

format_for_type(format, type)

Returns the format appropriate to the given type

type_from_default_value(value[, format, ...])

Guess the grammar type from a value, that will become the default value of the grammar type.

type_from_type(type[, format, format_all, ...])

Guess and return the grammar element (GrammarType class descendatnt) from a python type.

type_from_value(value[, type_map])

Gues the grammar type from a python value.

Classes

Array(type[, default_value, length, ...])

A (numpy) array of values of one type

BaseMixed([prefix, postfix, format, ...])

A variant type - it can hold "anything".

BaseRealWithUnits([prefix, postfix, format, ...])

The base class for float value, which can have units append.

BaseString([prefix, postfix, format, ...])

Base type for string grammar types

Bool([prefix, postfix, format, ...])

A bool type, whose value is represented by a letter (T or F)

Complex(type[, default_value, length, ...])

Date([prefix, postfix, format, ...])

A date value of the form 'DD.MM.YYYY'

Energy([prefix, postfix, format, ...])

The grammar type for energy.

Flag([prefix, postfix, format, ...])

A boolean value, which is True, if a name of the value appears in the input file.

GrammarType([prefix, postfix, format, ...])

Base class for definition of configuration option types

Integer([prefix, postfix, format, ...])

Signed integer

Keyword(*keywords, **kwargs)

A value, that can take values from the predefined set of strings.

LineString([prefix, postfix, format, ...])

A string, that takes all up to the end of the line

Mixed([prefix, postfix, format, ...])

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

Number([prefix, postfix, format, ...])

Base class for a number - descendants of this class can have minimal and/or maximal possible value.

ObjectNumber([prefix, postfix, format, ...])

An abstract class, that describe an unsigned integer, that reffers to an object.

PotMixed([prefix, postfix, format, ...])

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

QString([prefix, postfix, format, ...])

Either a quoted string, or just a word (without whitespaces or special chars)

Range(type[, prefix, postfix, format, ...])

A range type - it accepts either one value or range of two values of a given type.

Real([prefix, postfix, format, ...])

A real value

RealWithUnits(*args, units, **kwargs)

A float value with user-defined units

Separator([prefix, postfix, format, ...])

Special class for **** separator inside a section

Sequence(*types[, format, format_all, ...])

A sequence of values of given types

SetOf(type[, default_value, length, ...])

Set of values of the same type.

String([prefix, postfix, format, ...])

Just a string (without whitespaces and few special chars)

Table([columns, header, free_header, ...])

Table, optionaly with named columns, e.g.

TypedGrammarType([prefix, postfix, format, ...])

Unsigned([prefix, postfix, format, ...])

Unsigned integer (zero is possible)