当前位置: 首页>>代码示例>>Python>>正文


Python operator.__div__方法代码示例

本文整理汇总了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()) 
开发者ID:pyx-project,项目名称:pyx,代码行数:21,代码来源:test_solve.py

示例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) 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:4,代码来源:ColorDB.py

示例3: __div__

# 需要导入模块: import operator [as 别名]
# 或者: from operator import __div__ [as 别名]
def __div__(self, other):
        return self._operation(other, operator.__div__) 
开发者ID:mementum,项目名称:backtrader,代码行数:4,代码来源:lineroot.py

示例4: __rdiv__

# 需要导入模块: import operator [as 别名]
# 或者: from operator import __div__ [as 别名]
def __rdiv__(self, other):
        return self._roperation(other, operator.__div__) 
开发者ID:mementum,项目名称:backtrader,代码行数:4,代码来源:lineroot.py

示例5: __div__

# 需要导入模块: import operator [as 别名]
# 或者: from operator import __div__ [as 别名]
def __div__(self, other):
        return Null() 
开发者ID:ChrisBeaumont,项目名称:soupy,代码行数:4,代码来源:soupy.py


注:本文中的operator.__div__方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。