parse_scientific_notation#
- cherab.inversion.tools.parse_scientific_notation(sci_str: str, scilimits: tuple = (-1, 1), useLatex=True) strSource#
Parse a string in scientific notation and return a formatted string.
Strings like
'1.23e-4'are converted to'1.23x10^-4'or'1.23 \times 10^{-4}'ifuseLatexis True.- Parameters:
- sci_str
str A string in scientific notation. Must be in the form of ‘mantissa’ + ‘e’ + ‘exponent’.
- scilimits
tuple, (m,n),optional Scientific notation parsing is conducted only for numbers outside the range 10 m to 10 n, by default (-1, 1).
- useLatexbool,
optional If True, the output string will be formatted using LaTeX.
- sci_str
- Returns:
strThe formatted string.
Examples
>>> parse_scientific_notation('1.23e-4') '1.23 \\times 10^{-4}'