Esempio n. 1
0
    def test_math(self):
        from libcellml import Component

        # appendMath(const std::string &math)
        x = Component()
        x.appendMath('More maths')
        x.appendMath(' please!')

        # std::string math()
        self.assertEqual(x.math(), 'More maths please!')
        x = Component()
        self.assertEqual(x.math(), '')

        # void setMath(const std::string &math)
        x.setMath('bonjour')
        self.assertEqual(x.math(), 'bonjour')
        x.setMath('hola')
        self.assertEqual(x.math(), 'hola')
        x.removeMath()
        self.assertEqual(x.math(), '')
Esempio n. 2
0
    a.setUnits(per_month)
    b.setUnits(b_units)
    c.setUnits(per_month)
    d.setUnits(d_units)

    #  3.f
    #      Call the validator again to check the model.
    #      Expect one error regarding a missing unit in the MathML.
    validator.validateModel(model)
    print_issues(validator)

    #  3.g
    #      Units for constants inside the MathML must be specified at the time.
    #      This means we need to adjust equation1 to include the per_month units.
    #      We have to wipe all the existing MathML and replace it.
    component.removeMath()
    component.setMath(math_header)
    equation1 = \
        "  <apply><eq/>"\
        "    <ci>c</ci>"\
        "    <apply><plus/>"\
        "      <ci>a</ci>"\
        "      <cn cellml:units=\"per_month\">2.0</cn>"\
        "    </apply>"\
        "  </apply>"
    component.appendMath(equation1)
    component.appendMath(equation2)
    component.appendMath(equation3)
    component.appendMath(math_footer)

    #  3.h