Skip to content

Commit fb41ce4

Browse files
committed
more bug fixes
1 parent 69cba2f commit fb41ce4

2 files changed

Lines changed: 27 additions & 6 deletions

File tree

core/src/processing/data/FloatDict.java

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -411,13 +411,21 @@ public int minIndex() {
411411

412412
public String minKey() {
413413
checkMinMax("minKey");
414-
return keys[minIndex()];
414+
int index = minIndex();
415+
if (index == -1) {
416+
return null;
417+
}
418+
return keys[index];
415419
}
416420

417421

418422
public float minValue() {
419423
checkMinMax("minValue");
420-
return values[minIndex()];
424+
int index = minIndex();
425+
if (index == -1) {
426+
return Float.NaN;
427+
}
428+
return values[index];
421429
}
422430

423431

@@ -452,17 +460,25 @@ public int maxIndex() {
452460
}
453461

454462

455-
/** The key for a max value. */
463+
/** The key for a max value, or null if everything is NaN (no max). */
456464
public String maxKey() {
457465
checkMinMax("maxKey");
458-
return keys[maxIndex()];
466+
int index = maxIndex();
467+
if (index == -1) {
468+
return null;
469+
}
470+
return keys[index];
459471
}
460472

461473

462-
/** The max value. */
474+
/** The max value. (Or NaN if they're all NaN.) */
463475
public float maxValue() {
464476
checkMinMax("maxValue");
465-
return values[maxIndex()];
477+
int index = maxIndex();
478+
if (index == -1) {
479+
return Float.NaN;
480+
}
481+
return values[index];
466482
}
467483

468484

core/todo.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ X drastic performance improvements for addRow()
1919
X when using setColumnType(), replace nulls with missingInt, missingFloat, etc
2020
X formerly, was throwing a NullPointerException
2121

22+
data types
23+
X if all data is NaN in a FloatDict, return NaN for maxValue() and minValue()
24+
X formerly as AIOOBE -1 because -1 means "not found"
25+
X but that was indexing directly into the data array
26+
_ add this handling for IntDict and others
2227

2328
applet removal
2429
_ remove Applet as base class

0 commit comments

Comments
 (0)