Mercurial > hg > svcore
changeset 1512:c9c2aa17439a import-audio-data
Add small, signed
author | Chris Cannam |
---|---|
date | Thu, 06 Sep 2018 16:26:19 +0100 |
parents | 12b7a9613eb5 |
children | 75d92155fa20 |
files | data/fileio/CSVFormat.cpp data/fileio/CSVFormat.h |
diffstat | 2 files changed, 26 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/data/fileio/CSVFormat.cpp Thu Sep 06 11:49:00 2018 +0100 +++ b/data/fileio/CSVFormat.cpp Thu Sep 06 16:26:19 2018 +0100 @@ -71,14 +71,16 @@ for (int li = 0; li < lines.size(); ++li) { QString line = lines[li]; - if (line.startsWith("#") || line == "") continue; + if (line.startsWith("#") || line == "") { + continue; + } guessQualities(line, lineno); ++lineno; } - if (lineno >= 50) break; + if (lineno >= 150) break; } guessPurposes(); @@ -113,7 +115,8 @@ // something that indicates otherwise: ColumnQualities defaultQualities = - ColumnNumeric | ColumnIntegral | ColumnIncreasing | ColumnNearEmpty; + ColumnNumeric | ColumnIntegral | ColumnSmall | + ColumnIncreasing | ColumnNearEmpty; for (int i = 0; i < cols; ++i) { @@ -130,7 +133,9 @@ bool numeric = (qualities & ColumnNumeric); bool integral = (qualities & ColumnIntegral); bool increasing = (qualities & ColumnIncreasing); + bool small = (qualities & ColumnSmall); bool large = (qualities & ColumnLarge); // this one defaults to off + bool signd = (qualities & ColumnSigned); // also defaults to off bool emptyish = (qualities & ColumnNearEmpty); if (lineno > 1 && s.trimmed() != "") { @@ -147,7 +152,15 @@ value = (float)StringBits::stringToDoubleLocaleFree(s, &ok); } if (ok) { - if (lineno < 2 && value > 1000.f) large = true; + if (lineno < 2 && value > 1000.f) { + large = true; + } + if (value < 0.f) { + signd = true; + } + if (value < -1.f || value > 1.f) { + small = false; + } } else { numeric = false; } @@ -174,7 +187,9 @@ (numeric ? ColumnNumeric : 0) | (integral ? ColumnIntegral : 0) | (increasing ? ColumnIncreasing : 0) | + (small ? ColumnSmall : 0) | (large ? ColumnLarge : 0) | + (signd ? ColumnSigned : 0) | (emptyish ? ColumnNearEmpty : 0); }
--- a/data/fileio/CSVFormat.h Thu Sep 06 11:49:00 2018 +0100 +++ b/data/fileio/CSVFormat.h Thu Sep 06 16:26:19 2018 +0100 @@ -56,11 +56,13 @@ }; enum ColumnQuality { - ColumnNumeric = 1, - ColumnIntegral = 2, - ColumnIncreasing = 4, - ColumnLarge = 8, - ColumnNearEmpty = 16, + ColumnNumeric = 1, // No non-numeric values were seen in sample + ColumnIntegral = 2, // All sampled values were integers + ColumnIncreasing = 4, // Sampled values were monotonically increasing + ColumnSmall = 8, // All sampled values had magnitude < 1 + ColumnLarge = 16, // Values "quickly" grew to over 1000 + ColumnSigned = 32, // Some negative values were seen + ColumnNearEmpty = 64, // Nothing in this column beyond first row }; typedef unsigned int ColumnQualities;