Esempio n. 1
0
 def test_generate_new_names_old_disjoint_strict(self):
     with self.assertRaises(ValueError) as cm:
         _rename._generate_new_names(self.old_ids,
                                     self.name_map,
                                     strict=True,
                                     verbose=False)
         self.assertEqual(
             str(cm.exception),
             ("There are ids in the table which do not have new names.\n"
              "Either turn off strict mode or provide a remapping for "
              "all ids.\nThe following ids are not mapped:\n    S3"))
Esempio n. 2
0
 def test_generate_new_names_non_unique(self):
     name_map = pd.Series({'S1': 'S2_new', 'S2': 'S2_new'})
     with self.assertRaises(ValueError) as cm:
         _rename._generate_new_names(self.old_ids,
                                     name_map,
                                     strict=True,
                                     verbose=False)
         self.assertEqual(
             str(cm.exception),
             ('All new ids must be unique.\n'
              'Try the group method in this plugin if you want '
              'to combine multiple samples in the same table.'))
Esempio n. 3
0
 def test_generate_new_names_verbose_warnings(self):
     with warnings.catch_warnings(record=True) as w:
         # Cause all warnings to always be triggered.
         warnings.simplefilter("always")
         new_names = \
             _rename._generate_new_names(self.old_ids,
                                         self.name_map,
                                         strict=False,
                                         verbose=True)
     self.assertEqual(len(w), 2)
     self.assertTrue(isinstance(w[0].message, UserWarning))
     self.assertEqual(
         str(w[0].message),
         'There are ids in the original table which do not '
         'have new names.\nThe following ids will not be '
         'included:\n   S3')
     self.assertTrue(isinstance(w[1].message, UserWarning))
     self.assertEqual(
         str(w[1].message),
         'There are ids supplied for renaming that are not in'
         ' the table.\nThe following ids will not be mapped:'
         '\n   S4')
     self.assertEqual(new_names.keys(), self.known.keys())
     for k, v in new_names.items():
         self.assertEqual(v, self.known[k])
Esempio n. 4
0
 def test_generate_new_names_no_verbse(self):
     with warnings.catch_warnings(record=True) as w:
         # Cause all warnings to always be triggered.
         warnings.simplefilter("always")
         new_names = \
             _rename._generate_new_names(self.old_ids,
                                         self.name_map,
                                         strict=False,
                                         verbose=False)
     self.assertEqual(len(w), 0)
     self.assertEqual(new_names.keys(), self.known.keys())
     for k, v in new_names.items():
         self.assertEqual(v, self.known[k])