ecotyper.rcompat.parse¶
Text → double conversion exactly as R does it.
R does not use the C library’s (correctly rounded) strtod:
read.delim/read.table/scan→type.convert→R_strtod5(src/main/util.c): digits accumulated withans = 10*ans + d(an FMA on arm64) and then divided by a power of ten built by repeated squaring, so values with more than ~22 decimal places of scale are not always correctly rounded.data.table::fread→parse_double_regular(fread.c): 64-bit integer mantissa, then one multiplication/division by a tabulated10^k.
EcoTyper’s scripts exchange data through text files, so reproducing R’s
numbers bit for bit requires the same parsers. read_numeric_table()
parses a tab-delimited numeric table in either mode.
Functions
|
Parse an iterable of strings with R's (or fread's) number parser. |
|
Parse a tab-delimited table whose first column holds names. |
|
Values as R sees them after |
- ecotyper.rcompat.parse.read_numeric_table(path, mode='r')[source]¶
Parse a tab-delimited table whose first column holds names.
Returns
(header, first_col, values);headerholds every header field (including the first-column name when present).modeis"r"(read.delim) or"fread".- Parameters:
mode (str)