Exemple #1
0
    def test_intervals_with_predictions_not_3_columns_error(self):
        """Test an exeption is raised if intervals_with_predictions does not have 3 columns."""

        with pytest.raises(
                ValueError,
                match=re.escape(
                    "expecting intervals_with_predictions to have 3 columns"),
        ):

            helpers.gather_intervals(
                intervals_with_predictions=np.array([[1, 2], [1, 2]]))
Exemple #2
0
    def test_both_not_none(self, lower_interval, upper_interval,
                           intervals_with_predictions):
        """Test an exception is raised if both the inidividual intervals and combined arguments are not None."""

        with pytest.raises(
                ValueError,
                match=re.escape(
                    "either lower_interval and upper_interval or intervals_with_predictions must"
                    "be specified but both are specified"),
        ):

            helpers.gather_intervals(lower_interval, upper_interval,
                                     intervals_with_predictions)
Exemple #3
0
    def test_lower_upper_intervals_different_rows_error(self):
        """Test and exception is raised if lower and upper intervals do not have the same number of rows."""

        with pytest.raises(
                ValueError,
                match=re.escape(
                    "lower_interval_return and upper_interval_return have different shapes"
                ),
        ):

            helpers.gather_intervals(
                lower_interval=np.array([1, 2, 1, 2]),
                upper_interval=np.array([1, 2, 3]),
            )
Exemple #4
0
    def test_output_intervals_with_predictions_input(self):
        """Test the output if intervals_with_predictions passed."""

        arr = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])

        lower_out, upper_out = helpers.gather_intervals(
            intervals_with_predictions=arr)

        np.testing.assert_array_equal(lower_out, arr[:, 0])

        np.testing.assert_array_equal(upper_out, arr[:, 2])
Exemple #5
0
    def test_output_individual_intervals_input(self):
        """Test the inputs are returned if lower_interval and upper_interval are passed."""

        arr_lower = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9])
        arr_upper = np.array([5, 6, 7, 8, 9, 4, 3, 2, 1])

        lower_out, upper_out = helpers.gather_intervals(
            lower_interval=arr_lower, upper_interval=arr_upper)

        np.testing.assert_array_equal(lower_out, arr_lower)

        np.testing.assert_array_equal(upper_out, arr_upper)