本文整理汇总了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()