Table

class ase2sprkkr.common.test.grammar_types.arrays.Table(columns=None, header=None, free_header=False, format={<class 'float'>: '>22.14', None: '>16'}, format_all=True, numbering=None, numbering_label=None, numbering_format=True, grouping=False, grouping_label=None, grouping_format=True, prefix=None, postfix=None, length=None, row_condition=None, flatten=False, default_values=False, named_result=None, group_size=None, group_size_format='{:<12}{}', groups_as_list=None, **kwargs)[source]

Table, optionaly with named columns, e.g.

::text

IQ IREFQ IMQ NOQ ITOQ CONC

1 1 1 1 1 1.000 2 2 2 1 2 1.000

Class hierarchy

Inheritance diagram of ase2sprkkr.common.test.grammar_types.arrays.Table

Constructor

Parameters:
__init__(columns=None, header=None, free_header=False, format={<class 'float'>: '>22.14', None: '>16'}, format_all=True, numbering=None, numbering_label=None, numbering_format=True, grouping=False, grouping_label=None, grouping_format=True, prefix=None, postfix=None, length=None, row_condition=None, flatten=False, default_values=False, named_result=None, group_size=None, group_size_format='{:<12}{}', groups_as_list=None, **kwargs)[source]
Parameters:
  • columns (List[GrammarType]) – List of GrammarTypes that describes the columns of the table

  • header (bool | None) – Whether table will have header. Default None means True, if the names are specified

  • free_header – Do not require the exact content of the header, just skip one line during parsing

  • format – Pass this argument to the Sequence describing the line

  • format_string – Pass this argument to the Sequence describing the line

  • numbering (str | bool | GrammarType) – There will be one extra column on the begining of the table, with numbering starting from one. String argument means the label of the column.

  • numbering_label – The label of the numbering column (if not given in numbering).

  • numbering_format – Format for the numering column

  • grouping – If True, the data are not one table, but list of tables. Numbering then numbers the tables, not the rows of the tables. There will be one extra column which numbers rows within the table.

  • grouping_label – Similiar as numbering_label

  • grouping_format – Similiard as numbering_format

  • prefix – Prints the prefix before the table

  • postfix – Prints the postfix after the table

  • length – The table length (or the number of groups)

  • row_condition – The condition, that each row of the table should have satisfied

  • flatten – The resulting table will have one dimension. Is meaningful for table without named columns, with a same type of all columns

  • named_result – The resulting table will have numpy structured dtype with named columns. Default None means autodetection: it behaves as True if necessary, i.e.: if there are at least two columns with different types.

  • group_size – If grouping, there will be another line after the header (SPRKKR format of tables), which contains {NAME}     {VALUE}. The name should be specified in group_size. The value is the number of rows, which all subtables are required to have.

  • group_size_format – Format for the group_size line.

  • groups_as_list – If True - groups are contained in list If False - groups are contained in np.ndarray If None - True if group_size is defined (and thus if it is possible)

  • kwargs – Columns and their names can be assigned as kwargs, e.g. column1_name = float, column2_name = int, ...

array_access = True

The value of this type can be accessed as array

name_in_grammar = False

Default value for ValueDefinition.name_in_grammar. Some types (e.g. Tables) commonly have no name (are identified by its position in the potential file) – such type could redefine this class property.

special_columns()[source]
_grammar(param_name=False)[source]
_string(data)[source]

Convert the value to the ouput.

The string() apply format and do some additional transformation (add prefix, postfix etc.), so the actual way how to convert the value for the output should be here.

_validate(value, why='set')[source]

Return error message if the value is not valid.

convert(value)[source]

Convert a value from user to the “cannonical form”

property numpy_type

The base class of the class hierarchy.

When called, it accepts no arguments and returns a new featureless instance that has no instance attributes and cannot be given any.

property _numpy_type
number_of_columns()[source]
zero_data(length)[source]

Return array of zeros with the given number of rows and with the dtype of the table

grammar_name()[source]

Human readable expression of the grammar. By default, this is what is set by grammar.setName, however, sometimes is desirable to set even shorter string

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.