Example #1
0
    def test_perform_clustering(self):
        test_dir_name = os.path.dirname(__file__)
        feat_array_fn = os.path.join(test_dir_name, "data",
                                     "feature_array.csv")

        tmp_dir = self.__class__.TMP_DIR
        output_fn = os.path.join(tmp_dir, "code.txt")

        clusterer = Clusterer(feat_array_fn, output_fn, [])
        clusterer.iter = 100
        clusterer.perform_clustering()

        sample_output_filename = os.path.join(test_dir_name, "data",
                                              "sample_cluster_code.txt")
        sample_inv_output_filename = os.path.join(
            test_dir_name, "data", "sample_cluster_code_inv.txt")

        same_as_sample = filecmp.cmp(output_fn, sample_output_filename)
        same_as_inv = filecmp.cmp(output_fn, sample_inv_output_filename)
        self.assertTrue(same_as_sample or same_as_inv)

        # Now test the data set with non feat cols
        feat_array_fn = os.path.join(test_dir_name, "data",
                                     "feature_array_with_non_feat_cols.csv")
        clusterer = Clusterer(feat_array_fn, output_fn, ["id", "param"])
        clusterer.iter = 100
        clusterer.perform_clustering()

        same_as_sample = filecmp.cmp(output_fn, sample_output_filename)
        same_as_inv = filecmp.cmp(output_fn, sample_inv_output_filename)
        self.assertTrue(same_as_sample or same_as_inv)
Example #2
0
    def test_perform_clustering(self):
        test_dir_name = os.path.dirname(__file__)
        feat_array_fn = os.path.join(
            test_dir_name, "data", "feature_array.csv")

        tmp_dir = self.__class__.TMP_DIR
        output_fn = os.path.join(tmp_dir, "code.txt")

        clusterer = Clusterer(feat_array_fn, output_fn, [])
        clusterer.iter = 100
        clusterer.perform_clustering()

        sample_output_filename = os.path.join(
            test_dir_name, "data", "sample_cluster_code.txt")
        sample_inv_output_filename = os.path.join(
            test_dir_name, "data", "sample_cluster_code_inv.txt")

        same_as_sample = filecmp.cmp(output_fn, sample_output_filename)
        same_as_inv = filecmp.cmp(output_fn, sample_inv_output_filename)
        self.assertTrue(same_as_sample or same_as_inv)

        # Now test the data set with non feat cols
        feat_array_fn = os.path.join(
            test_dir_name, "data", "feature_array_with_non_feat_cols.csv")
        clusterer = Clusterer(feat_array_fn, output_fn, ["id", "param"])
        clusterer.iter = 100
        clusterer.perform_clustering()

        same_as_sample = filecmp.cmp(output_fn, sample_output_filename)
        same_as_inv = filecmp.cmp(output_fn, sample_inv_output_filename)
        self.assertTrue(same_as_sample or same_as_inv)