def testchange_class_nameInvalid(self):
        # Changes class name to an existing header name should raise exception
        dataPath = os.path.join(THIS_DIR, "test/DataSets/Tests/StringData.csv")
        se = StringEnumerator(dataPath, "phenotype")
        with self.assertRaises(Exception) as context:
            se.change_class_name("N1")

        self.assertTrue(
            "New Class Name Cannot Be An Already Existing Data Header Name" in
            str(context.exception))
 def testChangeClassAndHeaderNames(self):
     # Changes header and class names. Checks map, and classLabel/dataHeaders correctness
     dataPath = os.path.join(THIS_DIR, "test/DataSets/Tests/StringData.csv")
     se = StringEnumerator(dataPath, "phenotype")
     se.change_class_name("country")
     se.change_header_name("N1", "gender")
     se.change_header_name("N2", "N1")
     se.change_header_name("N1", "floats")
     se.change_header_name("N3", "phenotype")
     se.change_header_name("phenotype", "age")
     cHeaders = np.array(["gender", "floats", "age"])
     self.assertTrue(np.array_equal(cHeaders, se.dataHeaders))
     self.assertTrue(np.array_equal("country", se.classLabel))
 def testget_params2(self):
     # Get Params Test
     dataPath = os.path.join(THIS_DIR, "test/DataSets/Tests/StringData.csv")
     se = StringEnumerator(dataPath, "phenotype")
     se.change_header_name("N1", "gender")
     se.change_header_name("N2", "floats")
     se.change_header_name("N3", "age")
     se.change_class_name("country")
     se.add_attribute_converter("gender",
                                np.array(["female", "male", "NA", "other"]))
     se.add_attribute_converter("age", np.array(["old", "young"]))
     se.add_class_converter_random()
     se.convert_all_attributes()
     dataHeaders, classLabel, dataFeatures, dataPhenotypes = se.get_params()
     cHeaders = np.array(["gender", "floats", "age"])
     cFeatures = np.array([[1, 1.2, 1], [0, 0.3, np.nan], [0, -0.4, 0],
                           [np.nan, 0, 1]])
     cPhenotypes = np.array([0, 1, 0, 2])
     self.assertEqual("country", classLabel)
     self.assertTrue(np.array_equal(cHeaders, dataHeaders))
     self.assertTrue(np.allclose(cFeatures, dataFeatures, equal_nan=True))
     self.assertTrue(
         np.allclose(cPhenotypes, dataPhenotypes, equal_nan=True))