Reference#
Main API#
ArrayTeX.
- arraytex.to_matrix(arr, style='b', num_format=None, scientific_notation=False, to_clp=False)#
Convert a numpy.NDArray to LaTeX matrix.
- Parameters:
arr (ndarray[Any, dtype[Any]]) – the array to be converted
style (str) – a style formatter string, such as “b” for “bmatrix” or “p” for “pmatrix”
num_format (str | None) – a number formatter string, e.g. “.2f”
scientific_notation (bool) – a flag to determine whether e.g. 1 x 10^3 format should be used if “.e” is used for num_format, otherwise e-notation (1e3) is used
to_clp (bool) – copy the output to the system clipboard
- Returns:
the LaTeX matrix string representation of the array
- Raises:
TooManyDimensionsError – when the supplied array has more than 2 dimensions
- Return type:
str
- arraytex.to_tabular(arr, num_format=None, scientific_notation=False, col_align='c', col_names=None, index=None, to_clp=False)#
Convert a numpy.NDArray to LaTeX tabular environment.
- Parameters:
arr (ndarray[Any, dtype[Any]]) – the array to be converted
num_format (str | None) – a number formatter string, e.g. “.2f”
scientific_notation (bool) – a flag to determine whether 1 x 10^3 should be used, otherwise e-notation is used (1e3)
col_align (List[str] | str) – set the alignment of the columns, usually “c”, “r” or “l”. If a single character is provided then it will be broadcast to all columns. If a list is provided then each item will be assigned to each column, list size and number of columns must match
col_names (List[str] | None) – an optional list of column names, otherwise generic names will be assigned
index (List[str] | None) – an optional table index, i.e. row identifiers
to_clp (bool) – copy the output to the system clipboard
- Returns:
the LaTeX tabular string representation of the array
- Raises:
TooManyDimensionsError – when the supplied array has more than 2 dimensions
DimensionMismatchError – when there is a mismatch between column items and number of columns, or column index items and number of rows
- Return type:
str
Exceptions#
Module to hold custom errors.
- exception arraytex.errors.DimensionMismatchError#
Raised when dimensionality issues occur.
- exception arraytex.errors.TooManyDimensionsError#
Raised when an array of more than 2 dimensions is supplied.