# HG changeset patch # User Chris Cannam # Date 1536247579 -3600 # Node ID c9c2aa17439ae75413e6f0e54b43520414a68f90 # Parent 12b7a9613eb5943190433f17c71fc6afe0c92131 Add small, signed diff -r 12b7a9613eb5 -r c9c2aa17439a data/fileio/CSVFormat.cpp --- 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); } diff -r 12b7a9613eb5 -r c9c2aa17439a data/fileio/CSVFormat.h --- 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;