use of org.apache.ignite.ml.math.exceptions.UnsupportedOperationException in project ignite by apache.
the class CacheMatrixTest method testLike.
/**
*/
public void testLike() throws Exception {
MatrixKeyMapper<Integer> keyMapper = getKeyMapper(rows, cols);
IgniteCache<Integer, Double> cache = getCache();
CacheMatrix<Integer, Double> cacheMatrix = new CacheMatrix<>(rows, cols, cache, keyMapper, new IdentityValueMapper());
try {
cacheMatrix.like(rows, cols);
fail("UnsupportedOperationException expected");
} catch (UnsupportedOperationException e) {
// No-op.
}
}
use of org.apache.ignite.ml.math.exceptions.UnsupportedOperationException in project ignite by apache.
the class CacheMatrixTest method testCopy.
/**
*/
public void testCopy() throws Exception {
MatrixKeyMapper<Integer> keyMapper = getKeyMapper(rows, cols);
IgniteCache<Integer, Double> cache = getCache();
CacheMatrix<Integer, Double> cacheMatrix = new CacheMatrix<>(rows, cols, cache, keyMapper, new IdentityValueMapper());
fillMatrix(cacheMatrix);
try {
cacheMatrix.copy();
fail("UnsupportedOperationException expected");
} catch (UnsupportedOperationException e) {
// No-op.
}
}
use of org.apache.ignite.ml.math.exceptions.UnsupportedOperationException in project ignite by apache.
the class FunctionMatrixConstructorTest method basicTest.
/**
*/
private void basicTest(int rows, int cols) {
double[][] data = new double[rows][cols];
for (int row = 0; row < rows; row++) for (int col = 0; col < cols; col++) data[row][col] = row * cols + row;
Matrix mReadOnly = new FunctionMatrix(rows, cols, (i, j) -> data[i][j]);
assertEquals("Rows in matrix.", rows, mReadOnly.rowSize());
assertEquals("Cols in matrix.", cols, mReadOnly.columnSize());
for (int row = 0; row < rows; row++) for (int col = 0; col < cols; col++) {
assertEquals("Unexpected value at " + row + "x" + col, data[row][col], mReadOnly.get(row, col), 0d);
boolean expECaught = false;
try {
mReadOnly.set(row, col, 0.0);
} catch (UnsupportedOperationException uoe) {
expECaught = true;
}
assertTrue("Expected exception wasn't thrown at " + row + "x" + col, expECaught);
}
Matrix m = new FunctionMatrix(rows, cols, (i, j) -> data[i][j], (i, j, val) -> data[i][j] = val);
assertEquals("Rows in matrix, with setter function.", rows, m.rowSize());
assertEquals("Cols in matrix, with setter function.", cols, m.columnSize());
for (int row = 0; row < rows; row++) for (int col = 0; col < cols; col++) {
assertEquals("Unexpected value at " + row + "x" + col, data[row][col], m.get(row, col), 0d);
m.set(row, col, -data[row][col]);
}
for (int row = 0; row < rows; row++) for (int col = 0; col < cols; col++) assertEquals("Unexpected value set at " + row + "x" + col, -(row * cols + row), m.get(row, col), 0d);
assertTrue("Incorrect copy for empty matrix.", m.copy().equals(m));
}
use of org.apache.ignite.ml.math.exceptions.UnsupportedOperationException in project ignite by apache.
the class MatrixImplementationsTest method testLikeVector.
/**
*/
@Test
public void testLikeVector() {
consumeSampleMatrix((m, desc) -> {
if (likeVectorTypesMap().containsKey(m.getClass())) {
Vector likeVector = m.likeVector(m.columnSize());
assertNotNull(likeVector);
assertEquals("Unexpected value for " + desc, likeVector.size(), m.columnSize());
return;
}
boolean expECaught = false;
try {
m.likeVector(1);
} catch (UnsupportedOperationException uoe) {
expECaught = true;
}
assertTrue("Expected exception was not caught for " + desc, expECaught);
});
}
use of org.apache.ignite.ml.math.exceptions.UnsupportedOperationException in project ignite by apache.
the class CacheVectorTest method testLikeMatrix.
/**
*/
public void testLikeMatrix() {
IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
IdentityValueMapper valMapper = new IdentityValueMapper();
CacheVector<Integer, Double> cacheVector = new CacheVector<>(size, getCache(), keyMapper, valMapper);
try {
cacheVector.likeMatrix(size, size);
TestCase.fail("Unsupported case");
} catch (UnsupportedOperationException ignored) {
}
}
Aggregations