plastid.util.services.misc module¶
Miscellaneous functions that don’t seem to fit elsewhere
guess_formatter()
Convert string into primitive data type it probably encoded before str was called on it
number()
Convert string into numerical data type, trying bool, int, float, then str
- plastid.util.services.misc.guess_formatter(inp)[source]¶
Guesses the format of input, trying bool, int, float, then str. Correctly parses nan`s and `Inf`s. Converts `None to nan
- Parameters
- inpstr
input
- Returns
- boolean, number, or string
- plastid.util.services.misc.number(inp)[source]¶
Parses numbers from strings, preferring int over float. Parses nan, Nan, None, none, inf, and -inf
- Parameters
- inpstr
string input
- Returns
- float, numpy.nan, numpy.inf, or -numpy.inf, or str if no conversion found
- Raises
- ValueError
if inp cannot be converted to a number