Exemplo n.º 1
0
    def test_sample1d_invalid_range_minmax(self):

        # min range > max range
        with self.assertRaises(
                ValueError,
                msg=
                "A ValueError was not raised when the min range was larger than the max range."
        ):

            sample1d(fn1d, (10, 8, 100))
Exemplo n.º 2
0
    def test_sample1d_invalid_range_length(self):

        # tuple too short
        with self.assertRaises(
                ValueError,
                msg=
                "Passing a range tuple with too few values did not raise a ValueError."
        ):

            sample1d(fn1d, (1.0, 2.0))
Exemplo n.º 3
0
    def test_sample1d_invalid_range_type(self):

        # invalid type
        with self.assertRaises(
                TypeError,
                msg=
                "Type error was not raised when a string was (invalidly) supplied for the range."
        ):

            sample1d(fn1d, "blah")
Exemplo n.º 4
0
    def test_sample1d_invalid_function_called(self):

        # invalid function type
        with self.assertRaises(
                TypeError,
                msg=
                "Type error was not raised when a string was (invalidly) supplied for the function."
        ):

            sample1d("blah", (1, 2, 100))
Exemplo n.º 5
0
    def test_sample1d_invalid_range_samples(self):

        # number of samples < 1
        with self.assertRaises(
                ValueError,
                msg=
                "A ValueError was not raised when the number of samples was < 1."
        ):

            sample1d(fn1d, (10, 8, 0))
Exemplo n.º 6
0
    def test_sample1d_sample(self):

        rx = [1.0, 1.5, 2.0]
        rs = [1.0, 2.25, 4.0]

        tx, ts = sample1d(fn1d, (1.0, 2.0, 3))

        for i in range(3):

            self.assertEqual(tx[i], rx[i], "X points [{}] is incorrect.".format(i))
            self.assertEqual(ts[i], rs[i], "Sample point [{}] is incorrect.".format(i))