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 2010/04/21 09:48:15 UTC
svn commit: r936186 - in /lucene/mahout/trunk:
core/src/main/java/org/apache/mahout/classifier/discriminative/
core/src/main/java/org/apache/mahout/common/distance/
math/src/main/java/org/apache/mahout/math/
math/src/test/java/org/apache/mahout/math/
Author: srowen
Date: Wed Apr 21 07:48:15 2010
New Revision: 936186
URL: http://svn.apache.org/viewvc?rev=936186&view=rev
Log:
The rest of MAHOUT-316
Modified:
lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/discriminative/LinearTrainer.java
lucene/mahout/trunk/core/src/main/java/org/apache/mahout/common/distance/CosineDistanceMeasure.java
lucene/mahout/trunk/core/src/main/java/org/apache/mahout/common/distance/ManhattanDistanceMeasure.java
lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/CardinalityException.java
lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/DenseMatrix.java
lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/IndexException.java
lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/MatrixView.java
lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/SparseColumnMatrix.java
lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/SparseMatrix.java
lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/SparseRowMatrix.java
lucene/mahout/trunk/math/src/test/java/org/apache/mahout/math/MatrixTest.java
lucene/mahout/trunk/math/src/test/java/org/apache/mahout/math/TestMatrixView.java
Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/discriminative/LinearTrainer.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/discriminative/LinearTrainer.java?rev=936186&r1=936185&r2=936186&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/discriminative/LinearTrainer.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/classifier/discriminative/LinearTrainer.java Wed Apr 21 07:48:15 2010
@@ -77,7 +77,7 @@ public abstract class LinearTrainer {
CardinalityException,
TrainingException {
if (labelset.size() != dataset.size()[1]) {
- throw new CardinalityException();
+ throw new CardinalityException(labelset.size(), dataset.size()[1]);
}
boolean converged = false;
Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/common/distance/CosineDistanceMeasure.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/common/distance/CosineDistanceMeasure.java?rev=936186&r1=936185&r2=936186&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/common/distance/CosineDistanceMeasure.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/common/distance/CosineDistanceMeasure.java Wed Apr 21 07:48:15 2010
@@ -68,7 +68,7 @@ public class CosineDistanceMeasure imple
@Override
public double distance(Vector v1, Vector v2) {
if (v1.size() != v2.size()) {
- throw new CardinalityException();
+ throw new CardinalityException(v1.size(), v2.size());
}
double lengthSquaredv1 = v1.getLengthSquared();
double lengthSquaredv2 = v2.getLengthSquared();
Modified: lucene/mahout/trunk/core/src/main/java/org/apache/mahout/common/distance/ManhattanDistanceMeasure.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/common/distance/ManhattanDistanceMeasure.java?rev=936186&r1=936185&r2=936186&view=diff
==============================================================================
--- lucene/mahout/trunk/core/src/main/java/org/apache/mahout/common/distance/ManhattanDistanceMeasure.java (original)
+++ lucene/mahout/trunk/core/src/main/java/org/apache/mahout/common/distance/ManhattanDistanceMeasure.java Wed Apr 21 07:48:15 2010
@@ -58,7 +58,7 @@ public class ManhattanDistanceMeasure im
@Override
public double distance(Vector v1, Vector v2) {
if (v1.size() != v2.size()) {
- throw new CardinalityException();
+ throw new CardinalityException(v1.size(), v2.size());
}
double result = 0;
Vector vector = v1.minus(v2);
Modified: lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/CardinalityException.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/CardinalityException.java?rev=936186&r1=936185&r2=936186&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/CardinalityException.java (original)
+++ lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/CardinalityException.java Wed Apr 21 07:48:15 2010
@@ -17,11 +17,14 @@
package org.apache.mahout.math;
-/** Exception thrown when there is a cardinality mismatch in matrix operations */
-public class CardinalityException extends RuntimeException {
- public CardinalityException(int myCard, int otherCard) {
- super("My cardinality is: " + myCard + ", but the other is: " + otherCard);
+/**
+ * Exception thrown when there is a cardinality mismatch in matrix or vector operations.
+ * For example, vectors of differing cardinality cannot be added.
+ */
+public class CardinalityException extends IllegalArgumentException {
+
+ public CardinalityException(int expected, int cardinality) {
+ super("Required cardinality " + expected + " but got " + cardinality);
}
-
- public CardinalityException() { }
+
}
Modified: lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/DenseMatrix.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/DenseMatrix.java?rev=936186&r1=936185&r2=936186&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/DenseMatrix.java (original)
+++ lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/DenseMatrix.java Wed Apr 21 07:48:15 2010
@@ -94,12 +94,17 @@ public class DenseMatrix extends Abstrac
}
public Matrix viewPart(int[] offset, int[] size) {
- if (size[ROW] > rowSize() || size[COL] > columnSize()) {
- throw new CardinalityException();
+ if (offset[ROW] < 0) {
+ throw new IndexException(offset[ROW], rowSize());
}
- if (offset[ROW] < 0 || offset[ROW] + size[ROW] > rowSize() || offset[COL] < 0
- || offset[COL] + size[COL] > columnSize()) {
- throw new IndexException();
+ if (offset[ROW] + size[ROW] > rowSize()) {
+ throw new IndexException(offset[ROW] + size[ROW], rowSize());
+ }
+ if (offset[COL] < 0) {
+ throw new IndexException(offset[COL], columnSize());
+ }
+ if (offset[COL] + size[COL] > columnSize()) {
+ throw new IndexException(offset[COL] + size[COL], columnSize());
}
return new MatrixView(this, offset, size);
}
@@ -113,8 +118,11 @@ public class DenseMatrix extends Abstrac
}
public Matrix assignColumn(int column, Vector other) {
- if (other.size() != rowSize() || column >= columnSize()) {
- throw new CardinalityException();
+ if (rowSize() != other.size()) {
+ throw new CardinalityException(rowSize(), other.size());
+ }
+ if (column < 0 || column >= columnSize()) {
+ throw new IndexException(column, columnSize());
}
for (int row = 0; row < rowSize(); row++) {
values[row][column] = other.getQuick(row);
@@ -123,8 +131,11 @@ public class DenseMatrix extends Abstrac
}
public Matrix assignRow(int row, Vector other) {
- if (row >= rowSize() || other.size() != columnSize()) {
- throw new CardinalityException();
+ if (columnSize() != other.size()) {
+ throw new CardinalityException(columnSize(), other.size());
+ }
+ if (row < 0 || row >= rowSize()) {
+ throw new IndexException(row, rowSize());
}
for (int col = 0; col < columnSize(); col++) {
values[row][col] = other.getQuick(col);
@@ -134,14 +145,14 @@ public class DenseMatrix extends Abstrac
public Vector getColumn(int column) {
if (column < 0 || column >= columnSize()) {
- throw new IndexException();
+ throw new IndexException(column, columnSize());
}
return new TransposeViewVector(this, column);
}
public Vector getRow(int row) {
if (row < 0 || row >= rowSize()) {
- throw new IndexException();
+ throw new IndexException(row, rowSize());
}
return new DenseVector(values[row], true);
}
Modified: lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/IndexException.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/IndexException.java?rev=936186&r1=936185&r2=936186&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/IndexException.java (original)
+++ lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/IndexException.java Wed Apr 21 07:48:15 2010
@@ -17,13 +17,14 @@
package org.apache.mahout.math;
-/** Exception thrown when there is an index outside of [0, cardinality) */
-public class IndexException extends RuntimeException {
- public IndexException() {
-
- }
+/**
+ * Exception thrown when a matrix or vector is accessed at an index, or dimension,
+ * which does not logically exist in the entity.
+ */
+public class IndexException extends IllegalArgumentException {
public IndexException(int index, int cardinality) {
- super("index(" + index +") is out of bounds of (0, " + cardinality + ')');
+ super("Index " + index + " is outside allowable range of [0," + cardinality + ']');
}
+
}
Modified: lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/MatrixView.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/MatrixView.java?rev=936186&r1=936185&r2=936186&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/MatrixView.java (original)
+++ lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/MatrixView.java Wed Apr 21 07:48:15 2010
@@ -80,12 +80,17 @@ public class MatrixView extends Abstract
}
public Matrix viewPart(int[] offset, int[] size) {
- if (size[ROW] > cardinality[ROW] || size[COL] > cardinality[COL]) {
- throw new CardinalityException();
+ if (offset[ROW] < ROW) {
+ throw new IndexException(offset[ROW], ROW);
}
- if ((offset[ROW] < ROW || offset[ROW] + size[ROW] > cardinality[ROW])
- || (offset[COL] < ROW || offset[COL] + size[COL] > cardinality[COL])) {
- throw new IndexException();
+ if (offset[ROW] + size[ROW] > cardinality[ROW]) {
+ throw new IndexException(offset[ROW] + size[ROW], cardinality[ROW]);
+ }
+ if (offset[COL] < ROW) {
+ throw new IndexException(offset[COL], ROW);
+ }
+ if (offset[COL] + size[COL] > cardinality[COL]) {
+ throw new IndexException(offset[COL] + size[COL], cardinality[COL]);
}
int[] origin = offset.clone();
origin[ROW] += offset[ROW];
@@ -95,7 +100,7 @@ public class MatrixView extends Abstract
public Matrix assignColumn(int column, Vector other) {
if (cardinality[ROW] != other.size()) {
- throw new CardinalityException();
+ throw new CardinalityException(cardinality[ROW], other.size());
}
for (int row = 0; row < cardinality[ROW]; row++) {
matrix.setQuick(row + offset[ROW], column + offset[COL], other
@@ -106,7 +111,7 @@ public class MatrixView extends Abstract
public Matrix assignRow(int row, Vector other) {
if (cardinality[COL] != other.size()) {
- throw new CardinalityException();
+ throw new CardinalityException(cardinality[COL], other.size());
}
for (int col = 0; col < cardinality[COL]; col++) {
matrix
@@ -117,7 +122,7 @@ public class MatrixView extends Abstract
public Vector getColumn(int column) {
if (column < 0 || column >= cardinality[COL]) {
- throw new IndexException();
+ throw new IndexException(column, cardinality[COL]);
}
return new VectorView(matrix.getColumn(column + offset[COL]), offset[ROW],
cardinality[ROW]);
@@ -125,7 +130,7 @@ public class MatrixView extends Abstract
public Vector getRow(int row) {
if (row < 0 || row >= cardinality[ROW]) {
- throw new IndexException();
+ throw new IndexException(row, cardinality[ROW]);
}
return new VectorView(matrix.getRow(row + offset[ROW]), offset[COL],
cardinality[COL]);
Modified: lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/SparseColumnMatrix.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/SparseColumnMatrix.java?rev=936186&r1=936185&r2=936186&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/SparseColumnMatrix.java (original)
+++ lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/SparseColumnMatrix.java Wed Apr 21 07:48:15 2010
@@ -127,27 +127,38 @@ public class SparseColumnMatrix extends
}
public Matrix viewPart(int[] offset, int[] size) {
- if (size[COL] > columns.length || size[ROW] > columns[COL].size()) {
- throw new CardinalityException();
+ if (offset[ROW] < 0) {
+ throw new IndexException(offset[ROW], columns[COL].size());
}
- if (offset[COL] < 0 || offset[COL] + size[COL] > columns.length
- || offset[ROW] < 0 || offset[ROW] + size[ROW] > columns[COL].size()) {
- throw new IndexException();
+ if (offset[ROW] + size[ROW] > columns[COL].size()) {
+ throw new IndexException(offset[ROW] + size[ROW], columns[COL].size());
+ }
+ if (offset[COL] < 0) {
+ throw new IndexException(offset[COL], columns.length);
+ }
+ if (offset[COL] + size[COL] > columns.length) {
+ throw new IndexException(offset[COL] + size[COL], columns.length);
}
return new MatrixView(this, offset, size);
}
public Matrix assignColumn(int column, Vector other) {
- if (other.size() != cardinality[ROW] || column >= cardinality[COL]) {
- throw new CardinalityException();
+ if (cardinality[ROW] != other.size()) {
+ throw new CardinalityException(cardinality[ROW], other.size());
+ }
+ if (column < 0 || column >= cardinality[COL]) {
+ throw new IndexException(column, cardinality[COL]);
}
columns[column].assign(other);
return this;
}
public Matrix assignRow(int row, Vector other) {
- if (row >= cardinality[ROW] || other.size() != cardinality[COL]) {
- throw new CardinalityException();
+ if (cardinality[COL] != other.size()) {
+ throw new CardinalityException(cardinality[COL], other.size());
+ }
+ if (row < 0 || row >= cardinality[ROW]) {
+ throw new IndexException(row, cardinality[ROW]);
}
for (int col = 0; col < cardinality[COL]; col++) {
columns[col].setQuick(row, other.getQuick(col));
@@ -157,14 +168,14 @@ public class SparseColumnMatrix extends
public Vector getColumn(int column) {
if (column < 0 || column >= cardinality[COL]) {
- throw new IndexException();
+ throw new IndexException(column, cardinality[COL]);
}
return columns[column];
}
public Vector getRow(int row) {
if (row < 0 || row >= cardinality[ROW]) {
- throw new IndexException();
+ throw new IndexException(row, cardinality[ROW]);
}
return new TransposeViewVector(this, row, false);
}
Modified: lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/SparseMatrix.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/SparseMatrix.java?rev=936186&r1=936185&r2=936186&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/SparseMatrix.java (original)
+++ lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/SparseMatrix.java Wed Apr 21 07:48:15 2010
@@ -109,19 +109,27 @@ public class SparseMatrix extends Abstra
}
public Matrix viewPart(int[] offset, int[] size) {
- if (size[ROW] > cardinality[ROW] || size[COL] > cardinality[COL]) {
- throw new CardinalityException();
+ if (offset[ROW] < 0) {
+ throw new IndexException(offset[ROW], cardinality[ROW]);
}
- if (offset[ROW] < 0 || offset[ROW] + size[ROW] > cardinality[ROW]
- || offset[COL] < 0 || offset[COL] + size[COL] > cardinality[COL]) {
- throw new IndexException();
+ if (offset[ROW] + size[ROW] > cardinality[ROW]) {
+ throw new IndexException(offset[ROW] + size[ROW], cardinality[ROW]);
+ }
+ if (offset[COL] < 0) {
+ throw new IndexException(offset[COL], cardinality[COL]);
+ }
+ if (offset[COL] + size[COL] > cardinality[COL]) {
+ throw new IndexException(offset[COL] + size[COL], cardinality[COL]);
}
return new MatrixView(this, offset, size);
}
public Matrix assignColumn(int column, Vector other) {
- if (other.size() != cardinality[ROW] || column >= cardinality[COL]) {
- throw new CardinalityException();
+ if (cardinality[ROW] != other.size()) {
+ throw new CardinalityException(cardinality[ROW], other.size());
+ }
+ if (column < 0 || column >= cardinality[COL]) {
+ throw new IndexException(column, cardinality[COL]);
}
for (int row = 0; row < cardinality[ROW]; row++) {
double val = other.getQuick(row);
@@ -138,8 +146,11 @@ public class SparseMatrix extends Abstra
}
public Matrix assignRow(int row, Vector other) {
- if (row >= cardinality[ROW] || other.size() != cardinality[COL]) {
- throw new CardinalityException();
+ if (cardinality[COL] != other.size()) {
+ throw new CardinalityException(cardinality[COL], other.size());
+ }
+ if (row < 0 || row >= cardinality[ROW]) {
+ throw new IndexException(row, cardinality[ROW]);
}
rows.put(row, other);
return this;
@@ -147,7 +158,7 @@ public class SparseMatrix extends Abstra
public Vector getColumn(int column) {
if (column < 0 || column >= cardinality[COL]) {
- throw new IndexException();
+ throw new IndexException(column, cardinality[COL]);
}
double[] d = new double[cardinality[ROW]];
for (int row = 0; row < cardinality[ROW]; row++) {
@@ -158,7 +169,7 @@ public class SparseMatrix extends Abstra
public Vector getRow(int row) {
if (row < 0 || row >= cardinality[ROW]) {
- throw new IndexException();
+ throw new IndexException(row, cardinality[ROW]);
}
Vector res = rows.get(row);
if (res == null) {
Modified: lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/SparseRowMatrix.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/SparseRowMatrix.java?rev=936186&r1=936185&r2=936186&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/SparseRowMatrix.java (original)
+++ lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/SparseRowMatrix.java Wed Apr 21 07:48:15 2010
@@ -122,19 +122,27 @@ public class SparseRowMatrix extends Abs
}
public Matrix viewPart(int[] offset, int[] size) {
- if (size[ROW] > rows.length || size[COL] > rows[ROW].size()) {
- throw new CardinalityException();
+ if (offset[ROW] < 0) {
+ throw new IndexException(offset[ROW], rows.length);
}
- if (offset[ROW] < 0 || offset[ROW] + size[ROW] > rows.length
- || offset[COL] < 0 || offset[COL] + size[COL] > rows[ROW].size()) {
- throw new IndexException();
+ if (offset[ROW] + size[ROW] > rows.length) {
+ throw new IndexException(offset[ROW] + size[ROW], rows.length);
+ }
+ if (offset[COL] < 0) {
+ throw new IndexException(offset[COL], rows[ROW].size());
+ }
+ if (offset[COL] + size[COL] > rows[ROW].size()) {
+ throw new IndexException(offset[COL] + size[COL], rows[ROW].size());
}
return new MatrixView(this, offset, size);
}
public Matrix assignColumn(int column, Vector other) {
- if (other.size() != cardinality[ROW] || column >= cardinality[COL]) {
- throw new CardinalityException();
+ if (cardinality[ROW] != other.size()) {
+ throw new CardinalityException(cardinality[ROW], other.size());
+ }
+ if (column < 0 || column >= cardinality[COL]) {
+ throw new IndexException(column, cardinality[COL]);
}
for (int row = 0; row < cardinality[ROW]; row++) {
rows[row].setQuick(column, other.getQuick(row));
@@ -143,8 +151,11 @@ public class SparseRowMatrix extends Abs
}
public Matrix assignRow(int row, Vector other) {
- if (row >= cardinality[ROW] || other.size() != cardinality[COL]) {
- throw new CardinalityException();
+ if (cardinality[COL] != other.size()) {
+ throw new CardinalityException(cardinality[COL], other.size());
+ }
+ if (row < 0 || row >= cardinality[ROW]) {
+ throw new IndexException(row, cardinality[ROW]);
}
rows[row].assign(other);
return this;
@@ -157,7 +168,7 @@ public class SparseRowMatrix extends Abs
*/
public Vector getColumn(int column) {
if (column < 0 || column >= cardinality[COL]) {
- throw new IndexException();
+ throw new IndexException(column, cardinality[COL]);
}
return new TransposeViewVector(this, column) {
@Override
@@ -176,7 +187,7 @@ public class SparseRowMatrix extends Abs
*/
public Vector getRow(int row) {
if (row < 0 || row >= cardinality[ROW]) {
- throw new IndexException();
+ throw new IndexException(row, cardinality[ROW]);
}
return rows[row];
}
Modified: lucene/mahout/trunk/math/src/test/java/org/apache/mahout/math/MatrixTest.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/test/java/org/apache/mahout/math/MatrixTest.java?rev=936186&r1=936185&r2=936186&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/test/java/org/apache/mahout/math/MatrixTest.java (original)
+++ lucene/mahout/trunk/math/src/test/java/org/apache/mahout/math/MatrixTest.java Wed Apr 21 07:48:15 2010
@@ -140,10 +140,7 @@ public abstract class MatrixTest extends
try {
test.viewPart(offset, size);
fail("exception expected");
- } catch (CardinalityException e) {
- assertTrue(true);
} catch (IndexException e) {
- fail("cardinality exception expected");
}
}
@@ -153,10 +150,7 @@ public abstract class MatrixTest extends
try {
test.viewPart(offset, size);
fail("exception expected");
- } catch (CardinalityException e) {
- fail("index exception expected");
} catch (IndexException e) {
- assertTrue(true);
}
}
@@ -166,10 +160,7 @@ public abstract class MatrixTest extends
try {
test.viewPart(offset, size);
fail("exception expected");
- } catch (CardinalityException e) {
- fail("index exception expected");
} catch (IndexException e) {
- assertTrue(true);
}
}
@@ -201,7 +192,6 @@ public abstract class MatrixTest extends
test.assign(new double[c[ROW] + 1][c[COL]]);
fail("exception expected");
} catch (CardinalityException e) {
- assertTrue(true);
}
}
@@ -221,7 +211,6 @@ public abstract class MatrixTest extends
test.assign(test.transpose(), plus);
fail("exception expected");
} catch (CardinalityException e) {
- assertTrue(true);
}
}
@@ -242,7 +231,6 @@ public abstract class MatrixTest extends
test.assign(test.transpose());
fail("exception expected");
} catch (CardinalityException e) {
- assertTrue(true);
}
}
@@ -288,7 +276,6 @@ public abstract class MatrixTest extends
}
fail("index exception expected");
} catch (IndexException e) {
- assertTrue(true);
}
}
@@ -302,7 +289,6 @@ public abstract class MatrixTest extends
}
fail("index exception expected");
} catch (IndexException e) {
- assertTrue(true);
}
}
@@ -322,7 +308,6 @@ public abstract class MatrixTest extends
test.minus(test.transpose());
fail("cardinality exception expected");
} catch (CardinalityException e) {
- assertTrue(true);
}
}
@@ -353,7 +338,6 @@ public abstract class MatrixTest extends
test.plus(test.transpose());
fail("cardinality exception expected");
} catch (CardinalityException e) {
- assertTrue(true);
}
}
@@ -367,7 +351,6 @@ public abstract class MatrixTest extends
}
fail("index exception expected");
} catch (IndexException e) {
- assertTrue(true);
}
}
@@ -381,7 +364,6 @@ public abstract class MatrixTest extends
}
fail("index exception expected");
} catch (IndexException e) {
- assertTrue(true);
}
}
@@ -432,7 +414,6 @@ public abstract class MatrixTest extends
test.times(testTimesVectorA);
fail("Cardinalities do not match, should throw exception");
} catch (CardinalityException ce) {
- assertTrue(true);
}
}
@@ -452,7 +433,6 @@ public abstract class MatrixTest extends
test.times(other);
fail("cardinality exception expected");
} catch (CardinalityException e) {
- assertTrue(true);
}
}
@@ -488,7 +468,6 @@ public abstract class MatrixTest extends
test.assignRow(1, new DenseVector(data));
fail("expecting cardinality exception");
} catch (CardinalityException e) {
- assertTrue(true);
}
}
@@ -506,7 +485,6 @@ public abstract class MatrixTest extends
test.assignColumn(1, new DenseVector(data));
fail("expecting cardinality exception");
} catch (CardinalityException e) {
- assertTrue(true);
}
}
@@ -520,7 +498,6 @@ public abstract class MatrixTest extends
test.getRow(-1);
fail("expecting index exception");
} catch (IndexException e) {
- assertTrue(true);
}
}
@@ -529,7 +506,6 @@ public abstract class MatrixTest extends
test.getRow(5);
fail("expecting index exception");
} catch (IndexException e) {
- assertTrue(true);
}
}
@@ -543,7 +519,6 @@ public abstract class MatrixTest extends
test.getColumn(-1);
fail("expecting index exception");
} catch (IndexException e) {
- assertTrue(true);
}
}
@@ -552,7 +527,6 @@ public abstract class MatrixTest extends
test.getColumn(5);
fail("expecting index exception");
} catch (IndexException e) {
- assertTrue(true);
}
}
@@ -612,10 +586,7 @@ public abstract class MatrixTest extends
try {
m.get("Fie", "Foe");
fail("Expected UnboundLabelException");
- } catch (IndexException e) {
- fail("Expected UnboundLabelException");
} catch (UnboundLabelException e) {
- assertTrue(true);
}
}
Modified: lucene/mahout/trunk/math/src/test/java/org/apache/mahout/math/TestMatrixView.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/test/java/org/apache/mahout/math/TestMatrixView.java?rev=936186&r1=936185&r2=936186&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/test/java/org/apache/mahout/math/TestMatrixView.java (original)
+++ lucene/mahout/trunk/math/src/test/java/org/apache/mahout/math/TestMatrixView.java Wed Apr 21 07:48:15 2010
@@ -132,10 +132,7 @@ public class TestMatrixView extends Test
try {
test.viewPart(offset, size);
fail("exception expected");
- } catch (CardinalityException e) {
- assertTrue(true);
} catch (IndexException e) {
- fail("cardinality exception expected");
}
}
@@ -145,10 +142,7 @@ public class TestMatrixView extends Test
try {
test.viewPart(offset, size);
fail("exception expected");
- } catch (CardinalityException e) {
- fail("index exception expected");
} catch (IndexException e) {
- assertTrue(true);
}
}
@@ -158,10 +152,7 @@ public class TestMatrixView extends Test
try {
test.viewPart(offset, size);
fail("exception expected");
- } catch (CardinalityException e) {
- fail("index exception expected");
} catch (IndexException e) {
- assertTrue(true);
}
}
@@ -193,7 +184,6 @@ public class TestMatrixView extends Test
test.assign(new double[c[ROW] + 1][c[COL]]);
fail("exception expected");
} catch (CardinalityException e) {
- assertTrue(true);
}
}
@@ -213,7 +203,6 @@ public class TestMatrixView extends Test
test.assign(test.transpose(), plus);
fail("exception expected");
} catch (CardinalityException e) {
- assertTrue(true);
}
}
@@ -234,7 +223,6 @@ public class TestMatrixView extends Test
test.assign(test.transpose());
fail("exception expected");
} catch (CardinalityException e) {
- assertTrue(true);
}
}
@@ -280,7 +268,6 @@ public class TestMatrixView extends Test
}
fail("index exception expected");
} catch (IndexException e) {
- assertTrue(true);
}
}
@@ -294,7 +281,6 @@ public class TestMatrixView extends Test
}
fail("index exception expected");
} catch (IndexException e) {
- assertTrue(true);
}
}
@@ -314,7 +300,6 @@ public class TestMatrixView extends Test
test.minus(test.transpose());
fail("cardinality exception expected");
} catch (CardinalityException e) {
- assertTrue(true);
}
}
@@ -345,7 +330,6 @@ public class TestMatrixView extends Test
test.plus(test.transpose());
fail("cardinality exception expected");
} catch (CardinalityException e) {
- assertTrue(true);
}
}
@@ -359,7 +343,6 @@ public class TestMatrixView extends Test
}
fail("index exception expected");
} catch (IndexException e) {
- assertTrue(true);
}
}
@@ -373,7 +356,6 @@ public class TestMatrixView extends Test
}
fail("index exception expected");
} catch (IndexException e) {
- assertTrue(true);
}
}
@@ -404,7 +386,6 @@ public class TestMatrixView extends Test
test.times(other);
fail("cardinality exception expected");
} catch (CardinalityException e) {
- assertTrue(true);
}
}
@@ -440,7 +421,6 @@ public class TestMatrixView extends Test
test.assignRow(1, new DenseVector(data));
fail("expecting cardinality exception");
} catch (CardinalityException e) {
- assertTrue(true);
}
}
@@ -458,7 +438,6 @@ public class TestMatrixView extends Test
test.assignColumn(1, new DenseVector(data));
fail("expecting cardinality exception");
} catch (CardinalityException e) {
- assertTrue(true);
}
}
@@ -472,7 +451,6 @@ public class TestMatrixView extends Test
test.getRow(-1);
fail("expecting index exception");
} catch (IndexException e) {
- assertTrue(true);
}
}
@@ -481,7 +459,6 @@ public class TestMatrixView extends Test
test.getRow(5);
fail("expecting index exception");
} catch (IndexException e) {
- assertTrue(true);
}
}
@@ -495,7 +472,6 @@ public class TestMatrixView extends Test
test.getColumn(-1);
fail("expecting index exception");
} catch (IndexException e) {
- assertTrue(true);
}
}
@@ -504,7 +480,6 @@ public class TestMatrixView extends Test
test.getColumn(5);
fail("expecting index exception");
} catch (IndexException e) {
- assertTrue(true);
}
}
@@ -540,10 +515,7 @@ public class TestMatrixView extends Test
try {
test.get("Fie", "Foe");
fail("Expected UnboundLabelException");
- } catch (IndexException e) {
- fail("Expected UnboundLabelException");
} catch (UnboundLabelException e) {
- assertTrue(true);
}
}