principia_materia.io_interface package

Submodules

Module contents

principia_materia.io_interface.format_tensor(tensor, prec=8, cell_length=None, flat=False, yaml_style=False, indices=True, index_width=5)

Format a tensor into string

Format float arrays from 1 or more dimensions into string, with several settings to control the format.

Parameters:
  • tensor (array of floats) – The tensor to format.

  • prec (int, optional, default to 8) – The decimal points to round the floating point numbers to.

  • cell_length (int, optional, default to None) – The width to align numbers in.

  • flat (bool, optional, default to False) – If True, print out every single tensor entry along side its index. If True, flat yaml_style, and indices are ignored. If False, if input tensor is a vector or matrix, print them out directly, if input tensor has rank greater than 2, loop over all the axes except the last 2, and print the last 2 axes out as a matrix.

  • yaml_style (bool, optional, default to False) – If True, print out tensor in YAML nested list format.

  • indices (bool, optional, default to True) – If True, print out the indices of the matrix when rank of tensor is greater than 2.

  • index_width (int, optional, default to 5) – The width to align indices numbers in.

principia_materia.io_interface.get_compute_engine_map()

Load First-Principle Interfaces.

Returns:

compute_engine_map – A dictionary containing the available first-principle interfaces in the form of subclasses of ComputeJob.

Return type:

dict

principia_materia.io_interface.indent(text, prefix='  ', initial_indent=None)

Indent text

Create indentation for text, the function can also treat first line with special indentation.

Parameters:
  • text (str) – Text to indent

  • prefix (str or int, optional, default to " ") – The indentation, if type is str, prepend the prefix to each line, if type is int, prepend the amount of spaces to each line.

  • initial_indent (str, optional, default to None) – If not None, prepend the input string to the first line of text.

principia_materia.io_interface.jobs_series_to_jobs_db(jobs_db, jobs_series, search_conditions=[], update=True)

Read Jobs in from ComputeJobSeries and store them into database with JobsDB.

Parameters:
  • jobs_db (JobsDB) – The interface of the database for storing the jobs.

  • jobs_series (ComputeJobSeries) – The interface to the job series for reading the jobs.

  • search_conditions (list, optional) – Additional search conditions for filtering the jobs.

  • update (bool, optional) – If True, only read and store the jobs that haven’t been read in before. If False, overwrite the data already in the database.

principia_materia.io_interface.tuple_to_str(tup, prec=8, strip=True)

Format tuple into string.

Recursively format tuples into string.

Parameters:
  • tup (tuple) – Input tuple.

  • prec (int, optional, default to 8) – The decimal points to round the floating point numbers to.

  • strip (bool, optional, default to True) – Whether to strip whitespaces from formatted numbers.