From a0bc02db16a3ca4e56c21fd55cd77594eb018ae9 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Wed, 30 Jul 2014 09:38:19 -0400 Subject: [PATCH] return null on getString() for NaN values --- core/src/processing/data/Table.java | 16 ++++++++++++---- core/todo.txt | 4 ++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/core/src/processing/data/Table.java b/core/src/processing/data/Table.java index a153d16aa..93ba62fc4 100644 --- a/core/src/processing/data/Table.java +++ b/core/src/processing/data/Table.java @@ -2984,11 +2984,19 @@ public class Table { return missingString; } return columnCategories[column].key(cat); - } else { - return String.valueOf(Array.get(columns[column], row)); + } else if (columnTypes[column] == FLOAT) { + if (Float.isNaN(getFloat(row, column))) { + return null; + } + } else if (columnTypes[column] == DOUBLE) { + if (Double.isNaN(getFloat(row, column))) { + return null; + } } + return String.valueOf(Array.get(columns[column], row)); } + /** * @param columnName title of the column to reference */ @@ -3443,9 +3451,9 @@ public class Table { // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - public void replaceAll(String orig, String replacement) { + public void replaceAll(String regex, String replacement) { for (int col = 0; col < columns.length; col++) { - replaceAll(orig, replacement, col); + replaceAll(regex, replacement, col); } } diff --git a/core/todo.txt b/core/todo.txt index 93a05f7b3..791022f45 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -1,6 +1,10 @@ 0229 core (3.0a2) X add copy() method to Table +_ need a better method for "missing" data in Table +_ if missing int is zero, can't just remove those values from saving a table +_ but for NaN values, it's a necessity + pulls X implement A and a (elliptical arcs)