def __init__(self, t: str, q_list: List[str], v_list: List[str], order_of_integrator: int = 2,
                 verbose: bool = False) -> None:
        """
        We subclass from a base integrator class.
        This way we can abstract away common functionality between integrators.
        """

        Integrator.__init__(self, t, q_list, v_list, verbose, 'Polynomial Integrator')
        Assertions.assert_integer(order_of_integrator, "Order of integrator")
        self.order_of_integrator = order_of_integrator
Beispiel #2
0
    def discretise(self, expression, n: int, t_lim_lower: float, t_lim_upper: float) -> None:
        """
        Discretise the function that we provide on an interval [t_lim_lower, t_lim_upper].

        :param expression: Sympy expression for the function we want to discretise.
        :param n: The number of points to determine the system at.
        :param t_lim_lower: Lower time limit to sample our continuous function over.
        :param t_lim_upper: Upper time limit to sample our continuous function over.
        """

        Assertions.assert_integer(n, 'number of points to determine system at')

        self.set_time_boundaries(t_lim_lower, t_lim_upper)
        self.n = n

        self.t_list = np.linspace(t_lim_lower, t_lim_upper, n)
        self.set_expression(expression)
Beispiel #3
0
    def test_assert_integer(self):
        # Integers should pass
        Assertions.assert_integer(1, 'an integer')

        # Strings should not pass
        with self.assertRaises(AssertionError):
            Assertions.assert_integer('yeet', 'a string')

        # Lists should not pass
        with self.assertRaises(AssertionError):
            Assertions.assert_integer([], 'a list')