You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mahout.apache.org by sr...@apache.org on 2009/03/08 18:52:20 UTC

svn commit: r751482 [1/2] - in /lucene/mahout/trunk: core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/slopeone/ core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/slopeone/jdbc/ core/src/main/java/org/apache/mahout/classifier/...

Author: srowen
Date: Sun Mar  8 17:52:18 2009
New Revision: 751482

URL: http://svn.apache.org/viewvc?rev=751482&view=rev
Log:
Tons more code inspection-related updates, mostly in test code

Modified:
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/slopeone/MemoryDiffStorage.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/slopeone/jdbc/AbstractJDBCDiffStorage.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/ConfusionMatrix.java
    lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/LoadTest.java
    lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/common/MockRefreshable.java
    lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/eval/AverageAbsoluteDifferenceRecommenderEvaluatorTest.java
    lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/eval/GenericRecommenderIRStatsEvaluatorImplTest.java
    lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/eval/RMSRecommenderEvaluatorTest.java
    lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/neighborhood/DummySimilarity.java
    lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/recommender/MockRecommender.java
    lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/recommender/ReversingRescorer.java
    lucene/mahout/trunk/core/src/test/java/org/apache/mahout/classifier/bayes/BayesClassifierTest.java
    lucene/mahout/trunk/core/src/test/java/org/apache/mahout/classifier/bayes/BayesFeatureMapperTest.java
    lucene/mahout/trunk/core/src/test/java/org/apache/mahout/classifier/bayes/BayesFileFormatterTest.java
    lucene/mahout/trunk/core/src/test/java/org/apache/mahout/classifier/bayes/CBayesClassifierTest.java
    lucene/mahout/trunk/core/src/test/java/org/apache/mahout/clustering/canopy/TestCanopyCreation.java
    lucene/mahout/trunk/core/src/test/java/org/apache/mahout/clustering/canopy/VisibleCanopy.java
    lucene/mahout/trunk/core/src/test/java/org/apache/mahout/clustering/fuzzykmeans/TestFuzzyKmeansClustering.java
    lucene/mahout/trunk/core/src/test/java/org/apache/mahout/clustering/kmeans/TestKmeansClustering.java
    lucene/mahout/trunk/core/src/test/java/org/apache/mahout/clustering/meanshift/TestMeanShift.java
    lucene/mahout/trunk/core/src/test/java/org/apache/mahout/ga/watchmaker/MahoutEvaluatorTest.java
    lucene/mahout/trunk/core/src/test/java/org/apache/mahout/ga/watchmaker/STFitnessEvaluatorTest.java
    lucene/mahout/trunk/core/src/test/java/org/apache/mahout/ga/watchmaker/utils/DummyEvaluator.java
    lucene/mahout/trunk/core/src/test/java/org/apache/mahout/matrix/MatrixTest.java
    lucene/mahout/trunk/core/src/test/java/org/apache/mahout/matrix/TestDenseMatrix.java
    lucene/mahout/trunk/core/src/test/java/org/apache/mahout/matrix/TestDenseVector.java
    lucene/mahout/trunk/core/src/test/java/org/apache/mahout/matrix/TestMatrixView.java
    lucene/mahout/trunk/core/src/test/java/org/apache/mahout/matrix/TestSparseColumnMatrix.java
    lucene/mahout/trunk/core/src/test/java/org/apache/mahout/matrix/TestSparseMatrix.java
    lucene/mahout/trunk/core/src/test/java/org/apache/mahout/matrix/TestSparseRowMatrix.java
    lucene/mahout/trunk/core/src/test/java/org/apache/mahout/matrix/TestSparseVector.java
    lucene/mahout/trunk/core/src/test/java/org/apache/mahout/matrix/TestVectorView.java
    lucene/mahout/trunk/core/src/test/java/org/apache/mahout/matrix/TestVectorWritable.java
    lucene/mahout/trunk/core/src/test/java/org/apache/mahout/matrix/VectorTest.java
    lucene/mahout/trunk/core/src/test/java/org/apache/mahout/utils/DefaultDistanceMeasureTest.java
    lucene/mahout/trunk/core/src/test/java/org/apache/mahout/utils/DefaultWeightedDistanceMeasureTest.java
    lucene/mahout/trunk/core/src/test/java/org/apache/mahout/utils/DummyOutputCollector.java
    lucene/mahout/trunk/core/src/test/java/org/apache/mahout/utils/StringUtilsTest.java
    lucene/mahout/trunk/core/src/test/java/org/apache/mahout/utils/TestEuclideanDistanceMeasure.java
    lucene/mahout/trunk/core/src/test/java/org/apache/mahout/utils/TestManhattanDistanceMeasure.java
    lucene/mahout/trunk/core/src/test/java/org/apache/mahout/utils/TestTanimotoDistanceMeasure.java
    lucene/mahout/trunk/core/src/test/java/org/apache/mahout/utils/TestWeightedEuclideanDistanceMeasureTest.java
    lucene/mahout/trunk/core/src/test/java/org/apache/mahout/utils/TestWeightedManhattanDistanceMeasure.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/CDGA.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/hadoop/CDMahoutEvaluator.java
    lucene/mahout/trunk/examples/src/test/java/org/apache/mahout/ga/watchmaker/cd/hadoop/CDMahoutEvaluatorTest.java

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/slopeone/MemoryDiffStorage.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/slopeone/MemoryDiffStorage.java?rev=751482&r1=751481&r2=751482&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/slopeone/MemoryDiffStorage.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/slopeone/MemoryDiffStorage.java Sun Mar  8 17:52:18 2009
@@ -59,6 +59,7 @@
   private final long maxEntries;
   private final FastMap<Object, FastMap<Object, RunningAverage>> averageDiffs;
   private final Map<Object, RunningAverage> averageItemPref;
+  private final FastSet<Item> allRecommendableItemIDs;
   private final ReadWriteLock buildAverageDiffsLock;
   private final RefreshHelper refreshHelper;
 
@@ -106,6 +107,7 @@
     this.averageDiffs = new FastMap<Object, FastMap<Object, RunningAverage>>();
     this.averageItemPref = new FastMap<Object, RunningAverage>();
     this.buildAverageDiffsLock = new ReentrantReadWriteLock();
+    this.allRecommendableItemIDs = new FastSet<Item>(dataModel.getNumItems());
     this.refreshHelper = new RefreshHelper(new Callable<Object>() {
       @Override
       public Object call() throws TasteException {
@@ -210,6 +212,17 @@
       }
     }
     return result;
+    /*
+    User user = dataModel.getUser(userID);
+    Set<Item> result = allRecommendableItemIDs.clone();
+    Iterator<Item> it = result.iterator();
+    while (it.hasNext()) {
+      if (user.getPreferenceFor(it.next().getID()) == null) {
+        it.remove();
+      }
+    }
+    return result;
+     */
   }
 
   private void buildAverageDiffs() throws TasteException {
@@ -222,32 +235,51 @@
         averageCount = processOneUser(averageCount, user);
       }
 
-      // Go back and prune inconsequential diffs. "Inconsequential" means, here, only represented by one
-      // data point, so possibly unreliable
-      Iterator<FastMap<Object, RunningAverage>> it1 = averageDiffs.values().iterator();
-      while (it1.hasNext()) {
-        FastMap<Object, RunningAverage> map = it1.next();
-        Iterator<RunningAverage> it2 = map.values().iterator();
-        while (it2.hasNext()) {
-          RunningAverage average = it2.next();
-          if (average.getCount() <= 1) {
-            it2.remove();
-          }
-        }
-        if (map.isEmpty()) {
-          it1.remove();
-        } else {
-          map.rehash();
-        }
-      }
-
-      averageDiffs.rehash();
+      pruneInconsequentialDiffs();
+      updateAllRecommendableItems();
 
     } finally {
       buildAverageDiffsLock.writeLock().unlock();
     }
   }
 
+  private void pruneInconsequentialDiffs() {
+    // Go back and prune inconsequential diffs. "Inconsequential" means, here, only represented by one
+    // data point, so possibly unreliable
+    Iterator<FastMap<Object, RunningAverage>> it1 = averageDiffs.values().iterator();
+    while (it1.hasNext()) {
+      FastMap<Object, RunningAverage> map = it1.next();
+      Iterator<RunningAverage> it2 = map.values().iterator();
+      while (it2.hasNext()) {
+        RunningAverage average = it2.next();
+        if (average.getCount() <= 1) {
+          it2.remove();
+        }
+      }
+      if (map.isEmpty()) {
+        it1.remove();
+      } else {
+        map.rehash();
+      }
+    }
+    averageDiffs.rehash();
+  }
+
+  private void updateAllRecommendableItems() throws TasteException {
+    FastSet<Object> ids = new FastSet<Object>(dataModel.getNumItems());
+    for (Map.Entry<Object, FastMap<Object, RunningAverage>> entry : averageDiffs.entrySet()) {
+      ids.add(entry.getKey());
+      for (Object id : entry.getValue().keySet()) {
+        ids.add(id);
+      }
+    }
+    allRecommendableItemIDs.clear();
+    for (Object id : ids) {
+      allRecommendableItemIDs.add(dataModel.getItem(id));
+    }
+    allRecommendableItemIDs.rehash();
+  }
+
   private long processOneUser(long averageCount, User user) {
     log.debug("Processing prefs for user {}", user);
     // Save off prefs for the life of this loop iteration

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/slopeone/jdbc/AbstractJDBCDiffStorage.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/slopeone/jdbc/AbstractJDBCDiffStorage.java?rev=751482&r1=751481&r2=751482&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/slopeone/jdbc/AbstractJDBCDiffStorage.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/cf/taste/impl/recommender/slopeone/jdbc/AbstractJDBCDiffStorage.java Sun Mar  8 17:52:18 2009
@@ -204,38 +204,34 @@
   public void updateItemPref(Object itemID, double prefDelta, boolean remove)
           throws TasteException {
     Connection conn = null;
-    PreparedStatement stmt = null;
     try {
       conn = dataSource.getConnection();
       if (remove) {
-        stmt = doPartialUpdate(removeDiffSQLs[0], itemID, prefDelta, conn);
-        IOUtils.quietClose(stmt);
-        stmt = doPartialUpdate(removeDiffSQLs[1], itemID, prefDelta, conn);
-        IOUtils.quietClose(stmt);
+        doPartialUpdate(removeDiffSQLs[0], itemID, prefDelta, conn);
+        doPartialUpdate(removeDiffSQLs[1], itemID, prefDelta, conn);
       } else {
-        stmt = doPartialUpdate(updateDiffSQLs[0], itemID, prefDelta, conn);
-        IOUtils.quietClose(stmt);        
-        stmt = doPartialUpdate(updateDiffSQLs[1], itemID, prefDelta, conn);
-        IOUtils.quietClose(stmt);
+        doPartialUpdate(updateDiffSQLs[0], itemID, prefDelta, conn);
+        doPartialUpdate(updateDiffSQLs[1], itemID, prefDelta, conn);
       }
     } catch (SQLException sqle) {
       log.warn("Exception while updating item diff", sqle);
       throw new TasteException(sqle);
     } finally {
-      IOUtils.quietClose(null, stmt, conn);
+      IOUtils.quietClose(conn);
     }
   }
 
-  private static PreparedStatement doPartialUpdate(String sql,
-                                                   Object itemID,
-                                                   double prefDelta,
-                                                   Connection conn) throws SQLException {
+  private static void doPartialUpdate(String sql, Object itemID, double prefDelta, Connection conn)
+      throws SQLException {
     PreparedStatement stmt = conn.prepareStatement(sql);
-    stmt.setDouble(1, prefDelta);
-    stmt.setObject(2, itemID);
-    log.debug("Executing SQL update: {}", sql);
-    stmt.executeUpdate();
-    return stmt;
+    try {
+      stmt.setDouble(1, prefDelta);
+      stmt.setObject(2, itemID);
+      log.debug("Executing SQL update: {}", sql);
+      stmt.executeUpdate();
+    } finally {
+      IOUtils.quietClose(stmt);
+    }
   }
 
   @Override

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/ConfusionMatrix.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/ConfusionMatrix.java?rev=751482&r1=751481&r2=751482&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/ConfusionMatrix.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/ConfusionMatrix.java Sun Mar  8 17:52:18 2009
@@ -122,7 +122,7 @@
     incrementCount(correctLabel, classifiedLabel, 1);
   }
 
-  public ConfusionMatrix Merge(ConfusionMatrix b) {
+  public ConfusionMatrix merge(ConfusionMatrix b) {
     if (labels.size() != b.getLabels().size())
       throw new IllegalArgumentException("The Labels do not Match");
 

Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/LoadTest.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/LoadTest.java?rev=751482&r1=751481&r2=751482&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/LoadTest.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/LoadTest.java Sun Mar  8 17:52:18 2009
@@ -65,6 +65,7 @@
 
   private Random random;
 
+  @Override
   public void setUp() throws Exception {
     super.setUp();
     random = RandomUtils.getRandom();
@@ -141,6 +142,7 @@
       this.recommender = recommender;
     }
 
+    @Override
     public Object call() throws TasteException {
       for (int i = 0; i < NUM_USERS / 2; i++) {
         recommender.recommend(String.valueOf(random.nextInt(NUM_USERS)), 10);

Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/common/MockRefreshable.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/common/MockRefreshable.java?rev=751482&r1=751481&r2=751482&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/common/MockRefreshable.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/common/MockRefreshable.java Sun Mar  8 17:52:18 2009
@@ -29,10 +29,12 @@
 
   private int callCount;
 
+  @Override
   public void refresh(Collection<Refreshable> alreadyRefreshed) {
     call();
   }
 
+  @Override
   public Object call() {
     callCount++;
     return null;

Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/eval/AverageAbsoluteDifferenceRecommenderEvaluatorTest.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/eval/AverageAbsoluteDifferenceRecommenderEvaluatorTest.java?rev=751482&r1=751481&r2=751482&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/eval/AverageAbsoluteDifferenceRecommenderEvaluatorTest.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/eval/AverageAbsoluteDifferenceRecommenderEvaluatorTest.java Sun Mar  8 17:52:18 2009
@@ -30,6 +30,7 @@
   public void testEvaluate() throws Exception {
     DataModel model = getDataModel();
     RecommenderBuilder builder = new RecommenderBuilder() {
+      @Override
       public Recommender buildRecommender(DataModel dataModel) throws TasteException {
         return new SlopeOneRecommender(dataModel);
       }

Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/eval/GenericRecommenderIRStatsEvaluatorImplTest.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/eval/GenericRecommenderIRStatsEvaluatorImplTest.java?rev=751482&r1=751481&r2=751482&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/eval/GenericRecommenderIRStatsEvaluatorImplTest.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/eval/GenericRecommenderIRStatsEvaluatorImplTest.java Sun Mar  8 17:52:18 2009
@@ -31,6 +31,7 @@
   public void testEvaluate() throws Exception {
     DataModel model = getDataModel();
     RecommenderBuilder builder = new RecommenderBuilder() {
+      @Override
       public Recommender buildRecommender(DataModel dataModel) throws TasteException {
         return new SlopeOneRecommender(dataModel);
       }

Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/eval/RMSRecommenderEvaluatorTest.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/eval/RMSRecommenderEvaluatorTest.java?rev=751482&r1=751481&r2=751482&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/eval/RMSRecommenderEvaluatorTest.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/eval/RMSRecommenderEvaluatorTest.java Sun Mar  8 17:52:18 2009
@@ -30,6 +30,7 @@
   public void testEvaluate() throws Exception {
     DataModel model = getDataModel();
     RecommenderBuilder builder = new RecommenderBuilder() {
+      @Override
       public Recommender buildRecommender(DataModel dataModel) throws TasteException {
         return new SlopeOneRecommender(dataModel);
       }

Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/neighborhood/DummySimilarity.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/neighborhood/DummySimilarity.java?rev=751482&r1=751481&r2=751482&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/neighborhood/DummySimilarity.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/neighborhood/DummySimilarity.java Sun Mar  8 17:52:18 2009
@@ -28,20 +28,24 @@
 
 final class DummySimilarity implements UserSimilarity, ItemSimilarity {
 
+  @Override
   public double userSimilarity(User user1, User user2) {
     return 1.0 / Math.abs(user1.getPreferencesAsArray()[0].getValue() -
                           user2.getPreferencesAsArray()[0].getValue());
   }
 
+  @Override
   public double itemSimilarity(Item item1, Item item2) {
     // Make up something wacky
     return (double) (item1.hashCode() - item2.hashCode());
   }
 
+  @Override
   public void setPreferenceInferrer(PreferenceInferrer inferrer) {
     throw new UnsupportedOperationException();
   }
 
+  @Override
   public void refresh(Collection<Refreshable> alreadyRefreshed) {
     // do nothing
   }

Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/recommender/MockRecommender.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/recommender/MockRecommender.java?rev=751482&r1=751481&r2=751482&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/recommender/MockRecommender.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/recommender/MockRecommender.java Sun Mar  8 17:52:18 2009
@@ -44,31 +44,37 @@
     this.recommendCount = recommendCount;
   }
 
+  @Override
   public List<RecommendedItem> recommend(Object userID, int howMany) {
     recommendCount.incrementAndGet();
     return Collections.<RecommendedItem>singletonList(
             new GenericRecommendedItem(new GenericItem<String>("1"), 1.0));
   }
 
+  @Override
   public List<RecommendedItem> recommend(Object userID,
                                          int howMany,
                                          Rescorer<Item> rescorer) {
     return recommend(userID, howMany);
   }
 
+  @Override
   public double estimatePreference(Object userID, Object itemID) {
     recommendCount.incrementAndGet();
     return 0.0;
   }
 
+  @Override
   public void setPreference(Object userID, Object itemID, double value) {
     // do nothing
   }
 
+  @Override
   public void removePreference(Object userID, Object itemID) {
     // do nothing
   }
 
+  @Override
   public DataModel getDataModel() {
     User user1 = new GenericUser<String>("1", Collections.<Preference>emptyList());
     User user2 = new GenericUser<String>("2", Collections.<Preference>emptyList());
@@ -80,6 +86,7 @@
     return new GenericDataModel(users);
   }
 
+  @Override
   public void refresh(Collection<Refreshable> alreadyRefreshed) {
     // do nothing
   }

Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/recommender/ReversingRescorer.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/recommender/ReversingRescorer.java?rev=751482&r1=751481&r2=751482&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/recommender/ReversingRescorer.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/cf/taste/impl/recommender/ReversingRescorer.java Sun Mar  8 17:52:18 2009
@@ -25,10 +25,12 @@
  */
 public final class ReversingRescorer<T> implements Rescorer<T> {
 
+  @Override
   public double rescore(T thing, double originalScore) {
     return Double.isNaN(originalScore) ? Double.NaN : -originalScore;
   }
 
+  @Override
   public boolean isFiltered(T thing) {
     return false;
   }

Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/classifier/bayes/BayesClassifierTest.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/classifier/bayes/BayesClassifierTest.java?rev=751482&r1=751481&r2=751482&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/classifier/bayes/BayesClassifierTest.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/classifier/bayes/BayesClassifierTest.java Sun Mar  8 17:52:18 2009
@@ -22,34 +22,36 @@
 import org.apache.mahout.common.Model;
 
 public class BayesClassifierTest extends TestCase {
-  protected Model model;
 
+  protected Model model;
 
   public BayesClassifierTest(String s) {
     super(s);
   }
 
-  protected void setUp() {
+  @Override
+  protected void setUp() throws Exception {
+    super.setUp();
     model = new BayesModel();
     //String[] labels = new String[]{"a", "b", "c", "d", "e"};
     //long[] labelCounts = new long[]{6, 20, 60, 100, 200};
     //String[] features = new String[]{"aa", "bb", "cc", "dd", "ee"};
     model.setSigma_jSigma_k(100.0);
-    
+
     model.setSumFeatureWeight("aa", 100);
     model.setSumFeatureWeight("bb", 100);
     model.setSumFeatureWeight("cc", 100);
     model.setSumFeatureWeight("dd", 100);
     model.setSumFeatureWeight("ee", 100);
-    
+
     model.setSumLabelWeight("a", 1);
     model.setSumLabelWeight("b", 1);
     model.setSumLabelWeight("c", 1);
     model.setSumLabelWeight("d", 1);
     model.setSumLabelWeight("e", 1);
-    
+
     model.initializeWeightMatrix();
-   
+
     model.loadFeatureWeight("a", "aa", 5);
     model.loadFeatureWeight("a", "bb", 1);
 
@@ -67,34 +69,29 @@
     model.loadFeatureWeight("e", "dd", 50);
   }
 
-  protected void tearDown() {
-
-  }
-
   public void test() {
     BayesClassifier classifier = new BayesClassifier();
-    ClassifierResult result;
-    String[] document = new String[]{"aa", "ff"};
-    result = classifier.classify(model, document, "unknown");
-    assertTrue("category is null and it shouldn't be", result != null);
-    assertTrue(result + " is not equal to " + "e", result.getLabel().equals("e"));
+    String[] document = {"aa", "ff"};
+    ClassifierResult result = classifier.classify(model, document, "unknown");
+    assertNotNull("category is null and it shouldn't be", result);
+    assertEquals(result + " is not equal to e", "e", result.getLabel());
 
     document = new String[]{"ff"};
     result = classifier.classify(model, document, "unknown");
-    assertTrue("category is null and it shouldn't be", result != null);
-    assertTrue(result + " is not equal to " + "d", result.getLabel().equals("d"));//GSI: was unknown, but we now just pick the first cat
+    assertNotNull("category is null and it shouldn't be", result);
+    assertEquals(result + " is not equal to d", "d", result.getLabel());//GSI: was unknown, but we now just pick the first cat
 
     document = new String[]{"cc"};
     result = classifier.classify(model, document, "unknown");
-    assertTrue("category is null and it shouldn't be", result != null);
-    assertTrue(result + " is not equal to " + "d", result.getLabel().equals("d"));
+    assertNotNull("category is null and it shouldn't be", result);
+    assertEquals(result + " is not equal to d", "d", result.getLabel());
   }
 
   public void testResults() throws Exception {
     BayesClassifier classifier = new BayesClassifier();
-    String[] document = new String[]{"aa", "ff"};
+    String[] document = {"aa", "ff"};
     ClassifierResult result = classifier.classify(model, document, "unknown");
-    assertTrue("category is null and it shouldn't be", result != null);    
+    assertNotNull("category is null and it shouldn't be", result);
     System.out.println("Result: " + result);
   }
 }
\ No newline at end of file

Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/classifier/bayes/BayesFeatureMapperTest.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/classifier/bayes/BayesFeatureMapperTest.java?rev=751482&r1=751481&r2=751482&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/classifier/bayes/BayesFeatureMapperTest.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/classifier/bayes/BayesFeatureMapperTest.java Sun Mar  8 17:52:18 2009
@@ -11,11 +11,6 @@
 import java.util.List;
 import java.util.Map;
 
-
-/**
- *
- *
- **/
 public class BayesFeatureMapperTest extends TestCase {
 
   public void test() throws Exception {
@@ -31,11 +26,11 @@
     mapper.map(new Text("foo"), new Text("big brown shoe"), output, null);
     Map<String, List<DoubleWritable>> outMap = output.getData();
     System.out.println("Map: " + outMap);
-    assertTrue("outMap is null and it shouldn't be", outMap != null);
+    assertNotNull("outMap is null and it shouldn't be", outMap);
     //TODO: How about not such a lame test here?
     for (Map.Entry<String, List<DoubleWritable>> entry : outMap.entrySet()) {
-      assertTrue("entry.getKey() Size: " + entry.getKey().length() + " is not greater than: " + 0, entry.getKey().length() > 0);
-      assertTrue("entry.getValue() Size: " + entry.getValue().size() + " is not: " + 1, entry.getValue().size() == 1);
+      assertTrue("entry.getKey() Size: " + entry.getKey().length() + " is not greater than: 0", entry.getKey().length() > 0);
+      assertEquals("entry.getValue() Size: " + entry.getValue().size() + " is not: 1", 1, entry.getValue().size());
       assertTrue("value is not valie", entry.getValue().get(0).get() > 0);
     }
 

Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/classifier/bayes/BayesFileFormatterTest.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/classifier/bayes/BayesFileFormatterTest.java?rev=751482&r1=751481&r2=751482&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/classifier/bayes/BayesFileFormatterTest.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/classifier/bayes/BayesFileFormatterTest.java Sun Mar  8 17:52:18 2009
@@ -33,16 +33,18 @@
 import java.nio.charset.Charset;
 
 public class BayesFileFormatterTest extends TestCase {
+
   protected File input;
   protected File out;
   protected String[] words;
 
-
   public BayesFileFormatterTest(String s) {
     super(s);
   }
 
-  protected void setUp() throws IOException {
+  @Override
+  protected void setUp() throws Exception {
+    super.setUp();
     File tmpDir = new File(System.getProperty("java.io.tmpdir"));
     input = new File(tmpDir, "bayes/input");
     out = new File(tmpDir, "bayes/out");
@@ -61,36 +63,33 @@
     }
   }
 
-  protected void tearDown() {
-
-  }
-
   public void test() throws IOException {
     Analyzer analyzer = new WhitespaceAnalyzer();
     File[] files = out.listFiles();
-    assertTrue("files Size: " + files.length + " is not: " + 0, files.length == 0);
+    assertEquals("files Size: " + files.length + " is not: " + 0, 0, files.length);
     Charset charset = Charset.forName("UTF-8");
     BayesFileFormatter.format("animal", analyzer, input, charset, out);
 
     files = out.listFiles();
-    assertTrue("files Size: " + files.length + " is not: " + words.length, files.length == words.length);
+    assertEquals("files Size: " + files.length + " is not: " + words.length, files.length, words.length);
     for (File file : files) {
       //should only be one line in the file, and it should be label label
       BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), charset));
       String line = reader.readLine().trim();
       String label = "animal" + '\t' + file.getName();
-      assertTrue(line + ":::: is not equal to " + label + "::::", line.equals(label));
+      assertEquals(line + ":::: is not equal to " + label + "::::", line, label);
+      reader.close();
     }
   }
 
   public void testCollapse() throws Exception {
     Analyzer analyzer = new WhitespaceAnalyzer();
     File[] files = out.listFiles();
-    assertTrue("files Size: " + files.length + " is not: " + 0, files.length == 0);
+    assertEquals("files Size: " + files.length + " is not: " + 0, 0, files.length);
     Charset charset = Charset.forName("UTF-8");
     BayesFileFormatter.collapse("animal", analyzer, input, charset, new File(out, "animal"));
     files = out.listFiles();
-    assertTrue("files Size: " + files.length + " is not: " + 1, files.length == 1);
+    assertEquals("files Size: " + files.length + " is not: " + 1, 1, files.length);
     BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(files[0]), charset));
     String line;
     int count = 0;
@@ -99,7 +98,8 @@
       System.out.println("Line: " + line);
       count++;
     }
-    assertTrue(count + " does not equal: " + words.length, count == words.length);
+    reader.close();
+    assertEquals(count + " does not equal: " + words.length, count, words.length);
 
   }
 }
\ No newline at end of file

Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/classifier/bayes/CBayesClassifierTest.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/classifier/bayes/CBayesClassifierTest.java?rev=751482&r1=751481&r2=751482&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/classifier/bayes/CBayesClassifierTest.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/classifier/bayes/CBayesClassifierTest.java Sun Mar  8 17:52:18 2009
@@ -22,26 +22,28 @@
 import org.apache.mahout.classifier.cbayes.CBayesModel;
 
 public class CBayesClassifierTest extends TestCase {
-  protected CBayesModel model;
 
+  protected CBayesModel model;
 
   public CBayesClassifierTest(String s) {
     super(s);
   }
 
-  protected void setUp() {
+  @Override
+  protected void setUp() throws Exception {
+    super.setUp();
     model = new CBayesModel();
     //String[] labels = new String[]{"a", "b", "c", "d", "e"};
     //long[] labelCounts = new long[]{6, 20, 60, 100, 200};
     //String[] features = new String[]{"aa", "bb", "cc", "dd", "ee"};
     model.setSigma_jSigma_k(500.0);
-    
+
     model.setSumFeatureWeight("aa", 80);
     model.setSumFeatureWeight("bb", 21);
     model.setSumFeatureWeight("cc", 60);
     model.setSumFeatureWeight("dd", 115);
     model.setSumFeatureWeight("ee", 100);
-    
+
     model.setSumLabelWeight("a", 100);
     model.setSumLabelWeight("b", 100);
     model.setSumLabelWeight("c", 100);
@@ -53,10 +55,10 @@
     model.setThetaNormalizer("c", -100);
     model.setThetaNormalizer("d", -100);
     model.setThetaNormalizer("e", -100);
-    
+
     model.initializeNormalizer();
     model.initializeWeightMatrix();
-   
+
     model.loadFeatureWeight("a", "aa", 5);
     model.loadFeatureWeight("a", "bb", 1);
 
@@ -74,34 +76,29 @@
     model.loadFeatureWeight("e", "dd", 50);
   }
 
-  protected void tearDown() {
-
-  }
-
   public void test() {
     BayesClassifier classifier = new BayesClassifier();
-    ClassifierResult result;
-    String[] document = new String[]{"aa", "ff"};
-    result = classifier.classify(model, document, "unknown");
-    assertTrue("category is null and it shouldn't be", result != null);
-    assertTrue(result + " is not equal to " + "e", result.getLabel().equals("e"));
+    String[] document = {"aa", "ff"};
+    ClassifierResult result = classifier.classify(model, document, "unknown");
+    assertNotNull("category is null and it shouldn't be", result);
+    assertEquals(result + " is not equal to e", "e", result.getLabel());
 
     document = new String[]{"ff"};
     result = classifier.classify(model, document, "unknown");
-    assertTrue("category is null and it shouldn't be", result != null);
-    assertTrue(result + " is not equal to " + "d", result.getLabel().equals("d"));
+    assertNotNull("category is null and it shouldn't be", result);
+    assertEquals(result + " is not equal to d", "d", result.getLabel());
 
     document = new String[]{"cc"};
     result = classifier.classify(model, document, "unknown");
-    assertTrue("category is null and it shouldn't be", result != null);
-    assertTrue(result + " is not equal to " + "d", result.getLabel().equals("d"));
+    assertNotNull("category is null and it shouldn't be", result);
+    assertEquals(result + " is not equal to d", "d", result.getLabel());
   }
 
   public void testResults() throws Exception {
     BayesClassifier classifier = new BayesClassifier();
-    String[] document = new String[]{"aa", "ff"};
+    String[] document = {"aa", "ff"};
     ClassifierResult result = classifier.classify(model, document, "unknown");
-    assertTrue("category is null and it shouldn't be", result != null);    
+    assertNotNull("category is null and it shouldn't be", result);
     System.out.println("Result: " + result);
   }
 }
\ No newline at end of file

Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/clustering/canopy/TestCanopyCreation.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/clustering/canopy/TestCanopyCreation.java?rev=751482&r1=751481&r2=751482&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/clustering/canopy/TestCanopyCreation.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/clustering/canopy/TestCanopyCreation.java Sun Mar  8 17:52:18 2009
@@ -70,10 +70,9 @@
     super(name);
   }
 
-  private List<Vector> getPoints(double[][] raw) {
+  private static List<Vector> getPoints(double[][] raw) {
     List<Vector> points = new ArrayList<Vector>();
-    for (int i = 0; i < raw.length; i++) {
-      double[] fr = raw[i];
+    for (double[] fr : raw) {
       Vector vec = new SparseVector(fr.length);
       vec.assign(fr);
       points.add(vec);
@@ -81,10 +80,11 @@
     return points;
   }
 
-  private List<Text> getFormattedPoints(List<Vector> points) {
+  private static List<Text> getFormattedPoints(List<Vector> points) {
     List<Text> result = new ArrayList<Text>();
-    for (Vector point : points)
+    for (Vector point : points) {
       result.add(new Text(point.asFormatString()));
+    }
     return result;
   }
 
@@ -113,7 +113,7 @@
    * 
    * @param canopies
    */
-  private void verifyCanopies(List<Canopy> canopies, List<Canopy> reference) {
+  private static void verifyCanopies(List<Canopy> canopies, List<Canopy> reference) {
     assertEquals("number of canopies", reference.size(), canopies.size());
     for (int canopyIx = 0; canopyIx < canopies.size(); canopyIx++) {
       Canopy refCanopy = reference.get(canopyIx);
@@ -135,18 +135,18 @@
    * @param canopies
    *            a List<Canopy>
    */
-  private void prtCanopies(List<Canopy> canopies) {
+  private static void printCanopies(List<Canopy> canopies) {
     for (Canopy canopy : canopies) {
       System.out.println(canopy.toString());
     }
   }
 
-  private void writePointsToFile(List<Vector> points, String fileName)
+  private static void writePointsToFile(List<Vector> points, String fileName)
       throws IOException {
     writePointsToFileWithPayload(points, fileName, "");
   }
 
-  private void writePointsToFileWithPayload(List<Vector> points,
+  private static void writePointsToFileWithPayload(List<Vector> points,
       String fileName, String payload) throws IOException {
     BufferedWriter output = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileName), Charset.forName("UTF-8")));
     for (Vector point : points) {
@@ -158,18 +158,20 @@
     output.close();
   }
 
-  private void rmr(String path) throws Exception {
+  private static void rmr(String path) throws Exception {
     File f = new File(path);
     if (f.exists()) {
       if (f.isDirectory()) {
         String[] contents = f.list();
-        for (int i = 0; i < contents.length; i++)
-          rmr(f.toString() + File.separator + contents[i]);
+        for (String content : contents) {
+          rmr(f.toString() + File.separator + content);
+        }
       }
       f.delete();
     }
   }
 
+  @Override
   protected void setUp() throws Exception {
     super.setUp();
     rmr("output");
@@ -189,7 +191,7 @@
    *            a List<Canopy>
    * @return the List<Vector>
    */
-  List<Vector> populateCentroids(List<Canopy> canopies) {
+  static List<Vector> populateCentroids(List<Canopy> canopies) {
     List<Vector> result = new ArrayList<Vector>();
     for (Canopy canopy : canopies)
       result.add(canopy.computeCentroid());
@@ -209,7 +211,7 @@
    *            the T2 distance threshold
    * @return the List<Canopy> created
    */
-  List<Canopy> populateCanopies(DistanceMeasure measure, List<Vector> points,
+  static List<Canopy> populateCanopies(DistanceMeasure measure, List<Vector> points,
       double t1, double t2) {
     List<Canopy> canopies = new ArrayList<Canopy>();
     Canopy.config(measure, t1, t2);
@@ -253,7 +255,7 @@
   public void testReferenceManhattan() throws Exception {
     System.out.println("testReferenceManhattan");
     // see setUp for cluster creation
-    prtCanopies(referenceManhattan);
+    printCanopies(referenceManhattan);
     assertEquals("number of canopies", 3, referenceManhattan.size());
     for (int canopyIx = 0; canopyIx < referenceManhattan.size(); canopyIx++) {
       Canopy testCanopy = referenceManhattan.get(canopyIx);
@@ -265,7 +267,7 @@
       double[] refCentroid = expectedCentroids[canopyIx];
       Vector testCentroid = testCanopy.computeCentroid();
       for (int pointIx = 0; pointIx < refCentroid.length; pointIx++) {
-        assertEquals("canopy centroid " + canopyIx + "[" + pointIx + "]",
+        assertEquals("canopy centroid " + canopyIx + '[' + pointIx + ']',
             refCentroid[pointIx], testCentroid.get(pointIx));
       }
     }
@@ -280,7 +282,7 @@
   public void testReferenceEuclidean() throws Exception {
     System.out.println("testReferenceEuclidean()");
     // see setUp for cluster creation
-    prtCanopies(referenceEuclidean);
+    printCanopies(referenceEuclidean);
     assertEquals("number of canopies", 3, referenceManhattan.size());
     for (int canopyIx = 0; canopyIx < referenceManhattan.size(); canopyIx++) {
       Canopy testCanopy = referenceEuclidean.get(canopyIx);
@@ -292,7 +294,7 @@
       double[] refCentroid = expectedCentroids[canopyIx];
       Vector testCentroid = testCanopy.computeCentroid();
       for (int pointIx = 0; pointIx < refCentroid.length; pointIx++) {
-        assertEquals("canopy centroid " + canopyIx + "[" + pointIx + "]",
+        assertEquals("canopy centroid " + canopyIx + '[' + pointIx + ']',
             refCentroid[pointIx], testCentroid.get(pointIx));
       }
     }
@@ -313,7 +315,7 @@
       Canopy.addPointToCanopies(point, canopies);
 
     System.out.println("testIterativeManhattan");
-    prtCanopies(canopies);
+    printCanopies(canopies);
     verifyManhattanCanopies(canopies);
   }
 
@@ -332,7 +334,7 @@
       Canopy.addPointToCanopies(point, canopies);
 
     System.out.println("testIterativeEuclidean");
-    prtCanopies(canopies);
+    printCanopies(canopies);
     verifyEuclideanCanopies(canopies);
   }
 

Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/clustering/canopy/VisibleCanopy.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/clustering/canopy/VisibleCanopy.java?rev=751482&r1=751481&r2=751482&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/clustering/canopy/VisibleCanopy.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/clustering/canopy/VisibleCanopy.java Sun Mar  8 17:52:18 2009
@@ -41,6 +41,7 @@
    *
    * @param point a point
    */
+  @Override
   public void addPoint(Vector point) {
     super.addPoint(point);
     points.add(point);
@@ -52,6 +53,7 @@
    *
    * @return
    */
+  @Override
   public String toString() {
     String out = super.toString() + ": ";
     for (Vector pt : points)

Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/clustering/fuzzykmeans/TestFuzzyKmeansClustering.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/clustering/fuzzykmeans/TestFuzzyKmeansClustering.java?rev=751482&r1=751481&r2=751482&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/clustering/fuzzykmeans/TestFuzzyKmeansClustering.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/clustering/fuzzykmeans/TestFuzzyKmeansClustering.java Sun Mar  8 17:52:18 2009
@@ -44,18 +44,20 @@
 
 public class TestFuzzyKmeansClustering extends TestCase {
 
-  private void rmr(String path) throws Exception {
+  private static void rmr(String path) throws Exception {
     File f = new File(path);
     if (f.exists()) {
       if (f.isDirectory()) {
         String[] contents = f.list();
-        for (int i = 0; i < contents.length; i++)
-          rmr(f.toString() + File.separator + contents[i]);
+        for (String content : contents) {
+          rmr(f.toString() + File.separator + content);
+        }
       }
       f.delete();
     }
   }
 
+  @Override
   protected void setUp() throws Exception {
     super.setUp();
     rmr("output");
@@ -82,11 +84,11 @@
 
   }
 
-  public void referenceFuzzyKMeans(List<Vector> points,
+  public static void referenceFuzzyKMeans(List<Vector> points,
       List<SoftCluster> clusterList, Map<String, String> pointClusterInfo,
       String distanceMeasureClass, double threshold, int numIter)
       throws Exception {
-    final ClassLoader ccl = Thread.currentThread().getContextClassLoader();
+    ClassLoader ccl = Thread.currentThread().getContextClassLoader();
     Class<?> cl = ccl.loadClass(distanceMeasureClass);
 
     DistanceMeasure measure = (DistanceMeasure) cl.newInstance();
@@ -98,9 +100,8 @@
     computeCluster(points, clusterList, measure, pointClusterInfo);
   }
 
-  public boolean iterateReference(List<Vector> points,
+  public static boolean iterateReference(List<Vector> points,
       List<SoftCluster> clusterList, DistanceMeasure measure) {
-    boolean converged = true;
     // for each
     for (Vector point : points) {
       List<Double> clusterDistanceList = new ArrayList<Double>();
@@ -115,6 +116,7 @@
             Math.pow(probWeight, SoftCluster.getM()));
       }
     }
+    boolean converged = true;
     for (SoftCluster cluster : clusterList) {
       if (!cluster.computeConvergence())
         converged = false;
@@ -127,12 +129,12 @@
 
   }
 
-  public void computeCluster(List<Vector> points,
+  public static void computeCluster(List<Vector> points,
       List<SoftCluster> clusterList, DistanceMeasure measure,
       Map<String, String> pointClusterInfo) {
 
     for (Vector point : points) {
-      StringBuffer outputValue = new StringBuffer("[");
+      StringBuilder outputValue = new StringBuilder("[");
       List<Double> clusterDistanceList = new ArrayList<Double>();
       for (SoftCluster cluster : clusterList) {
         clusterDistanceList.add(measure.distance(point, cluster.getCenter()));
@@ -146,7 +148,7 @@
 
       pointClusterInfo.put(point.asFormatString().trim(), outputValue
           .toString().trim()
-          + "]");
+          + ']');
     }
   }
 
@@ -228,8 +230,8 @@
         SoftCluster cluster = new SoftCluster(vec);
         // add the center so the centroid will be correct upon output
         cluster.addPoint(cluster.getCenter(), 1);
-        writer.write(cluster.getIdentifier() + "\t"
-            + SoftCluster.formatCluster(cluster) + "\n");
+        writer.write(cluster.getIdentifier() + '\t'
+            + SoftCluster.formatCluster(cluster) + '\n');
 
       }
       writer.flush();

Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/clustering/kmeans/TestKmeansClustering.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/clustering/kmeans/TestKmeansClustering.java?rev=751482&r1=751481&r2=751482&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/clustering/kmeans/TestKmeansClustering.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/clustering/kmeans/TestKmeansClustering.java Sun Mar  8 17:52:18 2009
@@ -56,18 +56,20 @@
       { 1, 1, 1, 1, 1, 2, 2 }, { 1, 1, 1, 1, 1, 1, 2, 1 },
       { 1, 1, 1, 1, 1, 1, 1, 1, 1 } };
 
-  private void rmr(String path) throws Exception {
+  private static void rmr(String path) throws Exception {
     File f = new File(path);
     if (f.exists()) {
       if (f.isDirectory()) {
         String[] contents = f.list();
-        for (int i = 0; i < contents.length; i++)
-          rmr(f.toString() + File.separator + contents[i]);
+        for (String content : contents) {
+          rmr(f.toString() + File.separator + content);
+        }
       }
       f.delete();
     }
   }
 
+  @Override
   protected void setUp() throws Exception {
     super.setUp();
     rmr("output");
@@ -88,7 +90,7 @@
    * @param maxIter
    *            the maximum number of iterations
    */
-  private void referenceKmeans(List<Vector> points, List<Cluster> clusters,
+  private static void referenceKmeans(List<Vector> points, List<Cluster> clusters,
       DistanceMeasure measure, int maxIter) {
     boolean converged = false;
     int iteration = 0;
@@ -109,10 +111,8 @@
    *            a DistanceMeasure to use
    * @return
    */
-  private boolean iterateReference(List<Vector> points, List<Cluster> clusters,
+  private static boolean iterateReference(List<Vector> points, List<Cluster> clusters,
       DistanceMeasure measure) {
-    boolean converged;
-    converged = true;
     // iterate through all points, assigning each to the nearest cluster
     for (Vector point : points) {
       Cluster closestCluster = null;
@@ -127,6 +127,7 @@
       closestCluster.addPoint(point);
     }
     // test for convergence
+    boolean converged = true;
     for (Cluster cluster : clusters) {
       if (!cluster.computeConvergence())
         converged = false;
@@ -140,8 +141,7 @@
 
   public static List<Vector> getPoints(double[][] raw) {
     List<Vector> points = new ArrayList<Vector>();
-    for (int i = 0; i < raw.length; i++) {
-      double[] fr = raw[i];
+    for (double[] fr : raw) {
       Vector vec = new SparseVector(fr.length);
       vec.assign(fr);
       points.add(vec);
@@ -160,7 +160,7 @@
     Cluster.config(measure, 0.001);
     // try all possible values of k
     for (int k = 0; k < points.size(); k++) {
-      System.out.println("Test k=" + (k + 1) + ":");
+      System.out.println("Test k=" + (k + 1) + ':');
       // pick k initial cluster centers at random
       List<Cluster> clusters = new ArrayList<Cluster>();
       for (int i = 0; i < k + 1; i++) {
@@ -337,8 +337,7 @@
 
       // now verify that all clusters have correct centers
       converged = true;
-      for (int i = 0; i < reference.size(); i++) {
-        Cluster ref = reference.get(i);
+      for (Cluster ref : reference) {
         String key = ref.getIdentifier();
         List<Text> values = collector3.getValue(key);
         String value = values.get(0).toString();
@@ -416,10 +415,10 @@
       reader.close();
       if (k == 2)
         // cluster 3 is empty so won't appear in output
-        assertEquals("clusters[" + k + "]", expect.length - 1, collector
+        assertEquals("clusters[" + k + ']', expect.length - 1, collector
             .getKeys().size());
       else
-        assertEquals("clusters[" + k + "]", expect.length, collector.getKeys()
+        assertEquals("clusters[" + k + ']', expect.length, collector.getKeys()
             .size());
     }
   }
@@ -430,7 +429,7 @@
    * 
    * @throws Exception
    */
-  public void textKMeansWithCanopyClusterInput() throws Exception {
+  public static void textKMeansWithCanopyClusterInput() throws Exception {
     List<Vector> points = getPoints(reference);
     File testData = new File("testdata");
     if (!testData.exists())

Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/clustering/meanshift/TestMeanShift.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/clustering/meanshift/TestMeanShift.java?rev=751482&r1=751481&r2=751482&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/clustering/meanshift/TestMeanShift.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/clustering/meanshift/TestMeanShift.java Sun Mar  8 17:52:18 2009
@@ -59,7 +59,7 @@
    * 
    * @param canopies a List<Canopy>
    */
-  private void prtCanopies(List<MeanShiftCanopy> canopies) {
+  private static void printCanopies(List<MeanShiftCanopy> canopies) {
     for (MeanShiftCanopy canopy : canopies) {
       System.out.println(canopy.toString());
     }
@@ -73,7 +73,7 @@
    * TODO: handle payloads associated with points. Currently they are ignored
    * @throws IOException
    */
-  private void writePointsToFileWithPayload(Vector[] points, String fileName,
+  private static void writePointsToFileWithPayload(Vector[] points, String fileName,
       String payload) throws IOException {
     BufferedWriter output = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileName), Charset.forName("UTF-8")));
     for (Vector point : points) {
@@ -96,8 +96,9 @@
     if (f.exists()) {
       if (f.isDirectory()) {
         String[] contents = f.list();
-        for (int i = 0; i < contents.length; i++)
-          rmr(f.toString() + File.separator + contents[i]);
+        for (String content : contents) {
+          rmr(f.toString() + File.separator + content);
+        }
       }
       f.delete();
     }
@@ -119,14 +120,16 @@
       for (Vector pt : canopy.getBoundPoints())
         out[(int) pt.getQuick(0)][(int) pt.getQuick(1)] = (char) ch;
     }
-    for (int i = 0; i < out.length; i++)
-      System.out.println(out[i]);
+    for (char[] anOut : out) {
+      System.out.println(anOut);
+    }
   }
 
   private List<MeanShiftCanopy> getInitialCanopies() {
     List<MeanShiftCanopy> canopies = new ArrayList<MeanShiftCanopy>();
-    for (int i = 0; i < raw.length; i++)
-      canopies.add(new MeanShiftCanopy(raw[i]));
+    for (Vector aRaw : raw) {
+      canopies.add(new MeanShiftCanopy(aRaw));
+    }
     return canopies;
   }
 
@@ -160,8 +163,9 @@
     MeanShiftCanopy.config(new EuclideanDistanceMeasure(), 4.0, 1.0, 0.5);
     List<MeanShiftCanopy> canopies = new ArrayList<MeanShiftCanopy>();
     // add all points to the canopies
-    for (int i = 0; i < raw.length; i++)
-      MeanShiftCanopy.mergeCanopy(new MeanShiftCanopy(raw[i]), canopies);
+    for (Vector aRaw : raw) {
+      MeanShiftCanopy.mergeCanopy(new MeanShiftCanopy(aRaw), canopies);
+    }
     boolean done = false;
     int iter = 1;
     while (!done) {// shift canopies to their centroids
@@ -172,7 +176,7 @@
         MeanShiftCanopy.mergeCanopy(canopy, migratedCanopies);
       }
       canopies = migratedCanopies;
-      prtCanopies(canopies);
+      printCanopies(canopies);
       printImage(canopies);
       System.out.println(iter++);
     }
@@ -194,12 +198,14 @@
     List<MeanShiftCanopy> canopies = getInitialCanopies();
     // build the reference set
     List<MeanShiftCanopy> refCanopies = new ArrayList<MeanShiftCanopy>();
-    for (int i = 0; i < raw.length; i++)
-      MeanShiftCanopy.mergeCanopy(new MeanShiftCanopy(raw[i]), refCanopies);
+    for (Vector aRaw : raw) {
+      MeanShiftCanopy.mergeCanopy(new MeanShiftCanopy(aRaw), refCanopies);
+    }
 
     // map the data
-    for (MeanShiftCanopy canopy : canopies)
+    for (MeanShiftCanopy canopy : canopies) {
       mapper.map(new Text(), new Text(canopy.toString()), collector, null);
+    }
     assertEquals("Number of map results", 100, collector.getData().size());
     // now combine the mapper output
     MeanShiftCanopy.config(euclideanDistanceMeasure, 4, 1, 0.5);
@@ -225,13 +231,13 @@
       canopyMap.put(dc.getIdentifier(), dc);
     }
     // compare the maps
-    for (String id : refCanopyMap.keySet()) {
-      MeanShiftCanopy ref = refCanopyMap.get(id);
+    for (Map.Entry<String, MeanShiftCanopy> stringMeanShiftCanopyEntry : refCanopyMap.entrySet()) {
+      MeanShiftCanopy ref = stringMeanShiftCanopyEntry.getValue();
 
       MeanShiftCanopy canopy = canopyMap.get((ref.isConverged() ? "V" : "C")
           + (ref.getCanopyId() - raw.length));
       assertEquals("ids", ref.getCanopyId(), canopy.getCanopyId() + 100);
-      assertEquals("centers(" + ref.getIdentifier() + ")", ref.getCenter()
+      assertEquals("centers(" + ref.getIdentifier() + ')', ref.getCenter()
           .asWritableComparable().toString(), canopy.getCenter()
           .asWritableComparable().toString());
       assertEquals("bound points", ref.getBoundPoints().size(), canopy
@@ -256,19 +262,24 @@
     List<MeanShiftCanopy> canopies = getInitialCanopies();
     // build the reference set
     List<MeanShiftCanopy> refCanopies = new ArrayList<MeanShiftCanopy>();
-    for (int i = 0; i < raw.length; i++)
-      MeanShiftCanopy.mergeCanopy(new MeanShiftCanopy(raw[i]), refCanopies);
+    for (Vector aRaw : raw) {
+      MeanShiftCanopy.mergeCanopy(new MeanShiftCanopy(aRaw), refCanopies);
+    }
     List<MeanShiftCanopy> refCanopies2 = new ArrayList<MeanShiftCanopy>();
-    for (MeanShiftCanopy canopy : refCanopies)
+    for (MeanShiftCanopy canopy : refCanopies) {
       canopy.shiftToMean();
-    for (MeanShiftCanopy canopy : refCanopies)
+    }
+    for (MeanShiftCanopy canopy : refCanopies) {
       MeanShiftCanopy.mergeCanopy(canopy, refCanopies2);
-    for (MeanShiftCanopy canopy : refCanopies)
+    }
+    for (MeanShiftCanopy canopy : refCanopies) {
       canopy.shiftToMean();
+    }
 
     // map the data
-    for (MeanShiftCanopy canopy : canopies)
+    for (MeanShiftCanopy canopy : canopies) {
       mapper.map(new Text(), new Text(canopy.toString()), collector, null);
+    }
     assertEquals("Number of map results", 100, collector.getData().size());
     // now combine the mapper output
     MeanShiftCanopy.config(euclideanDistanceMeasure, 4, 1, 0.5);

Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/ga/watchmaker/MahoutEvaluatorTest.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/ga/watchmaker/MahoutEvaluatorTest.java?rev=751482&r1=751481&r2=751482&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/ga/watchmaker/MahoutEvaluatorTest.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/ga/watchmaker/MahoutEvaluatorTest.java Sun Mar  8 17:52:18 2009
@@ -66,7 +66,7 @@
     storeLoadPopulation(population);
   }
 
-  private void storeLoadPopulation(List<DummyCandidate> population)
+  private static void storeLoadPopulation(List<DummyCandidate> population)
       throws IOException {
     FileSystem fs = FileSystem.get(new Configuration());
     Path f = new Path("build/test.txt");
@@ -86,13 +86,13 @@
     }
   }
 
-  private void loadPopulation(FileSystem fs, Path f,
+  private static void loadPopulation(FileSystem fs, Path f,
       List<DummyCandidate> population) throws IOException {
     FSDataInputStream in = fs.open(f);
     BufferedReader reader = new BufferedReader(new InputStreamReader(in));
-    String s;
 
     try {
+      String s;
       while ((s = reader.readLine()) != null) {
         population.add((DummyCandidate) StringUtils.fromString(s));
       }

Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/ga/watchmaker/STFitnessEvaluatorTest.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/ga/watchmaker/STFitnessEvaluatorTest.java?rev=751482&r1=751481&r2=751482&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/ga/watchmaker/STFitnessEvaluatorTest.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/ga/watchmaker/STFitnessEvaluatorTest.java Sun Mar  8 17:52:18 2009
@@ -110,7 +110,7 @@
     assertEquals(2, mock.getNbCalls());
   }
 
-  private List<Integer> randomInts(int size, Random rng) {
+  private static List<Integer> randomInts(int size, Random rng) {
     List<Integer> population = new ArrayList<Integer>();
     for (int index = 0; index < size; index++)
       population.add(rng.nextInt());
@@ -118,7 +118,7 @@
     return population;
   }
 
-  private List<Double> randomFloats(int size, Random rng) {
+  private static List<Double> randomFloats(int size, Random rng) {
     List<Double> population = new ArrayList<Double>();
     for (int index = 0; index < size; index++)
       population.add(rng.nextDouble());

Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/ga/watchmaker/utils/DummyEvaluator.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/ga/watchmaker/utils/DummyEvaluator.java?rev=751482&r1=751481&r2=751482&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/ga/watchmaker/utils/DummyEvaluator.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/ga/watchmaker/utils/DummyEvaluator.java Sun Mar  8 17:52:18 2009
@@ -45,6 +45,7 @@
     evaluations.clear();
   }
   
+  @Override
   public double getFitness(DummyCandidate candidate,
       List<? extends DummyCandidate> population) {
     if (evaluations.containsKey(candidate.getIndex()))
@@ -56,6 +57,7 @@
     return fitness;
   }
 
+  @Override
   public boolean isNatural() {
     return false;
   }

Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/matrix/MatrixTest.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/matrix/MatrixTest.java?rev=751482&r1=751481&r2=751482&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/matrix/MatrixTest.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/matrix/MatrixTest.java Sun Mar  8 17:52:18 2009
@@ -29,10 +29,11 @@
 
   protected Matrix test;
 
-  public MatrixTest(String name) {
+  protected MatrixTest(String name) {
     super(name);
   }
 
+  @Override
   protected void setUp() throws Exception {
     super.setUp();
     test = matrixFactory(values);
@@ -49,10 +50,10 @@
   public void testCopy() {
     int[] c = test.cardinality();
     Matrix copy = test.copy();
-    assertTrue("wrong class", copy.getClass().equals(test.getClass()));
+    assertEquals("wrong class", copy.getClass(), test.getClass());
     for (int row = 0; row < c[ROW]; row++)
       for (int col = 0; col < c[COL]; col++)
-        assertEquals("value[" + row + "][" + col + "]",
+        assertEquals("value[" + row + "][" + col + ']',
                 test.getQuick(row, col), copy.getQuick(row, col));
   }
 
@@ -60,7 +61,7 @@
     int[] c = test.cardinality();
     for (int row = 0; row < c[ROW]; row++)
       for (int col = 0; col < c[COL]; col++)
-        assertEquals("value[" + row + "][" + col + "]", values[row][col], test
+        assertEquals("value[" + row + "][" + col + ']', values[row][col], test
                 .getQuick(row, col));
   }
 
@@ -71,14 +72,14 @@
 
   public void testLike() {
     Matrix like = test.like();
-    assertTrue("type", like.getClass().equals(test.getClass()));
+    assertEquals("type", like.getClass(), test.getClass());
     assertEquals("rows", test.cardinality()[ROW], like.cardinality()[ROW]);
     assertEquals("columns", test.cardinality()[COL], like.cardinality()[COL]);
   }
 
   public void testLikeIntInt() {
     Matrix like = test.like(4, 4);
-    assertTrue("type", like.getClass().equals(test.getClass()));
+    assertEquals("type", like.getClass(), test.getClass());
     assertEquals("rows", 4, like.cardinality()[ROW]);
     assertEquals("columns", 4, like.cardinality()[COL]);
   }
@@ -88,7 +89,7 @@
     for (int row = 0; row < c[ROW]; row++)
       for (int col = 0; col < c[COL]; col++) {
         test.setQuick(row, col, 1.23);
-        assertEquals("value[" + row + "][" + col + "]", 1.23, test.getQuick(
+        assertEquals("value[" + row + "][" + col + ']', 1.23, test.getQuick(
                 row, col));
       }
   }
@@ -104,7 +105,7 @@
     int[] c = test.cardinality();
     for (int row = 0; row < c[ROW]; row++)
       for (int col = 0; col < c[COL]; col++)
-        assertEquals("value[" + row + "][" + col + "]", values[row][col],
+        assertEquals("value[" + row + "][" + col + ']', values[row][col],
                 array[row][col]);
   }
 
@@ -115,7 +116,7 @@
     int[] c = view.cardinality();
     for (int row = 0; row < c[ROW]; row++)
       for (int col = 0; col < c[COL]; col++)
-        assertEquals("value[" + row + "][" + col + "]",
+        assertEquals("value[" + row + "][" + col + ']',
                 values[row + 1][col + 1], view.getQuick(row, col));
   }
 
@@ -163,7 +164,7 @@
     test.assign(4.53);
     for (int row = 0; row < c[ROW]; row++)
       for (int col = 0; col < c[COL]; col++)
-        assertEquals("value[" + row + "][" + col + "]", 4.53, test.getQuick(
+        assertEquals("value[" + row + "][" + col + ']', 4.53, test.getQuick(
                 row, col));
   }
 
@@ -172,7 +173,7 @@
     test.assign(new double[3][2]);
     for (int row = 0; row < c[ROW]; row++)
       for (int col = 0; col < c[COL]; col++)
-        assertEquals("value[" + row + "][" + col + "]", 0.0, test.getQuick(row,
+        assertEquals("value[" + row + "][" + col + ']', 0.0, test.getQuick(row,
                 col));
   }
 
@@ -191,7 +192,7 @@
     test.assign(test, new PlusFunction());
     for (int row = 0; row < c[ROW]; row++)
       for (int col = 0; col < c[COL]; col++)
-        assertEquals("value[" + row + "][" + col + "]", 2 * values[row][col],
+        assertEquals("value[" + row + "][" + col + ']', 2 * values[row][col],
                 test.getQuick(row, col));
   }
 
@@ -210,7 +211,7 @@
     value.assign(test);
     for (int row = 0; row < c[ROW]; row++)
       for (int col = 0; col < c[COL]; col++)
-        assertEquals("value[" + row + "][" + col + "]",
+        assertEquals("value[" + row + "][" + col + ']',
                 test.getQuick(row, col), value.getQuick(row, col));
   }
 
@@ -228,7 +229,7 @@
     test.assign(new NegateFunction());
     for (int row = 0; row < c[ROW]; row++)
       for (int col = 0; col < c[COL]; col++)
-        assertEquals("value[" + row + "][" + col + "]", -values[row][col], test
+        assertEquals("value[" + row + "][" + col + ']', -values[row][col], test
                 .getQuick(row, col));
   }
 
@@ -237,7 +238,7 @@
     Matrix value = test.divide(4.53);
     for (int row = 0; row < c[ROW]; row++)
       for (int col = 0; col < c[COL]; col++)
-        assertEquals("value[" + row + "][" + col + "]",
+        assertEquals("value[" + row + "][" + col + ']',
                 values[row][col] / 4.53, value.getQuick(row, col));
   }
 
@@ -245,7 +246,7 @@
     int[] c = test.cardinality();
     for (int row = 0; row < c[ROW]; row++)
       for (int col = 0; col < c[COL]; col++)
-        assertEquals("value[" + row + "][" + col + "]", values[row][col], test
+        assertEquals("value[" + row + "][" + col + ']', values[row][col], test
                 .get(row, col));
   }
 
@@ -278,7 +279,7 @@
     Matrix value = test.minus(test);
     for (int row = 0; row < c[ROW]; row++)
       for (int col = 0; col < c[COL]; col++)
-        assertEquals("value[" + row + "][" + col + "]", 0.0, value.getQuick(
+        assertEquals("value[" + row + "][" + col + ']', 0.0, value.getQuick(
                 row, col));
   }
 
@@ -296,7 +297,7 @@
     Matrix value = test.plus(4.53);
     for (int row = 0; row < c[ROW]; row++)
       for (int col = 0; col < c[COL]; col++)
-        assertEquals("value[" + row + "][" + col + "]",
+        assertEquals("value[" + row + "][" + col + ']',
                 values[row][col] + 4.53, value.getQuick(row, col));
   }
 
@@ -305,7 +306,7 @@
     Matrix value = test.plus(test);
     for (int row = 0; row < c[ROW]; row++)
       for (int col = 0; col < c[COL]; col++)
-        assertEquals("value[" + row + "][" + col + "]", values[row][col] * 2,
+        assertEquals("value[" + row + "][" + col + ']', values[row][col] * 2,
                 value.getQuick(row, col));
   }
 
@@ -349,7 +350,7 @@
     Matrix value = test.times(4.53);
     for (int row = 0; row < c[ROW]; row++)
       for (int col = 0; col < c[COL]; col++)
-        assertEquals("value[" + row + "][" + col + "]",
+        assertEquals("value[" + row + "][" + col + ']',
                 values[row][col] * 4.53, value.getQuick(row, col));
   }
 
@@ -384,7 +385,7 @@
     assertEquals("cols", c[ROW], t[COL]);
     for (int row = 0; row < c[ROW]; row++)
       for (int col = 0; col < c[COL]; col++)
-        assertEquals("value[" + row + "][" + col + "]",
+        assertEquals("value[" + row + "][" + col + ']',
                 test.getQuick(row, col), transpose.getQuick(col, row));
   }
 

Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/matrix/TestDenseMatrix.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/matrix/TestDenseMatrix.java?rev=751482&r1=751481&r2=751482&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/matrix/TestDenseMatrix.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/matrix/TestDenseMatrix.java Sun Mar  8 17:52:18 2009
@@ -23,6 +23,7 @@
     super(name);
   }
 
+  @Override
   public Matrix matrixFactory(double[][] values) {
     return new DenseMatrix(values);
   }

Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/matrix/TestDenseVector.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/matrix/TestDenseVector.java?rev=751482&r1=751481&r2=751482&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/matrix/TestDenseVector.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/matrix/TestDenseVector.java Sun Mar  8 17:52:18 2009
@@ -41,12 +41,12 @@
   public void testCopy() throws Exception {
     Vector copy = test.copy();
     for (int i = 0; i < test.cardinality(); i++)
-      assertEquals("copy [" + i + "]", test.get(i), copy.get(i));
+      assertEquals("copy [" + i + ']', test.get(i), copy.get(i));
   }
 
   public void testGet() throws Exception {
     for (int i = 0; i < test.cardinality(); i++)
-      assertEquals("get [" + i + "]", values[i], test.get(i));
+      assertEquals("get [" + i + ']', values[i], test.get(i));
   }
 
   public void testGetOver() {
@@ -71,9 +71,9 @@
     test.set(2, 4.5);
     for (int i = 0; i < test.cardinality(); i++)
       if (i == 2)
-        assertEquals("set [" + i + "]", 4.5, test.get(i));
+        assertEquals("set [" + i + ']', 4.5, test.get(i));
       else
-        assertEquals("set [" + i + "]", values[i], test.get(i));
+        assertEquals("set [" + i + ']', values[i], test.get(i));
   }
 
   public void testSize() throws Exception {
@@ -83,14 +83,14 @@
   public void testToArray() throws Exception {
     double[] val = test.toArray();
     for (int i = 0; i < test.cardinality(); i++)
-      assertEquals("get [" + i + "]", val[i], test.get(i));
+      assertEquals("get [" + i + ']', val[i], test.get(i));
   }
 
   public void testViewPart() throws Exception {
     Vector part = test.viewPart(1, 2);
     assertEquals("part size", 2, part.size());
     for (int i = 0; i < part.cardinality(); i++)
-      assertEquals("part[" + i + "]", values[i + 1], part.get(i));
+      assertEquals("part[" + i + ']', values[i + 1], part.get(i));
   }
 
   public void testViewPartUnder() {
@@ -129,19 +129,19 @@
   public void testDecodeFormat() throws Exception {
     Vector val = DenseVector.decodeFormat(test.asWritableComparable());
     for (int i = 0; i < test.cardinality(); i++)
-      assertEquals("get [" + i + "]", test.get(i), val.get(i));
+      assertEquals("get [" + i + ']', test.get(i), val.get(i));
   }
 
   public void testDenseVectorDoubleArray() throws Exception {
     for (int i = 0; i < test.cardinality(); i++)
-      assertEquals("test[" + i + "]", values[i], test.get(i));
+      assertEquals("test[" + i + ']', values[i], test.get(i));
   }
 
   public void testDenseVectorInt() throws Exception {
     Vector val = new DenseVector(4);
     assertEquals("cardinality", 4, val.cardinality());
     for (int i = 0; i < test.cardinality(); i++)
-      assertEquals("get [" + i + "]", 0.0, val.get(i));
+      assertEquals("get [" + i + ']', 0.0, val.get(i));
   }
 
   public void testDot() throws Exception {
@@ -169,21 +169,21 @@
     Vector val = test.minus(test);
     assertEquals("cardinality", 3, val.cardinality());
     for (int i = 0; i < test.cardinality(); i++)
-      assertEquals("get [" + i + "]", 0.0, val.get(i));
+      assertEquals("get [" + i + ']', 0.0, val.get(i));
   }
 
   public void testPlusDouble() throws Exception {
     Vector val = test.plus(1);
     assertEquals("cardinality", 3, val.cardinality());
     for (int i = 0; i < test.cardinality(); i++)
-      assertEquals("get [" + i + "]", values[i] + 1, val.get(i));
+      assertEquals("get [" + i + ']', values[i] + 1, val.get(i));
   }
 
   public void testPlusVector() throws Exception {
     Vector val = test.plus(test);
     assertEquals("cardinality", 3, val.cardinality());
     for (int i = 0; i < test.cardinality(); i++)
-      assertEquals("get [" + i + "]", values[i] * 2, val.get(i));
+      assertEquals("get [" + i + ']', values[i] * 2, val.get(i));
   }
 
   public void testPlusVectorCardinality() {
@@ -199,21 +199,21 @@
     Vector val = test.times(3);
     assertEquals("cardinality", 3, val.cardinality());
     for (int i = 0; i < test.cardinality(); i++)
-      assertEquals("get [" + i + "]", values[i] * 3, val.get(i));
+      assertEquals("get [" + i + ']', values[i] * 3, val.get(i));
   }
 
   public void testDivideDouble() throws Exception {
     Vector val = test.divide(3);
     assertEquals("cardinality", 3, val.cardinality());
     for (int i = 0; i < test.cardinality(); i++)
-      assertEquals("get [" + i + "]", values[i] / 3, val.get(i));
+      assertEquals("get [" + i + ']', values[i] / 3, val.get(i));
   }
 
   public void testTimesVector() throws Exception {
     Vector val = test.times(test);
     assertEquals("cardinality", 3, val.cardinality());
     for (int i = 0; i < test.cardinality(); i++)
-      assertEquals("get [" + i + "]", values[i] * values[i], val.get(i));
+      assertEquals("get [" + i + ']', values[i] * values[i], val.get(i));
   }
 
   public void testTimesVectorCardinality() {
@@ -227,22 +227,25 @@
 
   public void testZSum() {
     double expected = 0;
-    for (int i = 0; i < values.length; i++)
-      expected += values[i];
+    for (double value : values) {
+      expected += value;
+    }
     assertEquals("wrong zSum", expected, test.zSum());
   }
 
   public void testAssignDouble() {
     test.assign(0);
-    for (int i = 0; i < values.length; i++)
-      assertEquals("value[" + i + "]", 0.0, test.getQuick(i));
+    for (int i = 0; i < values.length; i++) {
+      assertEquals("value[" + i + ']', 0.0, test.getQuick(i));
+    }
   }
 
   public void testAssignDoubleArray() throws Exception {
     double[] array = new double[test.cardinality()];
     test.assign(array);
-    for (int i = 0; i < values.length; i++)
-      assertEquals("value[" + i + "]", 0.0, test.getQuick(i));
+    for (int i = 0; i < values.length; i++) {
+      assertEquals("value[" + i + ']', 0.0, test.getQuick(i));
+    }
   }
 
   public void testAssignDoubleArrayCardinality() {
@@ -258,8 +261,9 @@
   public void testAssignVector() throws Exception {
     Vector other = new DenseVector(test.cardinality());
     test.assign(other);
-    for (int i = 0; i < values.length; i++)
-      assertEquals("value[" + i + "]", 0.0, test.getQuick(i));
+    for (int i = 0; i < values.length; i++) {
+      assertEquals("value[" + i + ']', 0.0, test.getQuick(i));
+    }
   }
 
   public void testAssignVectorCardinality() {
@@ -274,26 +278,29 @@
 
   public void testAssignUnaryFunction() {
     test.assign(new NegateFunction());
-    for (int i = 0; i < values.length; i++)
-      assertEquals("value[" + i + "]", -values[i], test.getQuick(i));
+    for (int i = 0; i < values.length; i++) {
+      assertEquals("value[" + i + ']', -values[i], test.getQuick(i));
+    }
   }
 
   public void testAssignBinaryFunction() throws Exception {
     test.assign(test, new PlusFunction());
-    for (int i = 0; i < values.length; i++)
-      assertEquals("value[" + i + "]", 2 * values[i], test.getQuick(i));
+    for (int i = 0; i < values.length; i++) {
+      assertEquals("value[" + i + ']', 2 * values[i], test.getQuick(i));
+    }
   }
 
   public void testAssignBinaryFunction2() throws Exception {
     test.assign(new PlusFunction(), 4);
-    for (int i = 0; i < values.length; i++)
-      assertEquals("value[" + i + "]", values[i] + 4, test.getQuick(i));
+    for (int i = 0; i < values.length; i++) {
+      assertEquals("value[" + i + ']', values[i] + 4, test.getQuick(i));
+    }
   }
 
   public void testAssignBinaryFunction3() throws Exception {
     test.assign(new TimesFunction(), 4);
     for (int i = 0; i < values.length; i++)
-      assertEquals("value[" + i + "]", values[i] * 4, test.getQuick(i));
+      assertEquals("value[" + i + ']', values[i] * 4, test.getQuick(i));
   }
 
   public void testAssignBinaryFunctionCardinality() {
@@ -336,9 +343,11 @@
     Matrix result = test.cross(test);
     assertEquals("row cardinality", test.cardinality(), result.cardinality()[0]);
     assertEquals("col cardinality", test.cardinality(), result.cardinality()[1]);
-    for (int row = 0; row < result.cardinality()[0]; row++)
-      for (int col = 0; col < result.cardinality()[1]; col++)
-        assertEquals("cross[" + row + "][" + col + "]", test.getQuick(row)
+    for (int row = 0; row < result.cardinality()[0]; row++) {
+      for (int col = 0; col < result.cardinality()[1]; col++) {
+        assertEquals("cross[" + row + "][" + col + ']', test.getQuick(row)
             * test.getQuick(col), result.getQuick(row, col));
+      }
+    }
   }
 }

Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/matrix/TestMatrixView.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/matrix/TestMatrixView.java?rev=751482&r1=751481&r2=751482&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/matrix/TestMatrixView.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/matrix/TestMatrixView.java Sun Mar  8 17:52:18 2009
@@ -34,6 +34,7 @@
     super(name);
   }
 
+  @Override
   protected void setUp() throws Exception {
     super.setUp();
     int[] offset = { 1, 1 };
@@ -59,7 +60,7 @@
     assertTrue("wrong class", copy instanceof MatrixView);
     for (int row = 0; row < c[ROW]; row++)
       for (int col = 0; col < c[COL]; col++)
-        assertEquals("value[" + row + "][" + col + "]",
+        assertEquals("value[" + row + "][" + col + ']',
             test.getQuick(row, col), copy.getQuick(row, col));
   }
 
@@ -67,7 +68,7 @@
     int[] c = test.cardinality();
     for (int row = 0; row < c[ROW]; row++)
       for (int col = 0; col < c[COL]; col++)
-        assertEquals("value[" + row + "][" + col + "]",
+        assertEquals("value[" + row + "][" + col + ']',
             values[row + 1][col + 1], test.getQuick(row, col));
   }
 
@@ -95,7 +96,7 @@
     for (int row = 0; row < c[ROW]; row++)
       for (int col = 0; col < c[COL]; col++) {
         test.setQuick(row, col, 1.23);
-        assertEquals("value[" + row + "][" + col + "]", 1.23, test.getQuick(
+        assertEquals("value[" + row + "][" + col + ']', 1.23, test.getQuick(
             row, col));
       }
   }
@@ -111,7 +112,7 @@
     int[] c = test.cardinality();
     for (int row = 0; row < c[ROW]; row++)
       for (int col = 0; col < c[COL]; col++)
-        assertEquals("value[" + row + "][" + col + "]",
+        assertEquals("value[" + row + "][" + col + ']',
             values[row + 1][col + 1], array[row][col]);
   }
 
@@ -122,7 +123,7 @@
     int[] c = view.cardinality();
     for (int row = 0; row < c[ROW]; row++)
       for (int col = 0; col < c[COL]; col++)
-        assertEquals("value[" + row + "][" + col + "]",
+        assertEquals("value[" + row + "][" + col + ']',
             values[row + 2][col + 2], view.getQuick(row, col));
   }
 
@@ -170,7 +171,7 @@
     test.assign(4.53);
     for (int row = 0; row < c[ROW]; row++)
       for (int col = 0; col < c[COL]; col++)
-        assertEquals("value[" + row + "][" + col + "]", 4.53, test.getQuick(
+        assertEquals("value[" + row + "][" + col + ']', 4.53, test.getQuick(
             row, col));
   }
 
@@ -179,7 +180,7 @@
     test.assign(new double[3][2]);
     for (int row = 0; row < c[ROW]; row++)
       for (int col = 0; col < c[COL]; col++)
-        assertEquals("value[" + row + "][" + col + "]", 0.0, test.getQuick(row,
+        assertEquals("value[" + row + "][" + col + ']', 0.0, test.getQuick(row,
             col));
   }
 
@@ -198,7 +199,7 @@
     test.assign(test, new PlusFunction());
     for (int row = 0; row < c[ROW]; row++)
       for (int col = 0; col < c[COL]; col++)
-        assertEquals("value[" + row + "][" + col + "]",
+        assertEquals("value[" + row + "][" + col + ']',
             2 * values[row + 1][col + 1], test.getQuick(row, col));
   }
 
@@ -217,7 +218,7 @@
     value.assign(test);
     for (int row = 0; row < c[ROW]; row++)
       for (int col = 0; col < c[COL]; col++)
-        assertEquals("value[" + row + "][" + col + "]",
+        assertEquals("value[" + row + "][" + col + ']',
             test.getQuick(row, col), value.getQuick(row, col));
   }
 
@@ -235,7 +236,7 @@
     test.assign(new NegateFunction());
     for (int row = 0; row < c[ROW]; row++)
       for (int col = 0; col < c[COL]; col++)
-        assertEquals("value[" + row + "][" + col + "]",
+        assertEquals("value[" + row + "][" + col + ']',
             -values[row + 1][col + 1], test.getQuick(row, col));
   }
 
@@ -244,7 +245,7 @@
     Matrix value = test.divide(4.53);
     for (int row = 0; row < c[ROW]; row++)
       for (int col = 0; col < c[COL]; col++)
-        assertEquals("value[" + row + "][" + col + "]",
+        assertEquals("value[" + row + "][" + col + ']',
             values[row + 1][col + 1] / 4.53, value.getQuick(row, col));
   }
 
@@ -252,7 +253,7 @@
     int[] c = test.cardinality();
     for (int row = 0; row < c[ROW]; row++)
       for (int col = 0; col < c[COL]; col++)
-        assertEquals("value[" + row + "][" + col + "]",
+        assertEquals("value[" + row + "][" + col + ']',
             values[row + 1][col + 1], test.get(row, col));
   }
 
@@ -285,7 +286,7 @@
     Matrix value = test.minus(test);
     for (int row = 0; row < c[ROW]; row++)
       for (int col = 0; col < c[COL]; col++)
-        assertEquals("value[" + row + "][" + col + "]", 0.0, value.getQuick(
+        assertEquals("value[" + row + "][" + col + ']', 0.0, value.getQuick(
             row, col));
   }
 
@@ -303,7 +304,7 @@
     Matrix value = test.plus(4.53);
     for (int row = 0; row < c[ROW]; row++)
       for (int col = 0; col < c[COL]; col++)
-        assertEquals("value[" + row + "][" + col + "]",
+        assertEquals("value[" + row + "][" + col + ']',
             values[row + 1][col + 1] + 4.53, value.getQuick(row, col));
   }
 
@@ -312,7 +313,7 @@
     Matrix value = test.plus(test);
     for (int row = 0; row < c[ROW]; row++)
       for (int col = 0; col < c[COL]; col++)
-        assertEquals("value[" + row + "][" + col + "]",
+        assertEquals("value[" + row + "][" + col + ']',
             values[row + 1][col + 1] * 2, value.getQuick(row, col));
   }
 
@@ -356,7 +357,7 @@
     Matrix value = test.times(4.53);
     for (int row = 0; row < c[ROW]; row++)
       for (int col = 0; col < c[COL]; col++)
-        assertEquals("value[" + row + "][" + col + "]",
+        assertEquals("value[" + row + "][" + col + ']',
             values[row + 1][col + 1] * 4.53, value.getQuick(row, col));
   }
 
@@ -388,7 +389,7 @@
     assertEquals("cols", c[ROW], t[COL]);
     for (int row = 0; row < c[ROW]; row++)
       for (int col = 0; col < c[COL]; col++)
-        assertEquals("value[" + row + "][" + col + "]",
+        assertEquals("value[" + row + "][" + col + ']',
             test.getQuick(row, col), transpose.getQuick(col, row));
   }
 

Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/matrix/TestSparseColumnMatrix.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/matrix/TestSparseColumnMatrix.java?rev=751482&r1=751481&r2=751482&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/matrix/TestSparseColumnMatrix.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/matrix/TestSparseColumnMatrix.java Sun Mar  8 17:52:18 2009
@@ -23,6 +23,7 @@
     super(name);
   }
 
+  @Override
   public Matrix matrixFactory(double[][] values) {
     int[] cardinality = {values.length, values[0].length};
     Matrix matrix = new SparseColumnMatrix(cardinality);

Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/matrix/TestSparseMatrix.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/matrix/TestSparseMatrix.java?rev=751482&r1=751481&r2=751482&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/matrix/TestSparseMatrix.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/matrix/TestSparseMatrix.java Sun Mar  8 17:52:18 2009
@@ -23,6 +23,7 @@
     super(name);
   }
 
+  @Override
   public Matrix matrixFactory(double[][] values) {
     int[] cardinality = {values.length, values[0].length};
     Matrix matrix = new SparseMatrix(cardinality);

Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/matrix/TestSparseRowMatrix.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/matrix/TestSparseRowMatrix.java?rev=751482&r1=751481&r2=751482&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/matrix/TestSparseRowMatrix.java (original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/matrix/TestSparseRowMatrix.java Sun Mar  8 17:52:18 2009
@@ -23,6 +23,7 @@
     super(name);
   }
 
+  @Override
   public Matrix matrixFactory(double[][] values) {
     int[] cardinality = {values.length, values[0].length};
     Matrix matrix = new SparseRowMatrix(cardinality);