cherab.inversion.tools.parse_scientific_notationยถ

cherab.inversion.tools.parse_scientific_notation(sci_str: str, scilimits: tuple = (-1, 1), useLatex: bool = True) strSourceยถ

Parse a string in scientific notation and return a formatted string.

Strings like '1.23e-4' are converted to r'1.23x10^-4' or r'1.23 \\times 10^{-4}' if useLatex is True.

Parameters:
sci_str: strยถ

String in scientific notation. Must be in the form of โ€˜mantissaโ€™ + โ€˜eโ€™ + โ€˜exponentโ€™.

scilimits: tuple = (-1, 1)ยถ

Scientific notation parsing is conducted only for numbers outside the range 10 m to 10 n, by default (-1, 1).

useLatex: bool = Trueยถ

If True, the output string will be formatted using LaTeX.

Returns:

str โ€“ The formatted string.

Raises:

ValueError โ€“ If the input string does not contain an โ€˜eโ€™ character.

Examples

>>> parse_scientific_notation("1.23e-4")
'1.23 \\\\times 10^{-4}'