Return-Path: Delivered-To: apmail-lucene-mahout-dev-archive@locus.apache.org Received: (qmail 68729 invoked from network); 7 Aug 2008 21:48:53 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 7 Aug 2008 21:48:53 -0000 Received: (qmail 6729 invoked by uid 500); 7 Aug 2008 21:48:51 -0000 Delivered-To: apmail-lucene-mahout-dev-archive@lucene.apache.org Received: (qmail 6715 invoked by uid 500); 7 Aug 2008 21:48:51 -0000 Mailing-List: contact mahout-dev-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: mahout-dev@lucene.apache.org Delivered-To: mailing list mahout-dev@lucene.apache.org Received: (qmail 6704 invoked by uid 99); 7 Aug 2008 21:48:51 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Aug 2008 14:48:51 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of srowen@gmail.com designates 74.125.46.28 as permitted sender) Received: from [74.125.46.28] (HELO yw-out-2324.google.com) (74.125.46.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Aug 2008 21:47:54 +0000 Received: by yw-out-2324.google.com with SMTP id 3so314413ywj.5 for ; Thu, 07 Aug 2008 14:47:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=d0542v0cMIgbmAVLFihFDzK5j6yboGSJjAnCN6ZTCp8=; b=JrbvLxeyMOAk6ijO8/VUaiUvIyJdbZi41Lwdso7zZ0silOeDxa/e5iCsLIz0szzQxk lJMlKDKVScHsNkuSI0fk1uadlo525oKki9H0t3vFrh1ow8vWNWXpdQWWdOI0gfBapOw0 /j5t4YWFo9/hXrm80BKIJi3JeLPew0Kyrv/J4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=C+1YDxM6vaT2Dtq5gnCQ45vH+9XDX+cukEVEF6FetSeF7BlKliU35OYnRbrJim4nQW tHKl1sO53mJY2ZkAVKTrzMyZtULwZH76qosA4dzgxJm2gWkmyWqGj+NtoiGVkCKh5y/b k6tJlDmLFi7I9/0RdR5amr2+PTgFlk4sq2uq8= Received: by 10.150.146.1 with SMTP id t1mr6092328ybd.81.1218145636092; Thu, 07 Aug 2008 14:47:16 -0700 (PDT) Received: by 10.150.98.2 with HTTP; Thu, 7 Aug 2008 14:47:16 -0700 (PDT) Message-ID: Date: Thu, 7 Aug 2008 17:47:16 -0400 From: "Sean Owen" To: mahout-dev@lucene.apache.org Subject: Re: asFormatString tests fail In-Reply-To: <5c24dcc30808071232u25d2ca66u9bc9fe685471a791@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <5c24dcc30808071232u25d2ca66u9bc9fe685471a791@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org 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 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 >