示例#1
0
 def test_partial_evaluation(self) -> None:
     e = ExpressionScalar('a * c')
     params = {'c': 5.5}
     evaluated = e.evaluate_symbolic(params)
     expected = ExpressionScalar('a * 5.5')
     self.assertEqual(expected.underlying_expression,
                      evaluated.underlying_expression)
示例#2
0
 def test_evaluate_symbolic(self):
     e = ExpressionScalar('a * b + c')
     params = {
         'a': 'd',
         'c': -7
     }
     result = e.evaluate_symbolic(params)
     expected = ExpressionScalar('d*b-7')
     self.assertEqual(result, expected)
示例#3
0
    def test_partial_evaluation_vectorized(self) -> None:
        e = ExpressionScalar('a[i] * c')

        params = {'c': np.array([[1, 2], [3, 4]])}

        evaluated = e.evaluate_symbolic(params)
        expected = ExpressionVector([['a[i] * 1', 'a[i] * 2'],
                                     ['a[i] * 3', 'a[i] * 4']])

        np.testing.assert_equal(evaluated.underlying_expression,
                                expected.underlying_expression)