def test_poly_compare(self): poly = Poly({Mon(): 3, Mon({'n': 1}): 4}) # Assume poly > 0 to make various shape rules work with polymorphic shapes: assert poly >= 0 assert poly >= 1 assert poly > 0 assert 0 <= poly assert 0 < poly assert constant_poly(3) >= 1 assert constant_poly(3) > 1 self.assertRaisesRegex(ValueError, "", lambda: poly >= 2) self.assertRaisesRegex(ValueError, "", lambda: poly > 1)
def test_poly_equal(self): assert constant_poly(3) == 3 assert onp.array(3, onp.int64) == constant_poly(3) assert onp.array(3, onp.int64)[()] == constant_poly(3) assert not onp.array(3, onp.int64) != constant_poly(3) assert constant_poly(4) != 3 assert 3 == constant_poly(3) assert 4 != constant_poly(3) assert constant_poly(4) == constant_poly(4) assert constant_poly(3) != constant_poly(4) assert Poly({ Mon(): 3, Mon({'n': 1}): 4 }) == Poly({ Mon({'n': 1}): 4, Mon(): 3 }) assert Poly({ Mon(): 3, Mon({'n': 1}): 4 }) != Poly({ Mon(): 3, Mon({'n': 2}): 4 }) assert Poly({ Mon(): 3, Mon({'m': 1}): 4 }) != Poly({ Mon(): 3, Mon({'n': 1}): 4 })