StringLabelledMatrix1D extends LabelledMatrix1D<String, String> { @Override public LabelledMatrix1D<String, String> add(final LabelledMatrix1D<String, String> other) { return addIgnoringLabel(other); } StringLabelledMatrix1D(final String[] keys, final double[] values);  StringLabelledMatrix1D(final String[] keys, final Object[] labels, final double[] values);  StringLabelledMatrix1D(final String[] keys, final String labelsTitle, final double[] values, final String valuesTitle);  StringLabelledMatrix1D(final String[] keys, final Object[] labels, final String labelsTitle, final double[] values, final String valuesTitle); @Override int compare(final String key1, final String key2, final String tolerance); @Override LabelledMatrix1D<String, String> getMatrix(final String[] keys, final Object[] labels, final String labelsTitle, final double[] values, final String valuesTitle); @Override LabelledMatrix1D<String, String> getMatrix(final String[] keys, final Object[] labels, final double[] values); @Override LabelledMatrix1D<String, String> getMatrix(final String[] keys, final double[] values); @Override LabelledMatrix1D<String, String> add(final LabelledMatrix1D<String, String> other); @Override LabelledMatrix1D<String, String> add(final LabelledMatrix1D<String, String> other, final String tolerance);  }
@Test public void testAddDifferentLabels() { String[] keys = new String[] {"A", "B", "C", "D", "E", "F", "G", "H"}; Object[] labels = new Object[] {"A", "B", "C", "D", "E", "F", "G", "H"}; double[] values = new double[] {1, 2, 3, 4, 100, 200, 300, 400}; LabelledMatrix1D<String, String> sum = M.add(new StringLabelledMatrix1D(NAMES4, VALUES4)); assertEquals(sum, new StringLabelledMatrix1D(keys, values)); assertArrayEquals(labels, sum.getLabels()); sum = M.addIgnoringLabel(new StringLabelledMatrix1D(NAMES4, VALUES4)); assertEquals(sum, new StringLabelledMatrix1D(keys, values)); assertArrayEquals(labels, sum.getLabels()); sum = M.addIgnoringLabel(new StringLabelledMatrix1D(NAMES4, VALUES4), "E"); assertEquals(sum, new StringLabelledMatrix1D(keys, values)); assertArrayEquals(labels, sum.getLabels()); sum = M.add(new StringLabelledMatrix1D(NAMES4, VALUES4), "E"); assertEquals(sum, new StringLabelledMatrix1D(keys, values)); assertArrayEquals(labels, sum.getLabels()); }
@Test public void testAddSameLabels() { String[] keys = new String[] {"A", "B", "C", "D"}; Object[] labels = new Object[] {"A", "B", "C", "D"}; double[] values = new double[] {11, 22, 33, 44}; LabelledMatrix1D<String, String> sum = M.add(new StringLabelledMatrix1D(NAMES3, VALUES3)); assertEquals(sum, new StringLabelledMatrix1D(keys, values)); assertArrayEquals(labels, sum.getLabels()); sum = M.addIgnoringLabel(new StringLabelledMatrix1D(NAMES3, VALUES3)); assertEquals(sum, new StringLabelledMatrix1D(keys, values)); assertArrayEquals(labels, sum.getLabels()); sum = M.addIgnoringLabel(new StringLabelledMatrix1D(NAMES3, VALUES3), "L"); assertEquals(sum, new StringLabelledMatrix1D(keys, values)); assertArrayEquals(labels, sum.getLabels()); sum = M.add(new StringLabelledMatrix1D(NAMES3, VALUES3), "L"); assertEquals(sum, new StringLabelledMatrix1D(keys, values)); assertArrayEquals(labels, sum.getLabels()); }
@Test public void testAdd() { String[] keys = new String[] {"A", "B", "C", "D", "E", "F"}; Object[] labels = new Object[] {"A", "B", "C", "D", "E", "F"}; double[] values = new double[] {401, 2, 3, 304, 100, 200}; LabelledMatrix1D<String, String> sum = M.add(new StringLabelledMatrix1D(NAMES5, VALUES5)); assertEquals(sum, new StringLabelledMatrix1D(keys, values)); assertArrayEquals(labels, sum.getLabels()); sum = M.addIgnoringLabel(new StringLabelledMatrix1D(NAMES5, VALUES5), "P"); assertEquals(sum, new StringLabelledMatrix1D(keys, values)); assertArrayEquals(labels, sum.getLabels()); sum = M.add(new StringLabelledMatrix1D(NAMES5, VALUES5), "P"); assertEquals(sum, new StringLabelledMatrix1D(keys, values)); assertArrayEquals(labels, sum.getLabels()); }