mahout-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sro...@apache.org
Subject svn commit: r831743 - in /lucene/mahout/trunk: core/src/main/java/org/apache/mahout/clustering/dirichlet/models/ core/src/main/java/org/apache/mahout/clustering/lda/ core/src/main/java/org/apache/mahout/df/ core/src/main/java/org/apache/mahout/df/build...
Date Sun, 01 Nov 2009 19:35:14 GMT
Author: srowen
Date: Sun Nov  1 19:35:12 2009
New Revision: 831743

URL: http://svn.apache.org/viewvc?rev=831743&view=rev
Log:
MAHOUT-189

Modified:
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/dirichlet/models/AsymmetricSampledNormalModel.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/lda/IntPairWritable.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/lda/LDADriver.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/lda/LDAInference.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/lda/LDAPrintTopics.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/lda/LDAReducer.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/DecisionForest.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/ErrorEstimate.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/builder/DefaultTreeBuilder.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/callback/SingleTreePredictions.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/data/DataUtils.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/data/Dataset.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/mapred/partial/PartialBuilder.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/mapred/partial/Step2Mapper.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/mapreduce/partial/InterResults.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/mapreduce/partial/PartialBuilder.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/mapreduce/partial/Step2Mapper.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/mapreduce/partial/TreeID.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/split/OptIgSplit.java
    lucene/mahout/trunk/core/src/main/java/org/apache/mahout/matrix/SparseVector.java
    lucene/mahout/trunk/core/src/test/java/org/apache/mahout/ga/watchmaker/utils/DummyCandidate.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/CDRule.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/FileInfoParser.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/NominalAttr.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/hadoop/CDMapper.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/hadoop/DatasetSplit.java
    lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/tool/Descriptors.java
    lucene/mahout/trunk/examples/src/test/java/org/apache/mahout/ga/watchmaker/cd/utils/MockDataSet.java

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/dirichlet/models/AsymmetricSampledNormalModel.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/dirichlet/models/AsymmetricSampledNormalModel.java?rev=831743&r1=831742&r2=831743&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/dirichlet/models/AsymmetricSampledNormalModel.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/dirichlet/models/AsymmetricSampledNormalModel.java
Sun Nov  1 19:35:12 2009
@@ -99,7 +99,9 @@
    * @param sd a double std deviation
    */
   private double pdf(Vector x, double sd) {
-    assert x.getNumNondefaultElements() == 2;
+    if (x.getNumNondefaultElements() != 2) {
+      throw new IllegalArgumentException();
+    }
     double sd2 = sd * sd;
     double exp = -(x.dot(x) - 2 * x.dot(mean) + mean.dot(mean)) / (2 * sd2);
     double ex = Math.exp(exp);
@@ -109,7 +111,9 @@
   @Override
   public double pdf(Vector x) {
     // return the product of the two component pdfs
-    assert x.getNumNondefaultElements() == 2;
+    if (x.getNumNondefaultElements() != 2) {
+      throw new IllegalArgumentException();
+    }
     double pdf0 = pdf(x, sd.get(0));
     double pdf1 = pdf(x, sd.get(1));
     // if (pdf0 < 0 || pdf0 > 1 || pdf1 < 0 || pdf1 > 1)

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/lda/IntPairWritable.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/lda/IntPairWritable.java?rev=831743&r1=831742&r2=831743&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/lda/IntPairWritable.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/lda/IntPairWritable.java
Sun Nov  1 19:35:12 2009
@@ -113,7 +113,9 @@
 
     @Override
     public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
-      assert l1 == 8;
+      if (l1 != 8) {
+        throw new IllegalArgumentException();
+      }
       int int11 = readInt(b1, s1);
       int int21 = readInt(b2, s2);
       if (int11 != int21) {

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/lda/LDADriver.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/lda/LDADriver.java?rev=831743&r1=831742&r2=831743&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/lda/LDADriver.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/lda/LDADriver.java
Sun Nov  1 19:35:12 2009
@@ -326,15 +326,23 @@
         int word = key.getY();
         if (word == TOPIC_SUM_KEY) {
           logTotals[topic] = value.get();
-          assert !Double.isInfinite(value.get());
+          if (Double.isInfinite(value.get())) {
+            throw new IllegalArgumentException();
+          }
         } else if (topic == LOG_LIKELIHOOD_KEY) {
           ll = value.get();
         } else {
           //System.out.println(topic + " " + word);
-          assert topic >= 0 && word >= 0 : topic + " " + word;
-          assert pWgT.getQuick(topic, word) == 0.0;
+          if (!(topic >= 0 && word >= 0)) {
+            throw new IllegalArgumentException(topic + " " + word);
+          }
+          if (pWgT.getQuick(topic, word) != 0.0) {
+            throw new IllegalArgumentException();
+          }
           pWgT.setQuick(topic, word, value.get());
-          assert !Double.isInfinite(pWgT.getQuick(topic, word));
+          if (Double.isInfinite(pWgT.getQuick(topic, word))) {
+            throw new IllegalArgumentException();
+          }
         }
       }
       reader.close();

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/lda/LDAInference.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/lda/LDAInference.java?rev=831743&r1=831742&r2=831743&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/lda/LDAInference.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/lda/LDAInference.java
Sun Nov  1 19:35:12 2009
@@ -129,8 +129,8 @@
       digammaGamma = digammaGamma.plus(-digammaSumGamma);
 
       double ll = computeLikelihood(wordCounts, columnMap, phi, gamma, digammaGamma);
-      converged = oldLL < 0 && ((oldLL - ll) / oldLL < E_STEP_CONVERGENCE);
       assert !Double.isNaN(ll);
+      converged = oldLL < 0 && ((oldLL - ll) / oldLL < E_STEP_CONVERGENCE);
 
       oldLL = ll;
       iteration++;

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/lda/LDAPrintTopics.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/lda/LDAPrintTopics.java?rev=831743&r1=831742&r2=831743&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/lda/LDAPrintTopics.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/lda/LDAPrintTopics.java
Sun Nov  1 19:35:12 2009
@@ -152,7 +152,9 @@
       String[] parts = TAB_PATTERN.split(line);
       String word = parts[0];
       int index = Integer.parseInt(parts[2]);
-      assert index == result.size();
+      if (index != result.size()) {
+        throw new IllegalArgumentException();
+      }
       result.add(word);
     }
 

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/lda/LDAReducer.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/lda/LDAReducer.java?rev=831743&r1=831742&r2=831743&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/lda/LDAReducer.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/clustering/lda/LDAReducer.java
Sun Nov  1 19:35:12 2009
@@ -38,7 +38,9 @@
       double accum = 0.0;
       for (DoubleWritable vw : values) {
         double v = vw.get();
-        assert !Double.isNaN(v) : topicWord.getX() + " " + topicWord.getY();
+        if (Double.isNaN(v)) {
+          throw new IllegalArgumentException(topicWord.getX() + " " + topicWord.getY());
+        }
         accum += v;
       }
       context.write(topicWord, new DoubleWritable(accum));
@@ -46,9 +48,13 @@
       double accum = Double.NEGATIVE_INFINITY;
       for (DoubleWritable vw : values) {
         double v = vw.get();
-        assert !Double.isNaN(v) : topicWord.getX() + " " + topicWord.getY();
+        if (Double.isNaN(v)) {
+          throw new IllegalArgumentException(topicWord.getX() + " " + topicWord.getY());
+        }
         accum = LDAUtil.logSum(accum, v);
-        assert !Double.isNaN(accum) : topicWord.getX() + " " + topicWord.getY();
+        if (Double.isNaN(accum)) {
+          throw new IllegalArgumentException(topicWord.getX() + " " + topicWord.getY());
+        }
       }
       context.write(topicWord, new DoubleWritable(accum));
     }

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/DecisionForest.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/DecisionForest.java?rev=831743&r1=831742&r2=831743&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/DecisionForest.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/DecisionForest.java Sun Nov
 1 19:35:12 2009
@@ -39,7 +39,9 @@
   }
 
   public DecisionForest(List<Node> trees) {
-    assert trees != null && !trees.isEmpty() : "trees argument must not be null or
empty";
+    if (!(trees != null && !trees.isEmpty())) {
+      throw new IllegalArgumentException("trees argument must not be null or empty");
+    }
 
     this.trees = trees;
   }
@@ -55,7 +57,9 @@
    * @param callback
    */
   public void classify(Data data, PredictionCallback callback) {
-    assert callback != null : "callback must not be null";
+    if (callback == null) {
+      throw new IllegalArgumentException("callback must not be null");
+    }
 
     if (data.isEmpty())
       return; // nothing to classify

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/ErrorEstimate.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/ErrorEstimate.java?rev=831743&r1=831742&r2=831743&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/ErrorEstimate.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/ErrorEstimate.java Sun Nov
 1 19:35:12 2009
@@ -25,7 +25,9 @@
   }
 
   public static double errorRate(int[] labels, int[] predictions) {
-    assert labels.length == predictions.length : "labels.length != predictions.length";
+    if (labels.length != predictions.length) {
+      throw new IllegalArgumentException("labels.length != predictions.length");
+    }
 
     double nberrors = 0; // number of instance that got bad predictions
     double datasize = 0; // number of classified instances
@@ -67,7 +69,9 @@
    * @return
    */
   public static int nbErrors(int[] labels, int[] predictions) {
-    assert labels.length == predictions.length : "labels.length != predictions.length";
+    if (labels.length != predictions.length) {
+      throw new IllegalArgumentException("labels.length != predictions.length");
+    }
 
     int nberrors = 0;
 

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/builder/DefaultTreeBuilder.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/builder/DefaultTreeBuilder.java?rev=831743&r1=831742&r2=831743&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/builder/DefaultTreeBuilder.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/builder/DefaultTreeBuilder.java
Sun Nov  1 19:35:12 2009
@@ -111,7 +111,9 @@
    * @return
    */
   protected static int[] randomAttributes(Dataset dataset, Random rng, int m) {
-    assert m <= dataset.nbAttributes() : "m > num attributes";
+    if (m > dataset.nbAttributes()) {
+      throw new IllegalArgumentException("m > num attributes");
+    }
 
     int[] result = new int[m];
 

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/callback/SingleTreePredictions.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/callback/SingleTreePredictions.java?rev=831743&r1=831742&r2=831743&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/callback/SingleTreePredictions.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/callback/SingleTreePredictions.java
Sun Nov  1 19:35:12 2009
@@ -40,7 +40,9 @@
     if (this.treeId == null) {
       this.treeId = treeId;
     } else {
-      assert this.treeId == treeId : "the predictions does not belong to the same tree";
+      if (this.treeId != treeId) {
+        throw new IllegalArgumentException("the predictions does not belong to the same tree");
+      }
     }
     
     predictions[instanceId] = prediction;

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/data/DataUtils.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/data/DataUtils.java?rev=831743&r1=831742&r2=831743&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/data/DataUtils.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/data/DataUtils.java Sun Nov
 1 19:35:12 2009
@@ -49,7 +49,9 @@
    * @param array2
    */
   public static void add(int[] array1, int[] array2) {
-    assert array1.length == array2.length : "array1.length != array2.length";
+    if (array1.length != array2.length) {
+      throw new IllegalArgumentException("array1.length != array2.length");
+    }
     
     for (int index = 0; index < array1.length; index++) {
       array1[index] += array2[index];
@@ -62,7 +64,9 @@
    * @param array2
    */
   public static void dec(int[] array1, int[] array2) {
-    assert array1.length == array2.length : "array1.length != array2.length";
+    if (array1.length != array2.length) {
+      throw new IllegalArgumentException("array1.length != array2.length");
+    }
     
     for (int index = 0; index < array1.length; index++) {
       array1[index] -= array2[index];

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/data/Dataset.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/data/Dataset.java?rev=831743&r1=831742&r2=831743&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/data/Dataset.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/data/Dataset.java Sun Nov
 1 19:35:12 2009
@@ -198,12 +198,17 @@
   }
 
   private static void validateValues(Attribute[] attrs, List<String>[] values) {
-    assert attrs.length == values.length : "attrs.length != values.length";
+    if (attrs.length != values.length) {
+      throw new IllegalArgumentException("attrs.length != values.length");
+    }
 
     for (int attr = 0; attr < attrs.length; attr++) {
-      if (attrs[attr].isCategorical())
-        assert values[attr] != null : "values not found for attribute N° "
-            + attr;
+      if (attrs[attr].isCategorical()) {
+        if (values[attr] == null) {
+          throw new IllegalArgumentException("values not found for attribute N° "
+              + attr);
+        }
+      }
     }
   }
 

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/mapred/partial/PartialBuilder.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/mapred/partial/PartialBuilder.java?rev=831743&r1=831742&r2=831743&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/mapred/partial/PartialBuilder.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/mapred/partial/PartialBuilder.java
Sun Nov  1 19:35:12 2009
@@ -181,7 +181,9 @@
     }
 
     // make sure we got all the keys/values
-    assert index == keys.length;
+    if (index != keys.length) {
+      throw new IllegalStateException();
+    }
   }
 
   /**

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/mapred/partial/Step2Mapper.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/mapred/partial/Step2Mapper.java?rev=831743&r1=831742&r2=831743&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/mapred/partial/Step2Mapper.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/mapred/partial/Step2Mapper.java
Sun Nov  1 19:35:12 2009
@@ -129,7 +129,9 @@
    * @return
    */
   public static int nbConcerned(int numMaps, int numTrees, int partition) {
-    assert partition >= 0 : "partition < 0";
+    if (partition < 0) {
+      throw new IllegalArgumentException("partition < 0");
+    }
     // the trees of the mapper's partition are not concerned
     return numTrees - Step1Mapper.nbTrees(numMaps, numTrees, partition);
   }
@@ -153,7 +155,9 @@
 
     converter = new DataConverter(dataset);
 
-    assert keys.length == trees.length : "keys.length != trees.length";
+    if (keys.length != trees.length) {
+      throw new IllegalArgumentException("keys.length != trees.length");
+    }
     int nbConcerned = keys.length;
 
     this.keys = keys;
@@ -161,7 +165,9 @@
 
     // make sure the trees are not from this partition
     for (TreeID key : keys) {
-      assert key.partition() != partition : "a tree from this partition was found !";
+      if (key.partition() == partition) {
+        throw new IllegalArgumentException("a tree from this partition was found !");
+      }
     }
 
     // init the callbacks

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/mapreduce/partial/InterResults.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/mapreduce/partial/InterResults.java?rev=831743&r1=831742&r2=831743&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/mapreduce/partial/InterResults.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/mapreduce/partial/InterResults.java
Sun Nov  1 19:35:12 2009
@@ -49,7 +49,9 @@
   public static int load(FileSystem fs, Path forestPath, int numMaps,
       int numTrees, int partition, TreeID[] keys, Node[] trees)
       throws IOException {
-    assert keys.length == trees.length : "keys.length != trees.length";
+    if (keys.length != trees.length) {
+      throw new IllegalArgumentException("keys.length != trees.length");
+    }
 
     FSDataInputStream in = fs.open(forestPath);
 
@@ -82,7 +84,9 @@
         }
       }
 
-      assert current == keys.length : "loaded less keys/trees than expected";
+      if (current != keys.length) {
+        throw new IllegalStateException("loaded less keys/trees than expected");
+      }
     } finally {
       in.close();
     }
@@ -101,7 +105,9 @@
    */
   public static void store(FileSystem fs, Path forestPath,
       TreeID[] keys, Node[] trees, int[] sizes) throws IOException {
-    assert keys.length == trees.length : "keys.length != trees.length";
+    if (keys.length != trees.length) {
+      throw new IllegalArgumentException("keys.length != trees.length");
+    }
 
     int numTrees = keys.length;
     int numMaps = sizes.length;

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/mapreduce/partial/PartialBuilder.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/mapreduce/partial/PartialBuilder.java?rev=831743&r1=831742&r2=831743&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/mapreduce/partial/PartialBuilder.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/mapreduce/partial/PartialBuilder.java
Sun Nov  1 19:35:12 2009
@@ -149,7 +149,9 @@
   protected static void processOutput(Job job, Path outputPath,
       int[] firstIds, TreeID[] keys, Node[] trees, PredictionCallback callback)
       throws IOException {
-    assert keys.length == trees.length : "keys.length != trees.length";
+    if (keys.length != trees.length) {
+      throw new IllegalArgumentException("keys.length != trees.length");
+    }
     
     Configuration conf = job.getConfiguration();
     
@@ -185,7 +187,9 @@
     }
 
     // make sure we got all the keys/values
-    assert index == keys.length;
+    if (index != keys.length) {
+      throw new IllegalStateException();
+    }
   }
 
   /**

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/mapreduce/partial/Step2Mapper.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/mapreduce/partial/Step2Mapper.java?rev=831743&r1=831742&r2=831743&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/mapreduce/partial/Step2Mapper.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/mapreduce/partial/Step2Mapper.java
Sun Nov  1 19:35:12 2009
@@ -109,7 +109,9 @@
    * @return
    */
   public static int nbConcerned(int numMaps, int numTrees, int partition) {
-    assert partition >= 0 : "partition < 0";
+    if (partition < 0) {
+      throw new IllegalArgumentException("partition < 0");
+    }
     // the trees of the mapper's partition are not concerned
     return numTrees - Step1Mapper.nbTrees(numMaps, numTrees, partition);
   }
@@ -133,7 +135,9 @@
 
     converter = new DataConverter(dataset);
 
-    assert keys.length == trees.length : "keys.length != trees.length";
+    if (keys.length != trees.length) {
+      throw new IllegalArgumentException("keys.length != trees.length");
+    }
     int nbConcerned = keys.length;
 
     this.keys = keys;
@@ -141,7 +145,9 @@
 
     // make sure the trees are not from this partition
     for (TreeID key : keys) {
-      assert key.partition() != partition : "a tree from this partition was found !";
+      if (key.partition() == partition) {
+        throw new IllegalArgumentException("a tree from this partition was found !");
+      }
     }
 
     // init the callbacks

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/mapreduce/partial/TreeID.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/mapreduce/partial/TreeID.java?rev=831743&r1=831742&r2=831743&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/mapreduce/partial/TreeID.java
(original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/mapreduce/partial/TreeID.java
Sun Nov  1 19:35:12 2009
@@ -29,8 +29,12 @@
   }
 
   public TreeID(int partition, int treeId) {
-    assert partition >= 0 : "partition < 0";
-    assert treeId >= 0 : "treeId < 0";
+    if (partition < 0) {
+      throw new IllegalArgumentException("partition < 0");
+    }
+    if (treeId < 0) {
+      throw new IllegalArgumentException("treeId < 0");
+    }
     set(partition, treeId);
   }
 

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/split/OptIgSplit.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/split/OptIgSplit.java?rev=831743&r1=831742&r2=831743&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/split/OptIgSplit.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/df/split/OptIgSplit.java Sun
Nov  1 19:35:12 2009
@@ -153,7 +153,9 @@
       DataUtils.dec(countAll, counts[index]);
     }
 
-    assert best != -1 : "no best split found !";
+    if (best == -1) {
+      throw new IllegalStateException("no best split found !");
+    }
     return new Split(attr, bestIg, values[best]);
   }
 

Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/matrix/SparseVector.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/matrix/SparseVector.java?rev=831743&r1=831742&r2=831743&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/matrix/SparseVector.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/matrix/SparseVector.java Sun
Nov  1 19:35:12 2009
@@ -284,8 +284,9 @@
     int size = dataInput.readInt();
     OrderedIntDoubleMapping values = new OrderedIntDoubleMapping(size);
     int i = 0;
-    for (; i < size; i++) {
+    while (i < size) {
       values.set(dataInput.readInt(), dataInput.readDouble());
+      i++;
     }
     assert (i == size);
     this.cardinality = cardinality;

Modified: lucene/mahout/trunk/core/src/test/java/org/apache/mahout/ga/watchmaker/utils/DummyCandidate.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/test/java/org/apache/mahout/ga/watchmaker/utils/DummyCandidate.java?rev=831743&r1=831742&r2=831743&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/test/java/org/apache/mahout/ga/watchmaker/utils/DummyCandidate.java
(original)
+++ lucene/mahout/trunk/core/src/test/java/org/apache/mahout/ga/watchmaker/utils/DummyCandidate.java
Sun Nov  1 19:35:12 2009
@@ -57,7 +57,9 @@
   }
 
   public static List<DummyCandidate> generatePopulation(int size) {
-    assert size > 0 : "bad size";
+    if (size <= 0) {
+      throw new IllegalArgumentException("bad size");
+    }
 
     List<DummyCandidate> population = new ArrayList<DummyCandidate>();
     for (int index = 0; index < size; index++) {

Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/CDRule.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/CDRule.java?rev=831743&r1=831742&r2=831743&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/CDRule.java
(original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/CDRule.java
Sun Nov  1 19:35:12 2009
@@ -59,7 +59,9 @@
    */
   public CDRule(double threshold) {
     // crossover needs at least 2 attributes
-    assert threshold >= 0 && threshold <= 1 : "bad threshold";
+    if (!(threshold >= 0 && threshold <= 1)) {
+      throw new IllegalArgumentException("bad threshold");
+    }
 
     this.threshold = threshold;
 

Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/FileInfoParser.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/FileInfoParser.java?rev=831743&r1=831742&r2=831743&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/FileInfoParser.java
(original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/FileInfoParser.java
Sun Nov  1 19:35:12 2009
@@ -112,7 +112,9 @@
    */
   public static Path getInfoFile(FileSystem fs, Path inpath)
       throws IOException {
-    assert inpath != null : "null inpath parameter";
+    if (inpath == null) {
+      throw new IllegalArgumentException("null inpath parameter");
+    }
     if (!fs.exists(inpath))
       throw new IllegalArgumentException("Input path does not exist");
     if (!fs.getFileStatus(inpath).isDir())
@@ -150,7 +152,9 @@
   private static NumericalAttr parseNumerical(StringTokenizer tokenizer) {
     double min = nextDouble(tokenizer);
     double max = nextDouble(tokenizer);
-    assert min <= max : "min > max";
+    if (min > max) {
+      throw new IllegalArgumentException("min > max");
+    }
 
     return new NumericalAttr(min, max);
   }

Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/NominalAttr.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/NominalAttr.java?rev=831743&r1=831742&r2=831743&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/NominalAttr.java
(original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/NominalAttr.java
Sun Nov  1 19:35:12 2009
@@ -22,7 +22,9 @@
   private final String[] values;
 
   NominalAttr(String[] values) {
-    assert values.length > 0 : "values is empty";
+    if (values.length <= 0) {
+      throw new IllegalArgumentException("values is empty");
+    }
     this.values = values;
   }
 

Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/hadoop/CDMapper.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/hadoop/CDMapper.java?rev=831743&r1=831742&r2=831743&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/hadoop/CDMapper.java
(original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/hadoop/CDMapper.java
Sun Nov  1 19:35:12 2009
@@ -74,13 +74,19 @@
   }
 
   static void initializeDataSet(DataSet dataset) {
-    assert dataset != null : "bad 'dataset' configuration parameter";
+    if (dataset == null) {
+      throw new IllegalArgumentException("bad 'dataset' configuration parameter");
+    }
     DataSet.initialize(dataset);
   }
 
   void configure(List<Rule> rules, int target) {
-    assert rules != null && !rules.isEmpty() : "bad 'rules' configuration parameter";
-    assert target >= 0 : "bad 'target' configuration parameter";
+    if (!(rules != null && !rules.isEmpty())) {
+      throw new IllegalArgumentException("bad 'rules' configuration parameter");
+    }
+    if (target < 0) {
+      throw new IllegalArgumentException("bad 'target' configuration parameter");
+    }
 
     this.rules = rules;
     this.target = target;

Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/hadoop/DatasetSplit.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/hadoop/DatasetSplit.java?rev=831743&r1=831742&r2=831743&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/hadoop/DatasetSplit.java
(original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/hadoop/DatasetSplit.java
Sun Nov  1 19:35:12 2009
@@ -138,7 +138,9 @@
 
     public RndLineRecordReader(RecordReader<LongWritable, Text> reader,
         JobConf conf) {
-      assert reader != null : "null reader";
+      if (reader == null) {
+        throw new IllegalArgumentException("null reader");
+      }
 
       this.reader = reader;
 

Modified: lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/tool/Descriptors.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/tool/Descriptors.java?rev=831743&r1=831742&r2=831743&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/tool/Descriptors.java
(original)
+++ lucene/mahout/trunk/examples/src/main/java/org/apache/mahout/ga/watchmaker/cd/tool/Descriptors.java
Sun Nov  1 19:35:12 2009
@@ -34,7 +34,9 @@
   private final char[] descriptors;
 
   public Descriptors(char[] descriptors) {
-    assert descriptors != null && descriptors.length > 0;
+    if (!(descriptors != null && descriptors.length > 0)) {
+      throw new IllegalArgumentException();
+    }
 
     this.descriptors = descriptors;
 

Modified: lucene/mahout/trunk/examples/src/test/java/org/apache/mahout/ga/watchmaker/cd/utils/MockDataSet.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/examples/src/test/java/org/apache/mahout/ga/watchmaker/cd/utils/MockDataSet.java?rev=831743&r1=831742&r2=831743&view=diff
==============================================================================
--- lucene/mahout/trunk/examples/src/test/java/org/apache/mahout/ga/watchmaker/cd/utils/MockDataSet.java
(original)
+++ lucene/mahout/trunk/examples/src/test/java/org/apache/mahout/ga/watchmaker/cd/utils/MockDataSet.java
Sun Nov  1 19:35:12 2009
@@ -40,7 +40,9 @@
    * @param maxnba max number of attributes
    */
   public MockDataSet(Random rng, int maxnba) {
-    assert maxnba > 0 : "maxnba must be greater than 0";
+    if (maxnba <= 0) {
+      throw new IllegalArgumentException("maxnba must be greater than 0");
+    }
 
     this.rng = rng;
     this.maxnba = maxnba;



Mime
View raw message