def test_data_type_exception(self, np_2x1_with_label,
                                 xgb_regressor_1_split_1_tree):
        """Test an exception is raised if data is not a xgb.DMatrix object."""

        confo_model = XGBSklearnLeafNodeScaledConformalPredictor(
            xgb_regressor_1_split_1_tree)

        confo_model.calibrate(data=np_2x1_with_label[0],
                              response=np_2x1_with_label[1])

        with pytest.raises(
                TypeError,
                match=re.escape(
                    f"data is not in expected types {[np.ndarray, pd.DataFrame]}, got {list}"
                ),
        ):

            confo_model.predict_with_interval([])
    def test_no_leaf_node_counts_attribute_exception(
            self, np_2x1_with_label, xgb_regressor_1_split_1_tree):
        """Test an exception is raised if leaf_node_counts attribute is not present."""

        confo_model = XGBSklearnLeafNodeScaledConformalPredictor(
            xgb_regressor_1_split_1_tree)

        assert not hasattr(
            confo_model, "leaf_node_counts"
        ), "XGBSklearnLeafNodeScaledConformalPredictor has leaf_node_counts attribute prior to running calibrate"

        with pytest.raises(
                AttributeError,
                match=
                "XGBSklearnLeafNodeScaledConformalPredictor does not have leaf_node_counts"
                " attribute, run calibrate first.",
        ):

            confo_model.predict_with_interval(np_2x1_with_label[0])
    def test_super_predict_with_interval_call(self, mocker, np_2x1_with_label,
                                              xgb_regressor_1_split_1_tree):
        """Test that LeafNodeScaledConformalPredictor.predict_with_interval is called and the
        outputs of this are returned from the method.
        """

        confo_model = XGBSklearnLeafNodeScaledConformalPredictor(
            xgb_regressor_1_split_1_tree)

        confo_model.calibrate(data=np_2x1_with_label[0],
                              response=np_2x1_with_label[1])

        predict_return_value = np.array([200, 101, 1234])

        mocked = mocker.patch.object(
            pitci.base.LeafNodeScaledConformalPredictor,
            "predict_with_interval",
            return_value=predict_return_value,
        )

        results = confo_model.predict_with_interval(np_2x1_with_label[0])

        # test output of predict_with_interval is the return value of
        # LeafNodeScaledConformalPredictor.predict_with_interval
        np.testing.assert_array_equal(results, predict_return_value)

        assert (mocked.call_count == 1
                ), "incorrect number of calls to super().predict_with_interval"

        call_args = mocked.call_args_list[0]
        call_pos_args = call_args[0]
        call_kwargs = call_args[1]

        assert (
            call_pos_args == ()
        ), "positional args incorrect in call to LeafNodeScaledConformalPredictor.predict_with_interval"

        assert list(call_kwargs.keys()) == [
            "data"
        ], "incorrect keyword args in LeafNodeScaledConformalPredictor.predict_with_interval call"

        np.testing.assert_array_equal(call_kwargs["data"],
                                      np_2x1_with_label[0])