mahout-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sean Owen" <sro...@gmail.com>
Subject Re: asFormatString tests fail
Date Thu, 07 Aug 2008 21:47:16 GMT
Yeah that Map is a HashMap and so has no predictable key ordering.

Sounds like we want a TreeMap (i.e. a SortedMap implementation)?
author, may I change it? :)

On Thu, Aug 7, 2008 at 3:32 PM, Allen Day <allenday@gmail.com> wrote:
> Here's a relevant snippet:
>
>    [junit] Testcase:
> testAsFormatString(org.apache.mahout.matrix.TestSparseVector):
> FAILED
>    [junit] format expected:<[s5, [2:2.2, 1:1.1], 3:3.3, ] > but
> was:<[s5, [1:1.1, 2:2.2], 3:3.3, ] >
>    [junit] junit.framework.ComparisonFailure: format expected:<[s5,
> [2:2.2, 1:1.1], 3:3.3, ] > but was:<[s5, [1:1.1, 2:2.2], 3:3.3, ] >
>    [junit]     at
> org.apache.mahout.matrix.TestSparseVector.testAsFormatString(TestSparseVector.java:40)
>
> I've seen this happen in some of my dev environments but not others.
> The error is because the serialized vector/matrix has transposed some
> of the elements relative to what the unit test expects.  It looks to
> me like this is caused by iterating over the keyset directly rather
> than sorting it first:
>
> SparseVector.java:97
> -------------------------
>  public String asFormatString() {
>    StringBuilder out = new StringBuilder();
>    out.append("[s").append(cardinality).append(", ");
>    for (Integer index : values.keySet())
>      out.append(index).append(':').append(values.get(index)).append(", ");
>    out.append("] ");
>    return out.toString();
>  }
> -------------------------
>
> -Allen
>

Mime
View raw message