示例#1
0
    def test_generate_xmap(self):
        """The AREA tag is generated correctly"""
        data = self.list_data_single_plot[0]

        plot_output_dir = path.join(self.tmp_dir, "plot_dir")
        png_img_fp = path.join(plot_output_dir, data[LD_NAME] + '.png')
        eps_gz_fp = path.join(plot_output_dir, data[LD_NAME] + '.eps.gz')

        self._paths_to_clean_up = [png_img_fp, eps_gz_fp]
        self._dirs_to_clean_up = [plot_output_dir]

        mkdir(plot_output_dir)

        width, height, plot = plot_heatmap(data[LD_NAME], data[LD_HEADERS],
                                           data[LD_MATRIX],
                                           data[LD_TRANSFORM_VALUES],
                                           plot_output_dir)

        xmap, img_height, img_width = generate_xmap(width, height,
                                                    data[LD_HEADERS],
                                                    data[LD_MATRIX], plot,
                                                    self.mapping_data)

        self.assertEqual(img_height, 800)
        self.assertEqual(img_width, 800)
        self.assertEqual(xmap, result_xmap)
示例#2
0
    def test_get_coords(self):
        """The XY coords for the AREA tag are retrieved correctly"""
        data = self.list_data_single_plot[0]

        plot_output_dir = path.join(self.tmp_dir, "plot_dir")
        png_img_fp = path.join(plot_output_dir, data[LD_NAME] + '.png')
        eps_gz_fp = path.join(plot_output_dir, data[LD_NAME] + '.eps.gz')

        self._paths_to_clean_up = [png_img_fp, eps_gz_fp]
        self._dirs_to_clean_up = [plot_output_dir]

        mkdir(plot_output_dir)

        width, height, plot = plot_heatmap(data[LD_NAME], data[LD_HEADERS],
                                           data[LD_MATRIX],
                                           data[LD_TRANSFORM_VALUES],
                                           plot_output_dir)

        all_cids, all_xcoords, all_ycoords = get_coords(
            data[LD_HEADERS], data[LD_MATRIX], plot, self.mapping_data)

        result_all_xcoords = [354.0, 466.0, 578.0, 466.0, 578.0, 578.0]
        result_all_ycoords = [664.0, 664.0, 664.0, 552.0, 552.0, 440.0]

        self.assertEqual(all_cids, result_all_cids)
        self.assertEqual(all_xcoords, result_all_xcoords)
        self.assertEqual(all_ycoords, result_all_ycoords)
    def test_get_coords(self):
        """The XY coords for the AREA tag are retrieved correctly"""
        data = self.list_data_single_plot[0]

        plot_output_dir = path.join(self.tmp_dir, "plot_dir")
        png_img_fp = path.join(plot_output_dir, data[LD_NAME] + '.png')
        eps_gz_fp = path.join(plot_output_dir, data[LD_NAME] + '.eps.gz')

        self._paths_to_clean_up = [png_img_fp, eps_gz_fp]
        self._dirs_to_clean_up = [plot_output_dir]

        mkdir(plot_output_dir)

        width, height, plot = plot_heatmap(data[LD_NAME], data[LD_HEADERS],
            data[LD_MATRIX], data[LD_TRANSFORM_VALUES], plot_output_dir)

        all_cids, all_xcoords, all_ycoords = get_coords(data[LD_HEADERS],
            data[LD_MATRIX], plot, self.mapping_data)

        result_all_xcoords = [354.0, 466.0, 578.0, 466.0, 578.0, 578.0]
        result_all_ycoords = [664.0, 664.0, 664.0, 552.0, 552.0, 440.0]

        self.assertEqual(all_cids, result_all_cids)
        self.assertEqual(all_xcoords, result_all_xcoords)
        self.assertEqual(all_ycoords, result_all_ycoords)
示例#4
0
    def test_plot_heatmap(self):
        """The heatmap images are generated correctly"""
        png_img_fp = path.join(self.output_dir, self.plot_name + '.png')
        eps_gz_fp = path.join(self.output_dir, self.plot_name + '.eps.gz')

        self._paths_to_clean_up = [png_img_fp, eps_gz_fp]
        self._dirs_to_clean_up = [self.output_dir]

        mkdir(self.output_dir)

        width, height, plot = plot_heatmap(self.plot_name, self.headers,
            self.matrix, self.trans_values, self.output_dir)

        self.assertEqual(width, 10)
        self.assertEqual(height, 10)
        self.assertTrue(path.exists(png_img_fp),
            'The png file was not created in the appropiate location')
        self.assertTrue(path.exists(eps_gz_fp),
            'The eps file was not created in the appropiate location')


        png_img_fp_ns = path.join(self.output_dir_ns,
            self.plot_name_ns + '.png')
        eps_gz_fp_ns = path.join(self.output_dir_ns,
            self.plot_name_ns + '.eps.gz')

        self._paths_to_clean_up.append(png_img_fp_ns)
        self._paths_to_clean_up.append(eps_gz_fp_ns)
        self._dirs_to_clean_up.append(self.output_dir_ns)

        mkdir(self.output_dir_ns)

        width, height, plot = plot_heatmap(self.plot_name_ns, self.headers_ns,
            self.matrix_ns, self.trans_values, self.output_dir_ns)

        self.assertEqual(width, 10)
        self.assertEqual(height, 10)
        self.assertTrue(path.exists(png_img_fp_ns),
            'The png file was not created in the appropiate location')
        self.assertTrue(path.exists(eps_gz_fp_ns),
            'The eps file was not created in the appropiate location')
    def test_generate_xmap(self):
        """The AREA tag is generated correctly"""
        data = self.list_data_single_plot[0]

        plot_output_dir = path.join(self.tmp_dir, "plot_dir")
        png_img_fp = path.join(plot_output_dir, data[LD_NAME] + '.png')
        eps_gz_fp = path.join(plot_output_dir, data[LD_NAME] + '.eps.gz')

        self._paths_to_clean_up = [png_img_fp, eps_gz_fp]
        self._dirs_to_clean_up = [plot_output_dir]

        mkdir(plot_output_dir)

        width, height, plot = plot_heatmap(data[LD_NAME], data[LD_HEADERS],
            data[LD_MATRIX], data[LD_TRANSFORM_VALUES], plot_output_dir)

        xmap, img_height, img_width = generate_xmap(width, height,
            data[LD_HEADERS], data[LD_MATRIX], plot, self.mapping_data)

        self.assertEqual(img_height, 800)
        self.assertEqual(img_width, 800)
        self.assertEqual(xmap, result_xmap)