<commit_before>/**
 * Copyright (C) 2011 - present by OpenGamma Inc. and the OpenGamma group of companies
 * 
 * Please see distribution for license.
 */
package com.opengamma.financial.analytics;

import static org.testng.AssertJUnit.assertEquals;
import static org.testng.internal.junit.ArrayAsserts.assertArrayEquals;

import org.testng.annotations.Test;

/**
 * 
 */
public class DoubleLabelledMatrix2DTest {
  private static final Double[] SORTED_X_KEYS = new Double[] {1., 2., 3., 4., 5.};
  private static final Double[] SORTED_Y_KEYS = new Double[] {1., 2., 3.};
  private static final Object[] SORTED_X_LABELS1 = new String[] {"1.0", "2.0", "3.0", "4.0", "5.0"};
  private static final Object[] SORTED_Y_LABELS1 = new String[] {"1.0", "2.0", "3.0"};
  private static final Object[] SORTED_X_LABELS2 = new String[] {"A", "B", "C", "D", "E"};
  private static final Object[] SORTED_Y_LABELS2 = new String[] {"A", "B", "C"};
  private static final double[][] SORTED_VALUES = new double[][] {new double[] {1, 2, 3, 4, 5}, new double[] {2, 4, 6, 8, 10}, new double[] {3, 6, 9, 12, 15}};
  private static final Double[] X_KEYS = new Double[] {2., 1., 3., 5., 4.};
  private static final Double[] Y_KEYS = new Double[] {2., 3., 1.};
  private static final Object[] X_LABELS1 = new Object[] {"2.0", "1.0", "3.0", "5.0", "4.0"};
  private static final Object[] Y_LABELS1 = new Object[] {"2.0", "3.0", "1.0"};
  private static final Object[] X_LABELS2 = new Object[] {"B", "A", "C", "E", "D"};
  private static final Object[] Y_LABELS2 = new Object[] {"B", "C", "A"};
  private static final double[][] VALUES = new double[][] {new double[] {4, 2, 6, 10, 8}, new double[] {6, 3, 9, 15, 12}, new double[] {2, 1, 3, 5, 4}};

  @Test
  public void test() {
    DoubleLabelledMatrix2D result = new DoubleLabelledMatrix2D(X_KEYS, Y_KEYS, VALUES);
    testResult(result, SORTED_X_LABELS1, SORTED_Y_LABELS1);
    result = new DoubleLabelledMatrix2D(X_KEYS, X_LABELS1, Y_KEYS, Y_LABELS1, VALUES);
    testResult(result, SORTED_X_LABELS1, SORTED_Y_LABELS1);
    result = new DoubleLabelledMatrix2D(X_KEYS, X_LABELS2, Y_KEYS, Y_LABELS2, VALUES);
    testResult(result, SORTED_X_LABELS2, SORTED_Y_LABELS2);
  }

  //@Test
  public void testAdd() {
    Double[] otherX = new Double[] {6., 7.};
    Double[] otherY = new Double[] {4., 5., 6., 7., 8.};
    Object[] otherXLabels = new Object[] {"F", "G"};
    Object[] otherYLabels = new Object[] {"D", "E", "F", "G", "H"};
    double[][] values = new double[][] {new double[] {24, 28}, new double[] {30, 35}, new double[] {36, 42}, new double[] {42, 49}, new double[] {48, 56}};
    final DoubleLabelledMatrix2D originalMatrix = new DoubleLabelledMatrix2D(SORTED_X_KEYS, SORTED_X_LABELS2, SORTED_Y_KEYS, SORTED_Y_LABELS2, SORTED_VALUES);
    DoubleLabelledMatrix2D otherMatrix = new DoubleLabelledMatrix2D(otherX, otherXLabels, otherY, otherYLabels, values);
    LabelledMatrix2D<Double, Double> sum = originalMatrix.add(otherMatrix, 0.0001, 0.0001);
    double[][] expectedValues = new double[][] {new double[] {1, 2, 3, 4, 5, 0, 0},
                                                new double[] {2, 4, 6, 8, 10, 0, 0},<commit_msg>Forgot to commit this<commit_after>/**
 * Copyright (C) 2011 - present by OpenGamma Inc. and the OpenGamma group of companies
 * 
 * Please see distribution for license.
 */
package com.opengamma.financial.analytics;

import static org.testng.AssertJUnit.assertEquals;
import static org.testng.internal.junit.ArrayAsserts.assertArrayEquals;

import org.testng.annotations.Test;

/**
 * 
 */
public class DoubleLabelledMatrix2DTest {
  private static final Double[] SORTED_X_KEYS = new Double[] {1., 2., 3., 4., 5.};
  private static final Double[] SORTED_Y_KEYS = new Double[] {1., 2., 3.};
  private static final Object[] SORTED_X_LABELS1 = new String[] {"1.0", "2.0", "3.0", "4.0", "5.0"};
  private static final Object[] SORTED_Y_LABELS1 = new String[] {"1.0", "2.0", "3.0"};
  private static final Object[] SORTED_X_LABELS2 = new String[] {"A", "B", "C", "D", "E"};
  private static final Object[] SORTED_Y_LABELS2 = new String[] {"A", "B", "C"};
  private static final double[][] SORTED_VALUES = new double[][] {new double[] {1, 2, 3, 4, 5}, new double[] {2, 4, 6, 8, 10}, new double[] {3, 6, 9, 12, 15}};
  private static final Double[] X_KEYS = new Double[] {2., 1., 3., 5., 4.};
  private static final Double[] Y_KEYS = new Double[] {2., 3., 1.};
  private static final Object[] X_LABELS1 = new Object[] {"2.0", "1.0", "3.0", "5.0", "4.0"};
  private static final Object[] Y_LABELS1 = new Object[] {"2.0", "3.0", "1.0"};
  private static final Object[] X_LABELS2 = new Object[] {"B", "A", "C", "E", "D"};
  private static final Object[] Y_LABELS2 = new Object[] {"B", "C", "A"};
  private static final double[][] VALUES = new double[][] {new double[] {4, 2, 6, 10, 8}, new double[] {6, 3, 9, 15, 12}, new double[] {2, 1, 3, 5, 4}};

  @Test
  public void test() {
    DoubleLabelledMatrix2D result = new DoubleLabelledMatrix2D(X_KEYS, Y_KEYS, VALUES);
    testResult(result, SORTED_X_LABELS1, SORTED_Y_LABELS1);
    result = new DoubleLabelledMatrix2D(X_KEYS, X_LABELS1, Y_KEYS, Y_LABELS1, VALUES);
    testResult(result, SORTED_X_LABELS1, SORTED_Y_LABELS1);
    result = new DoubleLabelledMatrix2D(X_KEYS, X_LABELS2, Y_KEYS, Y_LABELS2, VALUES);
    testResult(result, SORTED_X_LABELS2, SORTED_Y_LABELS2);
  }

  @Test
  public void testAdd() {
    Double[] otherX = new Double[] {6., 7.};
    Double[] otherY = new Double[] {4., 5., 6., 7., 8.};
    Object[] otherXLabels = new Object[] {"F", "G"};
    Object[] otherYLabels = new Object[] {"D", "E", "F", "G", "H"};
    double[][] values = new double[][] {new double[] {24, 28}, new double[] {30, 35}, new double[] {36, 42}, new double[] {42, 49}, new double[] {48, 56}};
    final DoubleLabelledMatrix2D originalMatrix = new DoubleLabelledMatrix2D(SORTED_X_KEYS, SORTED_X_LABELS2, SORTED_Y_KEYS, SORTED_Y_LABELS2, SORTED_VALUES);
    DoubleLabelledMatrix2D otherMatrix = new DoubleLabelledMatrix2D(otherX, otherXLabels, otherY, otherYLabels, values);
    LabelledMatrix2D<Double, Double> sum = originalMatrix.add(otherMatrix, 0.0001, 0.0001);
    double[][] expectedValues = new double[][] {new double[] {1, 2, 3, 4, 5, 0, 0},
                                                new double[] {2, 4, 6, 8, 10, 0, 0},
{'fraction_non_alphanumeric': 0.17544966866519407, 'fraction_numerical': 0.05364468286525718, 'mean_word_length': 4.128640776699029, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5330731', 'n_tokens_mistral': 2491, 'n_tokens_neox': 2335, 'n_words': 714}