Пример #1
0
 def test_monomials_linear(self):
     L = MVPolyDict.monomials(2, 1)
     self.assertTrue(len(L) == 3,
                     "expected 3 monomials, got {0:d}".format(len(L)))
     E = [
         { ()        : 1 },
         { ((0, 1),) : 1 },
         { ((1, 1),) : 1 }
     ]
     for i in range(3):
         self.assertTrue(L[i].coef == E[i],
                         "{0!s} != {1!s}".format(repr(L[i].coef), repr(E[i])))
Пример #2
0
 def test_monomials_quadratic(self):
     L = MVPolyDict.monomials(2, 2)
     self.assertTrue(len(L) == 6,
                     "expected 6 monomials, got {0:d}".format(len(L)))
     E = [
         { ()               : 1 },
         { ((0, 1),)        : 1 },
         { ((1, 1),)        : 1 },
         { ((0, 2),)        : 1 },
         { ((0, 1), (1, 1)) : 1 },
         { ((1, 2),)        : 1 },
     ]
     for i in range(5):
         self.assertTrue(L[i].coef == E[i],
                         "{0!s} != {1!s}".format(repr(L[i].coef), repr(E[i])))
Пример #3
0
 def test_monomials_constant(self):
     L = MVPolyDict.monomials(2, 0)
     self.assertTrue(L[0].coef == { () : 1 },
                     "{0!s}".format(repr(L[0].coef)))