def test_fit_transform_show_and_draw_calls(self):
        """
        Test calling fit, transform, and show on the pipeline
        """

        pipeline = VisualPipeline([
            ("a", mock.MagicMock(MockTransformer())),
            ("b", mock.MagicMock(MockVisualTransformer())),
            ("c", mock.MagicMock(MockTransformer())),
            ("d", mock.MagicMock(MockVisualTransformer())),
            ("e", mock.MagicMock(MockEstimator())),
        ])

        X = [[1, 1, 1, 1, 1], [2, 2, 2, 2, 2], [3, 3, 3, 3, 3]]

        y = [1, 2, 3, 4, 5]

        pipeline.fit(X, y)
        for name, step in pipeline.named_steps.items():
            step.fit.assert_called_once_with(X, y)

        pipeline.transform(X)
        for name, step in pipeline.named_steps.items():
            if name == "e":
                continue
            step.transform.assert_called_once_with(X)

        pipeline.show()
        for name, step in pipeline.named_steps.items():
            if name in {"a", "c", "e"}:
                continue
            step.show.assert_called_once_with(outpath=None)
    def test_pipeline_show(self):
        """
        Test the show call against the VisualPipeline
        """

        pipeline = VisualPipeline([
            ("a", mock.MagicMock(MockTransformer())),
            ("b", mock.MagicMock(MockVisualTransformer())),
            ("c", mock.MagicMock(MockTransformer())),
            ("d", mock.MagicMock(MockVisualTransformer())),
            ("e", mock.MagicMock(MockEstimator())),
        ])

        pipeline.show()
        pipeline.steps[1][1].show.assert_called_once_with(outpath=None)
        pipeline.steps[3][1].show.assert_called_once_with(outpath=None)
    def test_pipeline_savefig_show(self):
        """
        Test the show call with an outdir to save all the figures
        """
        pipeline = VisualPipeline([
            ("a", mock.MagicMock(MockTransformer())),
            ("b", mock.MagicMock(MockVisualTransformer())),
            ("c", mock.MagicMock(MockTransformer())),
            ("d", mock.MagicMock(MockVisualTransformer())),
            ("e", mock.MagicMock(MockVisualEstimator())),
        ])

        # Must use path joining for Windows compatibility
        tmpdir = os.path.join("tmp", "figures")

        pipeline.show(outdir=tmpdir)
        pipeline.steps[1][1].show.assert_called_once_with(
            outpath=os.path.join(tmpdir, "b.pdf"))
        pipeline.steps[3][1].show.assert_called_once_with(
            outpath=os.path.join(tmpdir, "d.pdf"))
        pipeline.steps[4][1].show.assert_called_once_with(
            outpath=os.path.join(tmpdir, "e.pdf"))