use of org.apache.sis.test.DependsOnMethod in project sis by apache.
the class TensorParametersTest method testMatrixConversion.
/**
* Tests {@link TensorParameters#createValueGroup(Map, Matrix)} and its converse
* {@link TensorParameters#toMatrix(ParameterValueGroup)}.
*/
@Test
@DependsOnMethod("testGetAllDescriptors")
public void testMatrixConversion() {
final int size = StrictMath.min(6, TensorParameters.CACHE_SIZE);
final Random random = TestUtilities.createRandomNumberGenerator();
for (int numRow = 2; numRow <= size; numRow++) {
for (int numCol = 2; numCol <= size; numCol++) {
final Matrix matrix = Matrices.createZero(numRow, numCol);
for (int j = 0; j < numRow; j++) {
for (int i = 0; i < numCol; i++) {
matrix.setElement(j, i, 200 * random.nextDouble() - 100);
}
}
final ParameterValueGroup group = param.createValueGroup(singletonMap(ParameterDescriptor.NAME_KEY, "Test"), matrix);
assertEquals(NUM_ROW, numRow, group.parameter(NUM_ROW).intValue());
assertEquals(NUM_COL, numCol, group.parameter(NUM_COL).intValue());
assertEquals("elements", matrix, param.toMatrix(group));
assertEquals("elements", matrix, param.toMatrix(new ParameterValueGroupWrapper(group)));
}
}
}
use of org.apache.sis.test.DependsOnMethod in project sis by apache.
the class CoordinateSystemsTest method testSwapAndScaleAxes.
/**
* Tests {@link CoordinateSystems#swapAndScaleAxes(CoordinateSystem, CoordinateSystem)}
* with a more arbitrary case, which include unit conversions.
*
* @throws IncommensurableException if a conversion between incompatible units was attempted.
*/
@Test
@DependsOnMethod("testSwapAndScaleAxes3D")
public void testSwapAndScaleAxes() throws IncommensurableException {
final CoordinateSystem hxy = new DefaultCartesianCS(singletonMap(NAME_KEY, "(h,x,y)"), HardCodedAxes.HEIGHT_cm, HardCodedAxes.EASTING, HardCodedAxes.NORTHING);
final CoordinateSystem yxh = new DefaultCartesianCS(singletonMap(NAME_KEY, "(y,x,h)"), HardCodedAxes.SOUTHING, HardCodedAxes.EASTING, HardCodedAxes.DEPTH);
assertTrue(swapAndScaleAxes(hxy, hxy).isIdentity());
assertTrue(swapAndScaleAxes(yxh, yxh).isIdentity());
assertMatrixEquals("(h,x,y) → (y,x,h)", Matrices.create(4, 4, new double[] { 0, 0, -1, 0, 0, 1, 0, 0, -0.01, 0, 0, 0, 0, 0, 0, 1 }), swapAndScaleAxes(hxy, yxh), STRICT);
assertMatrixEquals("(y,x,h) → (h,x,y)", Matrices.create(4, 4, new double[] { 0, 0, -100, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 1 }), swapAndScaleAxes(yxh, hxy), STRICT);
}
use of org.apache.sis.test.DependsOnMethod in project sis by apache.
the class CoordinateSystemsTest method testScaleAndSwapAxesNonSquare.
/**
* Tests {@link CoordinateSystems#swapAndScaleAxes(CoordinateSystem, CoordinateSystem)} with a non-square matrix.
*
* @throws IncommensurableException if a conversion between incompatible units was attempted.
*/
@Test
@DependsOnMethod("testSwapAndScaleAxes")
public void testScaleAndSwapAxesNonSquare() throws IncommensurableException {
final DefaultCartesianCS cs = new DefaultCartesianCS(singletonMap(NAME_KEY, "Test"), new DefaultCoordinateSystemAxis(getProperties(HardCodedAxes.SOUTHING), "y", AxisDirection.SOUTH, Units.CENTIMETRE), new DefaultCoordinateSystemAxis(getProperties(HardCodedAxes.EASTING), "x", AxisDirection.EAST, Units.MILLIMETRE));
Matrix matrix = swapAndScaleAxes(HardCodedCS.CARTESIAN_2D, cs);
assertMatrixEquals("(x,y) → (y,x)", Matrices.create(3, 3, new double[] { 0, -100, 0, 1000, 0, 0, 0, 0, 1 }), matrix, STRICT);
matrix = swapAndScaleAxes(HardCodedCS.CARTESIAN_3D, cs);
assertMatrixEquals("(x,y,z) → (y,x)", Matrices.create(3, 4, new double[] { 0, -100, 0, 0, 1000, 0, 0, 0, 0, 0, 0, 1 }), matrix, STRICT);
}
use of org.apache.sis.test.DependsOnMethod in project sis by apache.
the class TreeTableFormatTest method testTreeTableParse.
/**
* Tests the parsing of a tree table. This method parses and reformats a tree table,
* and performs its check on the assumption that the tree table formatting is accurate.
*
* @throws ParseException if the parsing failed.
*/
@Test
@DependsOnMethod("testTreeTableFormat")
public void testTreeTableParse() throws ParseException {
final TableColumn<Integer> valueA = new TableColumn<>(Integer.class, "value #1");
final TableColumn<String> valueB = new TableColumn<>(String.class, "value #2");
final TreeTableFormat tf = new TreeTableFormat(null, null);
tf.setColumns(NAME, valueA, valueB);
tf.setVerticalLinePosition(1);
final String text = "Node #1………………………… 10…… Value #1B\n" + " ├──Node #2……………… 20\n" + " │ └──Node #4…… 40…… Value #4B\n" + " └──Node #3……………… ………… Value #3B\n";
final TreeTable table = tf.parseObject(text);
assertMultilinesEquals(text, tf.format(table));
}
use of org.apache.sis.test.DependsOnMethod in project sis by apache.
the class TreeTableFormatTest method testTreeParse.
/**
* Tests the parsing of a tree. This method parses and reformats a tree,
* and performs its check on the assumption that the tree formatting is
* accurate.
*
* @throws ParseException if the parsing failed.
*/
@Test
@DependsOnMethod("testTreeFormat")
public void testTreeParse() throws ParseException {
final TreeTableFormat tf = new TreeTableFormat(null, null);
tf.setVerticalLinePosition(0);
final String text = "Node #1\n" + "├───Node #2\n" + "│ └───Node #4\n" + "└───Node #3\n";
final TreeTable table = tf.parseObject(text);
assertMultilinesEquals(text, tf.format(table));
}
Aggregations