def test_get_rhs_substituted(self): # Signature: name(cls, expr_obj, namemap) # No Docstring # from nineml.abstraction_layer.component.util import MathUtil e = StrToExpr.alias("a := b*c + d/(e*sin(f+g/e)) + b1 + e_ / exp(12*g)") rhs_sub = MathUtil.get_rhs_substituted(e, {"b": "B", "e": "E"}) self.assertEqual(rhs_sub, "B*c + d/(E*sin(f+g/E)) + b1 + e_ / exp(12*g)")
def test_get_prefixed_rhs_string(self): # Signature: name(cls, expr_obj, prefix='', exclude=None) # No Docstring # from nineml.abstraction_layer.component.util import MathUtil e = StrToExpr.alias("a := b*c + d/(e*sin(f+g/e)) + b1 + e_ / exp(12*g)") rhs_sub = MathUtil.get_prefixed_rhs_string(e, prefix="U_", exclude=["c", "e_"]) self.assertEqual(rhs_sub, "U_b*c + U_d/(e*sin(U_f+U_g/e)) + U_b1 + e_ / exp(12*U_g)")
def test_alias(self): for expr_str, (exp_lhs, exp_rhs) in Aliases: alias = StrToExpr.alias(expr_str) self.assertEqual(alias.lhs, exp_lhs) self.assertEqual(alias.rhs, exp_rhs)