tests.paper.sigfig
This module provides function for working with significant figures.
Modified from sound-shell-model/paper/python/sigfig.py.
Functions
- tests.paper.sigfig.format_table(cols, errors, n, labels=None, headers=None, latex=False)
Format a table such that the errors have n significant figures. [cols] and [errors] should be a list of 1D arrays that correspond to data and errors in columns. [n] is the number of significant figures to keep in the errors. [labels] is an optional column of strings that will be in the first column. [headers] is an optional list of column headers. If [latex] is true, format the table so that it can be included in a LaTeX table
- tests.paper.sigfig.round_sig(x, n)
Round floating point x to n significant figures.
- Parameters:
x (float)
n (int)
- Return type:
str
- tests.paper.sigfig.round_sig_error(x, ex, n, paren=False)
Find ex rounded to n sig-figs and make the floating point x match the number of decimals. If [paren], the string is returned as quantity(error) format
- Parameters:
x (float)
ex (float)
n (int)
paren (bool)
- Return type:
str | Tuple[str, str]
- tests.paper.sigfig.round_sig_error2(x, ex1, ex2, n)
Find min(ex1,ex2) rounded to n sig-figs and make the floating point x and max(ex,ex2) match the number of decimals.
- Parameters:
x (float)
ex1 (float)
ex2 (float)
n (int)
- Return type:
Tuple[str, str, str]
- tests.paper.sigfig.round_sig_signed(x, n)
Round floating point x to n significant figures.
- Parameters:
x (float)
n (int)
- Return type:
str