Array

class ase2sprkkr.common.grammar_types.Array(type, default_value=None, length=None, max_length=None, min_length=None, as_list=False, format=None, **kwargs)[source]

A (numpy) array of values of one type

Class hierarchy

Inheritance diagram of ase2sprkkr.common.grammar_types.Array

Constructor

__init__(type, default_value=None, length=None, max_length=None, min_length=None, as_list=False, format=None, **kwargs)[source]
Parameters
  • type – The grammar type of the values in the list (it can be given by a python type)

  • default_value – The default value for the list

  • length – If it is set, the list have to have just this length (it sets min_ and max_length to the length)

  • min_length – The minimal allowed length of the list.

  • max_length – The maximal allowed length of the list.

  • as_list – Type of the value array. True means List, False means np.ndarray, or custom type (e.g. tuple) can be provided. However, the value can be set using tuple or list anyway.

delimiter = Suppress:(<SP><TAB>)
Parameters

name (str) –

Return type

ParserElement

delimiter_str = ' '
_set_convert_action(grammar)[source]
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

_string(val)[source]

The string method 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”

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.