Exemplo n.º 1
0
    def test_sympification(self):
        symbolic = Broadcast(a, (3, ))
        as_str = str(symbolic)

        re_sympified = qc_sympify(as_str)
        self.assertEqual(re_sympified, symbolic)

        sympification = qc_sympify('Broadcast(a, (3,))')
        self.assertEqual(sympification, symbolic)
Exemplo n.º 2
0
    def test_get_most_simple_representation(self):
        cpl = get_most_simple_representation(qc_sympify('1 + 1j'))
        self.assertIsInstance(cpl, str)
        self.assertTrue(bool(sympy.Eq(sympy.sympify(cpl), 1 + 1j)))

        integer = get_most_simple_representation(qc_sympify('3'))
        self.assertIsInstance(integer, int)
        self.assertEqual(integer, 3)

        flt = get_most_simple_representation(qc_sympify('3.1'))
        self.assertIsInstance(flt, float)
        self.assertEqual(flt, 3.1)

        st = get_most_simple_representation(qc_sympify('a + b'))
        self.assertIsInstance(st, str)
        self.assertEqual(st, 'a + b')
Exemplo n.º 3
0
 def sympify(self, expression):
     return qc_sympify(expression)