def testDeleteNonexistentAttribute(self): # Deletes nonexistent attribute dataPath = os.path.join(THIS_DIR, "test/DataSets/Tests/StringData.csv") se = StringEnumerator(dataPath, "phenotype") with self.assertRaises(Exception) as context: se.delete_attribute("N") self.assertTrue("Header Doesn't Exist" in str(context.exception))
def testdelete_attribute(self): # Deletes attributes and checks map, headers, and arrays for correctness dataPath = os.path.join(THIS_DIR, "test/DataSets/Tests/StringData.csv") se = StringEnumerator(dataPath, "phenotype") se.change_header_name("N1", "gender") se.add_attribute_converter_random("gender") se.add_attribute_converter_random("N3") se.delete_attribute("gender") cHeaders = np.array(["N2", "N3"]) cMap = {"N3": {"young": "0", "old": "1"}} self.assertTrue(np.array_equal(cHeaders, se.dataHeaders)) self.assertTrue(np.array_equal("phenotype", se.classLabel)) self.assertTrue(se.map == cMap)