Ejemplo n.º 1
0
    def test__identify_sample_groups_not_strict(self):
        # Defines the know values
        known_pairs = {
            1: [
                np.array(['PP'], dtype=object),
                np.array(['CD', 'NR'], dtype=object)
            ],
            0: [
                np.array(['MM', 'WM'], dtype=object),
                np.array(['MH'], dtype=object)
            ],
            2:
            [np.array(['GW'], dtype=object),
             np.array(['CB'], dtype=object)]
        }
        known_index = np.array([0, 1, 2])
        test_pairs, test_index = _identify_sample_groups(self.meta,
                                                         'INT', ['SEX', 'ABX'],
                                                         order=['N', 'Y'],
                                                         strict_match=False)
        self.assertEqual(known_pairs.keys(), test_pairs.keys())

        for k in known_pairs:
            for i in range(2):
                npt.assert_array_equal(known_pairs[k][i], test_pairs[k][i])
        npt.assert_array_equal(known_index, test_index)
Ejemplo n.º 2
0
 def test__identify_sample_groups_not_strict(self):
     # Defines the know values
     known_pairs = {0: [['PP'], ['CD', 'NR']],
                    1: [['MM', 'WM'], ['MH']],
                    2: [['GW'], ['CB']]}
     known_index = np.array([0, 1, 2])
     test_pairs, test_index = _identify_sample_groups(self.meta,
                                                      'INT',
                                                      ['SEX', 'ABX'],
                                                      order=['N', 'Y'],
                                                      strict_match=False)
     self.assertEqual(known_pairs.keys(), test_pairs.keys())
     self.assertEqual(sorted(known_pairs.values()),
                      sorted(test_pairs.values()))
     npt.assert_array_equal(known_index, test_index)
Ejemplo n.º 3
0
 def test__identify_sample_groups(self):
     # Defines the know values
     known_pairs = {0: [['MM'], ['CD']],
                    1: [['SR'], ['LF']],
                    2: [['TS'], ['PC']],
                    3: [['GW'], ['CB']],
                    4: [['PP'], ['MH']],
                    5: [['WM'], ['NR']]}
     known_index = np.array([0, 1, 2, 3, 4, 5])
     test_pairs, test_index = _identify_sample_groups(self.meta,
                                                      'INT',
                                                      ['SEX', 'AGE'],
                                                      order=['N', 'Y'],
                                                      strict_match=True)
     self.assertEqual(known_pairs.keys(), test_pairs.keys())
     self.assertEqual(sorted(known_pairs.values()),
                      sorted(test_pairs.values()))
     npt.assert_array_equal(known_index, test_index)
Ejemplo n.º 4
0
    def test__identify_sample_groups_not_strict(self):
        # Defines the know values
        known_pairs = {1: [np.array(['PP'], dtype=object),
                           np.array(['CD', 'NR'], dtype=object)],
                       0: [np.array(['MM', 'WM'], dtype=object),
                           np.array(['MH'], dtype=object)],
                       2: [np.array(['GW'], dtype=object),
                           np.array(['CB'], dtype=object)]}
        known_index = np.array([0, 1, 2])
        test_pairs, test_index = _identify_sample_groups(self.meta,
                                                         'INT',
                                                         ['SEX', 'ABX'],
                                                         order=['N', 'Y'],
                                                         strict_match=False)
        self.assertEqual(known_pairs.keys(), test_pairs.keys())

        for k in known_pairs:
            for i in range(2):
                npt.assert_array_equal(known_pairs[k][i], test_pairs[k][i])
        npt.assert_array_equal(known_index, test_index)