pyiron.base.generic.parameters module

class pyiron.base.generic.parameters.GenericParameters(table_name=None, input_file_name=None, val_only=False, comment_char='#', separator_char=' ', end_value_char='')[source]

Bases: pyiron.base.generic.template.PyironObject

GenericParameters class defines the typical input file with a key value structure plus an additional column for comments. Convenience class to easily create, read, and modify input files

Parameters
  • table_name (str) – name of the input file inside the HDF5 file - optional

  • input_file_name (str/Nonetype) – name of the input file (if None default parameters are used)

  • val_only (bool) – input format consists of value (comments) only

  • comment_char (str) – separator that characterizes comment (e.g. “#” for python)

  • separator_char (str) – separator that characterizes the split between key and value - default=’ ‘

  • end_value_char (str) – special character at the end of every line - default=’’

.. attribute:: file_name

file name of the input file

.. attribute:: table_name

name of the input table inside the HDF5 file

.. attribute:: val_only

boolean option to switch from a key value list to an value only input file

.. attribute:: comment_char

separator that characterizes comment

.. attribute:: separator_char

separator that characterizes the split between key and value

.. attribute:: multi_word_separator

multi word separator to have multi word keys

.. attribute:: end_value_char

special character at the end of every line

.. attribute:: replace_char_dict

dictionary to replace certain character combinations

clear_all()[source]

Clears all fields in the object

property comment_char

Get the separator that characterizes comment

Returns

comment character

Return type

str

define_blocks(block_dict)[source]

Define a block section within the GenericParameters

Parameters

block_dict (dict) – dictionary to define the block

property end_value_char

Get the special character at the end of every line

Returns

end of line character

Return type

str

property file_name

Get the file name of the input file

Returns

file name

Return type

str

from_hdf(hdf, group_name=None)[source]

Restore the GenericParameters from an HDF5 file

Parameters
  • hdf (ProjectHDFio) – HDF5 group object

  • group_name (str) – HDF5 subgroup name - optional

get(parameter_name, default_value=None)[source]

Get the value of a specific parameter from GenericParameters - if the parameter is not available return default_value if that is set.

Parameters
  • parameter_name (str) – parameter key

  • default_value (str) – default value to return is the parameter is not set

Returns

value of the parameter

Return type

str

get_attribute(attribute_name)[source]

Get the value of a specific parameter from GenericParameters

Parameters

attribute_name (str) – parameter key

Returns

value of the parameter

Return type

str

get_pandas()[source]

Output the GenericParameters object as Pandas Dataframe for human readability.

Returns

Pandas Dataframe of the GenericParameters object

Return type

pandas.DataFrame

get_string_lst()[source]

Get list of strings from GenericParameters to write to input file

keys()[source]

Return keys of GenericParameters object

load_default()[source]

Load defaults resets the dataset in the background to be empty

load_string(input_str)[source]

Load a multi line string to overwrite the current parameter settings

Parameters

input_str (str) – multi line string

modify(separator=None, append_if_not_present=False, **modify_dict)[source]

Modify values for existing parameters. The command is called as modify(param1=val1, param2=val2, …)

Parameters
  • separator (str) – needed if the parameter name contains special characters such as par: use then as input: modify(separator=”:”, par=val) - optional

  • append_if_not_present (bool) – do not raise an exception but append the parameter in practice use set(par=val) - default=False

  • **modify_dict (dict) – dictionary of parameter names and values

property multi_word_separator

Get the multi word separator to have multi word keys

Returns

multi word separator

Return type

str

read_input(file_name, ignore_trigger=None)[source]

Read input file and store the data in GenericParameters - this overwrites the current parameter settings

Parameters
  • file_name (str) – absolute path to the input file

  • ignore_trigger (str) – trigger for lines to be ignored

remove_keys(key_list)[source]

Remove a list of keys from the GenericParameters

Parameters

key_list (list) – list of keys to be removed

property replace_char_dict

Get the dictionary to replace certain character combinations

Returns

character replace dictionary

Return type

dict

property separator_char

Get the separator that characterizes the split between key and value

Returns

separator character

Return type

str

set(separator=None, **set_dict)[source]

Set the value of multiple parameters or create new parameter key, if they do not exist already.

Parameters
  • separator (float/int/str) – separator string - optional

  • **set_dict (dict) – dictionary containing the parameter keys and their corresponding values to be set

set_dict(dictionary)[source]

Set a dictionary of key value pairs

Parameters

dictionary (dict) – dictionary of key value pairs

set_value(line, val)[source]

Set the value of a parameter in a specific line

Parameters
  • line (float/int/str) – line number - starting with 0

  • val (str/bytes) – value to be set

property table_name

Get the name of the input table inside the HDF5 file

Returns

table name

Return type

str

to_hdf(hdf, group_name=None)[source]

Store the GenericParameters in an HDF5 file

Parameters
  • hdf (ProjectHDFio) – HDF5 group object

  • group_name (str) – HDF5 subgroup name - optional

property val_only

Get the boolean option to switch from a key value list to an value only input file

Returns

[True/False]

Return type

bool

write_file(file_name, cwd=None)[source]

Write GenericParameters to input file

Parameters
  • file_name (str) – name of the file, either absolute (then cwd must be None) or relative

  • cwd (str) – path name (default: None)