Example #1
0
    def test_get_rhs_substituted(self):
        # Signature: name(cls, expr_obj, namemap)
        # from nineml.abstraction.component.util import MathUtil

        e = Alias.from_str('a := b*c + b1 + e_*exp(-12*g) + '
                           'd/(e*sin(f + g/e))')

        rhs_sub = e.rhs_substituted({'b': 'B', 'e': 'E'})
        self.assertEqual(
            rhs_sub,
            sympy.sympify('B*c + b1 + e_*exp(-12*g) + d/(E*sin(f + g/E))',
                          locals={'E': sympy.Symbol('E')}))
Example #2
0
    def test_get_rhs_substituted(self):
        # Signature: name(cls, expr_obj, namemap)
        # from nineml.abstraction.component.util import MathUtil

        e = Alias.from_str('a := b*c + b1 + e_*exp(-12*g) + '
                           'd/(e*sin(f + g/e))')

        rhs_sub = e.rhs_substituted({'b': 'B', 'e': 'E'})
        self.assertEqual(
            rhs_sub,
            sympy.sympify('B*c + b1 + e_*exp(-12*g) + d/(E*sin(f + g/E))',
                          locals={'E': sympy.Symbol('E')}))
Example #3
0
    def test_get_prefixed_rhs_string(self):
        # Signature: name(cls, expr_obj, prefix='', exclude=None)
        # No Docstring
        # from nineml.abstraction.component.util import MathUtil

        e = Alias.from_str('a := b*c + d/(e_*sin(f+g/e_)) + b1 + '
                           'e_ / exp(12*g)')

        rhs_sub = e.rhs_suffixed(suffix='', prefix='U_', excludes=['c', 'e_'])
        self.assertEqual(
            rhs_sub,
            sympy.sympify('U_b*c + U_d/(e_*sin(U_f+U_g/e_)) + U_b1 +'
                          ' e_ / exp(12*U_g)'))
Example #4
0
    def test_get_prefixed_rhs_string(self):
        # Signature: name(cls, expr_obj, prefix='', exclude=None)
                # No Docstring
        # from nineml.abstraction.component.util import MathUtil

        e = Alias.from_str('a := b*c + d/(e_*sin(f+g/e_)) + b1 + '
                           'e_ / exp(12*g)')

        rhs_sub = e.rhs_suffixed(suffix='', prefix='U_', excludes=['c', 'e_'])
        self.assertEqual(
            rhs_sub,
            sympy.sympify('U_b*c + U_d/(e_*sin(U_f+U_g/e_)) + U_b1 +'
                          ' e_ / exp(12*U_g)')
        )
Example #5
0
    def test_alias(self):
        for expr_str, (exp_lhs, exp_rhs) in Aliases:
            alias = Alias.from_str(expr_str)

            self.assertEqual(alias.lhs, exp_lhs)
            self.assertEqual(str(alias.rhs), exp_rhs)
Example #6
0
    def test_alias(self):
        for expr_str, (exp_lhs, exp_rhs) in Aliases:
            alias = Alias.from_str(expr_str)

            self.assertEqual(alias.lhs, exp_lhs)
            self.assertEqual(str(alias.rhs), exp_rhs)