示例#1
0
    def test_random_visualizer_increased_tolerance(self):
        """
        Test that not close visualizers pass with increased tolerance
        """
        viz = RandomVisualizer(random_state=224).fit()
        viz.finalize()

        self.assert_images_similar(viz, tol=30)
示例#2
0
    def test_random_visualizer_increased_tolerance(self):
        """
        Test that not close visualizers pass with increased tolerance
        """
        viz = RandomVisualizer(random_state=224).fit()
        viz.poof()

        self.assert_images_similar(viz, tol=30)
示例#3
0
    def test_random_visualizer(self):
        """
        Test that a random visualization is correctly compared to a baseline
        """
        viz = RandomVisualizer(random_state=111).fit()
        viz.poof()

        compare = self.assert_images_similar(viz, tol=1.0)
        assert_path_exists(compare.actual_image_path)
        assert_path_exists(compare.baseline_image_path)
示例#4
0
    def test_random_visualizer_not_close(self):
        """
        Test that not close visualizers raise an assertion error.
        """
        viz = RandomVisualizer(random_state=224).fit()
        viz.poof()

        with pytest.raises(ImageComparisonFailure, match="images not close"):
            self.assert_images_similar(viz)

        # Assert there is a diff
        assert_path_exists(
            ACTUAL_IMAGES, "test_meta", "test_random_visualizer_not_close-failed-diff.png"
        )
示例#5
0
    def test_draw_with_cols(self):
        """
        Draw 2 visualizers in their own column
        """
        visualizers = [
            RandomVisualizer(random_state=633),
            RandomVisualizer(random_state=336),
        ]

        X, y = make_classification(random_state=187)
        grid = VisualizerGrid(visualizers, ncols=2)

        grid.fit(X, y)
        grid.poof()

        self.assert_images_similar(grid)
示例#6
0
    def test_draw_with_cols(self):
        """
        Draw 2 visualizers in their own column
        """
        visualizers = [
            RandomVisualizer(random_state=633),
            RandomVisualizer(random_state=336),
        ]

        X, y = make_classification(random_state=187)
        grid = VisualizerGrid(visualizers, ncols=2)

        grid.fit(X, y)
        # show is required here (do not replace with finalize)!
        assert grid.show() is not None

        self.assert_images_similar(grid, tol=1.0)
    def test_draw_with_rows(self):
        """
        Draw 2 visualizers in their own row
        """
        visualizers = [
            RandomVisualizer(random_state=63),
            RandomVisualizer(random_state=36),
        ]

        X, y = make_classification(random_state=87)
        grid = VisualizerGrid(visualizers, nrows=2)

        grid.fit(X, y)
        # poof is required here (do not replace with finalize)!
        assert grid.poof() is not None

        self.assert_images_similar(grid)
示例#8
0
    def test_missing_baseline_image(self):
        """
        Test that a missing baseline image raises an exception
        """
        viz = RandomVisualizer(random_state=14).fit()
        viz.finalize()

        # Assert the baseline image does not exist
        assert_path_not_exists(BASELINE_IMAGES, "test_meta",
                               "test_missing_baseline_image.png")

        with pytest.raises(ImageComparisonFailure,
                           match="image does not exist"):
            self.assert_images_similar(viz)

        # Assert the actual image was created (to copy to baseline)
        assert_path_exists(ACTUAL_IMAGES, "test_meta",
                           "test_missing_baseline_image.png")
示例#9
0
    def test_random_visualizer_not_close(self):
        """
        Test that not close visualizers raise an assertion error.
        """
        # Baseline image random_state=224
        # NOTE: if regenerating baseline images, skip this one or change random state!
        viz = RandomVisualizer(random_state=225).fit()
        viz.finalize()

        with pytest.raises(ImageComparisonFailure, match="images not close"):
            # If failing, perhaps baseline images were regenerated? See note above.
            self.assert_images_similar(viz)

        # Assert there is a diff
        assert_path_exists(
            ACTUAL_IMAGES,
            "test_meta",
            "test_random_visualizer_not_close-failed-diff.png",
        )
示例#10
0
    def test_missing_baseline_image(self):
        """
        Test that a missing basline image raises an exception
        """
        viz = RandomVisualizer(random_state=14).fit()
        viz.poof()

        # Assert the baseline image does not exist
        assert_path_not_exists(
            BASELINE_IMAGES, "test_meta", "test_missing_baseline_image.png"
        )

        with pytest.raises(ImageComparisonFailure, match="image does not exist"):
            self.assert_images_similar(viz)

        # Assert the actual image was created (to copy to baseline)
        assert_path_exists(
            ACTUAL_IMAGES, "test_meta", "test_missing_baseline_image.png"
        )
示例#11
0
    def test_draw_visualizer_grid(self):
        """
        Draw a 4 visualizers grid with default options
        """
        visualizers = [
            RandomVisualizer(random_state=(1 + x)**2) for x in range(4)
        ]

        X, y = make_classification(random_state=78)
        grid = VisualizerGrid(visualizers)

        grid.fit(X, y)
        grid.poof()

        self.assert_images_similar(grid)
示例#12
0
    def test_draw_visualizer_grid(self):
        """
        Draw a 4 visualizers grid with default options
        """
        visualizers = [
            RandomVisualizer(random_state=(1 + x)**2) for x in range(4)
        ]

        X, y = make_classification(random_state=78)
        grid = VisualizerGrid(visualizers)

        grid.fit(X, y)
        # show is required here (do not replace with finalize)!
        assert grid.show() is not None

        self.assert_images_similar(grid, tol=1.0)