本文整理匯總了Python中operator.__div__方法的典型用法代碼示例。如果您正苦於以下問題:Python operator.__div__方法的具體用法?Python operator.__div__怎麽用?Python operator.__div__使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類operator
的用法示例。
在下文中一共展示了operator.__div__方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: testMath
# 需要導入模塊: import operator [as 別名]
# 或者: from operator import __div__ [as 別名]
def testMath(self):
self.failUnlessEqual(str(-scalar(name="s")), "unnamed_scalar{=-1.0} * s")
self.failUnlessEqual(str(scalar(name="s") + scalar(name="t")), "s + t")
self.failUnlessEqual(str(scalar(name="s") + 1), "s + unnamed_scalar{=1.0}")
self.failUnlessEqual(str(1 + scalar(name="s")), "s + unnamed_scalar{=1.0}")
self.failUnlessEqual(str(scalar(name="s") - scalar(name="t")), "unnamed_scalar{=-1.0} * t + s")
self.failUnlessEqual(str(1 - scalar(name="s")), "unnamed_scalar{=-1.0} * s + unnamed_scalar{=1.0}")
self.failUnlessEqual(str(2 * scalar(name="s")), "s * unnamed_scalar{=2.0}")
self.failUnlessEqual(str(scalar(name="s") * 2), "s * unnamed_scalar{=2.0}")
self.failUnlessEqual(str(scalar(name="s") * scalar(name="t")), "s * t")
self.failUnlessEqual(str((scalar(name="s") + scalar(name="t")) * 2), "s * unnamed_scalar{=2.0} + t * unnamed_scalar{=2.0}")
self.failUnlessEqual(str(scalar(name="s") / 2.0), "unnamed_scalar{=0.5} * s")
self.failUnlessEqual(str(scalar(name="s") / 2), "unnamed_scalar{=0.0} * s") # integer logic!
self.failUnlessEqual(str((scalar(name="s") + scalar(name="t")) / 2.0), "unnamed_scalar{=0.5} * s + unnamed_scalar{=0.5} * t")
self.failUnlessRaises((RuntimeError, AttributeError, TypeError), operator.__div__, 2, scalar())
self.failUnlessRaises((RuntimeError, AttributeError, TypeError), operator.__div__, scalar(), scalar())
self.failUnlessRaises((RuntimeError, AttributeError, TypeError), operator.__div__, vector(1), scalar())
self.failUnlessRaises((RuntimeError, AttributeError, TypeError), operator.__div__, scalar() + scalar(), scalar())
self.failUnlessRaises((RuntimeError, AttributeError, TypeError), operator.__div__, vector(1) + vector(1), scalar())
示例2: triplet_to_fractional_rgb
# 需要導入模塊: import operator [as 別名]
# 或者: from operator import __div__ [as 別名]
def triplet_to_fractional_rgb(rgbtuple):
return map(operator.__div__, rgbtuple, _maxtuple)
示例3: __div__
# 需要導入模塊: import operator [as 別名]
# 或者: from operator import __div__ [as 別名]
def __div__(self, other):
return self._operation(other, operator.__div__)
示例4: __rdiv__
# 需要導入模塊: import operator [as 別名]
# 或者: from operator import __div__ [as 別名]
def __rdiv__(self, other):
return self._roperation(other, operator.__div__)
示例5: __div__
# 需要導入模塊: import operator [as 別名]
# 或者: from operator import __div__ [as 別名]
def __div__(self, other):
return Null()