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


Python operator.lshift方法代码示例

本文整理汇总了Python中operator.lshift方法的典型用法代码示例。如果您正苦于以下问题:Python operator.lshift方法的具体用法?Python operator.lshift怎么用?Python operator.lshift使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在operator的用法示例。


在下文中一共展示了operator.lshift方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: set_bit_order

# 需要导入模块: import operator [as 别名]
# 或者: from operator import lshift [as 别名]
def set_bit_order(self, order):
        """Set order of bits to be read/written over serial lines.  Should be
        either MSBFIRST for most-significant first, or LSBFIRST for
        least-signifcant first.
        """
        # Set self._mask to the bitmask which points at the appropriate bit to
        # read or write, and appropriate left/right shift operator function for
        # reading/writing.
        if order == MSBFIRST:
            self._mask = 0x80
            self._write_shift = operator.lshift
            self._read_shift = operator.rshift
        elif order == LSBFIRST:
            self._mask = 0x01
            self._write_shift = operator.rshift
            self._read_shift = operator.lshift
        else:
            raise ValueError('Order must be MSBFIRST or LSBFIRST.') 
开发者ID:adafruit,项目名称:Adafruit_Python_GPIO,代码行数:20,代码来源:SPI.py

示例2: test_operatorerrors

# 需要导入模块: import operator [as 别名]
# 或者: from operator import lshift [as 别名]
def test_operatorerrors(self):
        f2 = self.f2
        f2p = self.f2p
        f256 = self.f256
        f19 = self.f19
        self.assertRaises(TypeError, operator.add, f2(1), f2p(2))
        self.assertRaises(TypeError, operator.iadd, f2(1), f2p(2))
        self.assertRaises(TypeError, operator.sub, f2(1), f256(2))
        self.assertRaises(TypeError, operator.isub, f2(1), f256(2))
        self.assertRaises(TypeError, operator.mul, f2(1), f19(2))
        self.assertRaises(TypeError, operator.imul, f2(1), f19(2))
        self.assertRaises(TypeError, operator.truediv, f256(1), f19(2))
        self.assertRaises(TypeError, operator.itruediv, f256(1), f19(2))
        self.assertRaises(TypeError, operator.truediv, 3.14, f19(2))
        self.assertRaises(TypeError, operator.lshift, f2(1), f2(1))
        self.assertRaises(TypeError, operator.ilshift, f2(1), f2(1))
        self.assertRaises(TypeError, operator.lshift, 1, f2(1))
        self.assertRaises(TypeError, operator.rshift, f19(1), f19(1))
        self.assertRaises(TypeError, operator.irshift, f19(1), f19(1))
        self.assertRaises(TypeError, operator.irshift, f256(1), f256(1))
        self.assertRaises(TypeError, operator.pow, f2(1), f19(2))
        self.assertRaises(TypeError, operator.pow, f19(1), 3.14) 
开发者ID:lschoe,项目名称:mpyc,代码行数:24,代码来源:test_finfields.py

示例3: test_operatorerrors

# 需要导入模块: import operator [as 别名]
# 或者: from operator import lshift [as 别名]
def test_operatorerrors(self):
        secfld = sectypes.SecFld()
        secint = sectypes.SecInt()
        a = secfld(0)
        b = secint(1)
        self.assertRaises(TypeError, operator.add, a, b)
        self.assertRaises(TypeError, operator.add, a, 3.14)
        self.assertRaises(TypeError, operator.sub, a, b)
        self.assertRaises(TypeError, operator.mul, a, b)
        self.assertRaises(TypeError, operator.mul, 3.14, b)
        self.assertRaises(TypeError, operator.truediv, a, b)
        self.assertRaises(TypeError, operator.truediv, a, b)
        self.assertRaises(TypeError, operator.mod, a, b)
        self.assertRaises(TypeError, operator.mod, b, a)
        self.assertRaises(TypeError, operator.floordiv, a, b)
        self.assertRaises(TypeError, divmod, a, b)
        self.assertRaises(TypeError, divmod, b, a)
        self.assertRaises(TypeError, operator.pow, b, 3.14)
        self.assertRaises(TypeError, operator.lshift, b, 3.14)
        self.assertRaises(TypeError, operator.lshift, 3.14, b)
        self.assertRaises(TypeError, operator.rshift, b, 3.14)
        self.assertRaises(TypeError, operator.rshift, 3.14, b) 
开发者ID:lschoe,项目名称:mpyc,代码行数:24,代码来源:test_sectypes.py

示例4: testLShift

# 需要导入模块: import operator [as 别名]
# 或者: from operator import lshift [as 别名]
def testLShift(self):
        self.binaryCheck(operator.lshift, jmax=256) 
开发者ID:myhdl,项目名称:myhdl,代码行数:4,代码来源:test_Signal.py

示例5: __lshift__

# 需要导入模块: import operator [as 别名]
# 或者: from operator import lshift [as 别名]
def __lshift__(self, y):
    return NonStandardInteger(operator.lshift(self.val, y)) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:4,代码来源:test_util.py

示例6: __rlshift__

# 需要导入模块: import operator [as 别名]
# 或者: from operator import lshift [as 别名]
def __rlshift__(self, y):
    return NonStandardInteger(operator.lshift(y, self.val)) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:4,代码来源:test_util.py

示例7: test_lshift

# 需要导入模块: import operator [as 别名]
# 或者: from operator import lshift [as 别名]
def test_lshift(self):
        self.assertRaises(TypeError, operator.lshift)
        self.assertRaises(TypeError, operator.lshift, None, 42)
        self.assertTrue(operator.lshift(5, 1) == 10)
        self.assertTrue(operator.lshift(5, 0) == 5)
        self.assertRaises(ValueError, operator.lshift, 2, -1) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:8,代码来源:test_operator.py

示例8: _op_generic_ShlN

# 需要导入模块: import operator [as 别名]
# 或者: from operator import lshift [as 别名]
def _op_generic_ShlN(self, args):
        return self.generic_shift_thing(args, operator.lshift) 
开发者ID:angr,项目名称:angr,代码行数:4,代码来源:irop.py

示例9: __lshift__

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

示例10: __lshift__

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

示例11: __rlshift__

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

示例12: __lshift__

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

示例13: __rlshift__

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

示例14: test_lshift_scalar

# 需要导入模块: import operator [as 别名]
# 或者: from operator import lshift [as 别名]
def test_lshift_scalar(self):
        self.check_array_scalar_op(operator.lshift) 
开发者ID:cupy,项目名称:cupy,代码行数:4,代码来源:test_ndarray_elementwise_op.py

示例15: test_rlshift_scalar

# 需要导入模块: import operator [as 别名]
# 或者: from operator import lshift [as 别名]
def test_rlshift_scalar(self):
        self.check_array_scalar_op(operator.lshift, swap=True) 
开发者ID:cupy,项目名称:cupy,代码行数:4,代码来源:test_ndarray_elementwise_op.py


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