From 6dd3724b9b5e29a9bd9f404d28d0cf6d43ccfe95 Mon Sep 17 00:00:00 2001 From: Phil Steitz Date: Sat, 16 Jan 2010 20:01:17 +0000 Subject: [PATCH] Fixed regression in Frequency.getPct(Object) introduced in 2.0. Cumulative percent was being returned for Object arguments in place of percent. JIRA: MATH-329 Reported by Will Wu git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@900016 13f79535-47bb-0310-9956-ffa450edef68 --- src/main/java/org/apache/commons/math/stat/Frequency.java | 2 +- src/site/xdoc/changes.xml | 4 ++++ src/test/java/org/apache/commons/math/stat/FrequencyTest.java | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/apache/commons/math/stat/Frequency.java b/src/main/java/org/apache/commons/math/stat/Frequency.java index c45d72883..68c8bf2de 100644 --- a/src/main/java/org/apache/commons/math/stat/Frequency.java +++ b/src/main/java/org/apache/commons/math/stat/Frequency.java @@ -300,7 +300,7 @@ public class Frequency implements Serializable { */ @Deprecated public double getPct(Object v) { - return getCumPct((Comparable) v); + return getPct((Comparable) v); } /** diff --git a/src/site/xdoc/changes.xml b/src/site/xdoc/changes.xml index 6ed488994..44acbcab6 100644 --- a/src/site/xdoc/changes.xml +++ b/src/site/xdoc/changes.xml @@ -39,6 +39,10 @@ The type attribute can be add,update,fix,remove. + + Fixed regression in Frequency.getPct(Object) introduced in 2.0. Cumulative + percent was being returned for Object arguments in place of percent. + Singular Value Decomposition now computes either the compact SVD (using only positive singular values) or truncated SVD (using a user-specified maximal diff --git a/src/test/java/org/apache/commons/math/stat/FrequencyTest.java b/src/test/java/org/apache/commons/math/stat/FrequencyTest.java index 4fcbe2b5c..f216edaf8 100644 --- a/src/test/java/org/apache/commons/math/stat/FrequencyTest.java +++ b/src/test/java/org/apache/commons/math/stat/FrequencyTest.java @@ -144,6 +144,8 @@ public final class FrequencyTest extends TestCase { assertEquals("one pct",0.25,f.getPct(1),tolerance); assertEquals("two pct",0.25,f.getPct(Long.valueOf(2)),tolerance); assertEquals("three pct",0.5,f.getPct(threeL),tolerance); + // MATH-329 + assertEquals("three (Object) pct",0.5,f.getPct((Object) (Integer.valueOf(3))),tolerance); assertEquals("five pct",0,f.getPct(5),tolerance); assertEquals("foo pct",0,f.getPct("foo"),tolerance); assertEquals("one cum pct",0.25,f.getCumPct(1),tolerance);