cape.tnakit.arrayutils: Tools for NumPy arrays

This includes tools for modifying or analyzing vectors, including tools to display the vectors/arrays.

cape.tnakit.arrayutils.get_printf_fmt(V, prec=6, emax=4, emin=-2, echar='e')

Determine an appropriate print format for a column vector

Call:
>>> fmt = get_printf_fmt(V, prec=6, emax=4, emin=-2, echar="e")
Inputs:
V: list | np.ndarray

1D vector of values for printing as column in CSV file

prec: {6} | int > 0

Number of digits to use after . in float format

emax: {4} | int > 0

Maximum number of digits to left of . in float

emin: {0} | int < 0

Maximum number of zeros to right of . in float

echar: {"e"} | "E" | "d" | "D"

Character to use for exponential format

Outputs:
fmt: str

String flag such that fmt % v has same number of digits for each v in V

Versions:
  • 2019-07-12 @ddalle: First version