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


Python numpy.bitwise_xor方法代码示例

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


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

示例1: gaussian_elimination_mod2

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import bitwise_xor [as 别名]
def gaussian_elimination_mod2(A):
    """
    Gaussian elimination mod2 of A.

    """

    A = _np.array(A, dtype='int')
    m, n = A.shape
    i, j = 0, 0

    while (i < m) and (j < n):
        k = A[i:m, j].argmax() + i
        A[_np.array([i, k]), :] = A[_np.array([k, i]), :]
        aijn = _np.array([A[i, j:]])
        col = _np.array([A[:, j]]).T
        col[i] = 0
        flip = _np.dot(col, aijn)
        A[:, j:] = _np.bitwise_xor(A[:, j:], flip)
        i += 1
        j += 1
    return A 
开发者ID:pyGSTio,项目名称:pyGSTi,代码行数:23,代码来源:matrixmod2.py

示例2: test_NotImplemented_not_returned

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import bitwise_xor [as 别名]
def test_NotImplemented_not_returned(self):
        # See gh-5964 and gh-2091. Some of these functions are not operator
        # related and were fixed for other reasons in the past.
        binary_funcs = [
            np.power, np.add, np.subtract, np.multiply, np.divide,
            np.true_divide, np.floor_divide, np.bitwise_and, np.bitwise_or,
            np.bitwise_xor, np.left_shift, np.right_shift, np.fmax,
            np.fmin, np.fmod, np.hypot, np.logaddexp, np.logaddexp2,
            np.logical_and, np.logical_or, np.logical_xor, np.maximum,
            np.minimum, np.mod,
            np.greater, np.greater_equal, np.less, np.less_equal,
            np.equal, np.not_equal]

        a = np.array('1')
        b = 1
        c = np.array([1., 2.])
        for f in binary_funcs:
            assert_raises(TypeError, f, a, b)
            assert_raises(TypeError, f, c, a) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:21,代码来源:test_ufunc.py

示例3: test_values

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import bitwise_xor [as 别名]
def test_values(self):
        for dt in self.bitwise_types:
            zeros = np.array([0], dtype=dt)
            ones = np.array([-1], dtype=dt)
            msg = "dt = '%s'" % dt.char

            assert_equal(np.bitwise_not(zeros), ones, err_msg=msg)
            assert_equal(np.bitwise_not(ones), zeros, err_msg=msg)

            assert_equal(np.bitwise_or(zeros, zeros), zeros, err_msg=msg)
            assert_equal(np.bitwise_or(zeros, ones), ones, err_msg=msg)
            assert_equal(np.bitwise_or(ones, zeros), ones, err_msg=msg)
            assert_equal(np.bitwise_or(ones, ones), ones, err_msg=msg)

            assert_equal(np.bitwise_xor(zeros, zeros), zeros, err_msg=msg)
            assert_equal(np.bitwise_xor(zeros, ones), ones, err_msg=msg)
            assert_equal(np.bitwise_xor(ones, zeros), ones, err_msg=msg)
            assert_equal(np.bitwise_xor(ones, ones), zeros, err_msg=msg)

            assert_equal(np.bitwise_and(zeros, zeros), zeros, err_msg=msg)
            assert_equal(np.bitwise_and(zeros, ones), zeros, err_msg=msg)
            assert_equal(np.bitwise_and(ones, zeros), zeros, err_msg=msg)
            assert_equal(np.bitwise_and(ones, ones), ones, err_msg=msg) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:25,代码来源:test_umath.py

示例4: test_NotImplemented_not_returned

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import bitwise_xor [as 别名]
def test_NotImplemented_not_returned(self):
        # See gh-5964 and gh-2091. Some of these functions are not operator
        # related and were fixed for other reasons in the past.
        binary_funcs = [
            np.power, np.add, np.subtract, np.multiply, np.divide,
            np.true_divide, np.floor_divide, np.bitwise_and, np.bitwise_or,
            np.bitwise_xor, np.left_shift, np.right_shift, np.fmax,
            np.fmin, np.fmod, np.hypot, np.logaddexp, np.logaddexp2,
            np.logical_and, np.logical_or, np.logical_xor, np.maximum,
            np.minimum, np.mod
            ]

        # These functions still return NotImplemented. Will be fixed in
        # future.
        # bad = [np.greater, np.greater_equal, np.less, np.less_equal, np.not_equal]

        a = np.array('1')
        b = 1
        for f in binary_funcs:
            assert_raises(TypeError, f, a, b) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:22,代码来源:test_ufunc.py

示例5: set_ufunc

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import bitwise_xor [as 别名]
def set_ufunc(self, scalar_op):
        # This is probably a speed up of the implementation
        if isinstance(scalar_op, theano.scalar.basic.Add):
            self.ufunc = numpy.add
        elif isinstance(scalar_op, theano.scalar.basic.Mul):
            self.ufunc = numpy.multiply
        elif isinstance(scalar_op, theano.scalar.basic.Maximum):
            self.ufunc = numpy.maximum
        elif isinstance(scalar_op, theano.scalar.basic.Minimum):
            self.ufunc = numpy.minimum
        elif isinstance(scalar_op, theano.scalar.basic.AND):
            self.ufunc = numpy.bitwise_and
        elif isinstance(scalar_op, theano.scalar.basic.OR):
            self.ufunc = numpy.bitwise_or
        elif isinstance(scalar_op, theano.scalar.basic.XOR):
            self.ufunc = numpy.bitwise_xor
        else:
            self.ufunc = numpy.frompyfunc(scalar_op.impl, 2, 1) 
开发者ID:muhanzhang,项目名称:D-VAE,代码行数:20,代码来源:elemwise.py

示例6: get_unique_wfs

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import bitwise_xor [as 别名]
def get_unique_wfs(n=10000, duration=32, defined_channels=frozenset(['A'])):
    if not hasattr(get_unique_wfs, 'cache'):
        get_unique_wfs.cache = {}

    key = (n, duration)

    if key not in get_unique_wfs.cache:
        h = hash(key)
        base = np.bitwise_xor(np.linspace(-h, h, num=duration + n, dtype=np.int64), h)
        base = base / np.max(np.abs(base))

        get_unique_wfs.cache[key] = [
            DummyWaveform(duration=duration, sample_output=base[idx:idx+duration],
                          defined_channels=defined_channels)
            for idx in range(n)
        ]
    return get_unique_wfs.cache[key] 
开发者ID:qutech,项目名称:qupulse,代码行数:19,代码来源:seqc_tests.py

示例7: _hash_rows

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import bitwise_xor [as 别名]
def _hash_rows(array, mult=1000003, dtype=np.uint64):
    # Code based on python's tupleobject hasing
    # Generate hash
    mult = dtype(mult)
    sorted = np.sort(array, axis=1).astype(dtype)
    hash_array = 0x345678 * np.ones(array.shape[0], dtype=dtype)
    for i in reversed(range(array.shape[1])):
        hash_array = np.bitwise_xor(hash_array, sorted[:, i]) * mult
        mult += dtype(82520 + i + i)
    hash_array += dtype(97531)
    hash_array[hash_array == -1] = -2
    return hash_array 
开发者ID:simnibs,项目名称:simnibs,代码行数:14,代码来源:mesh_io.py

示例8: _colsum

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import bitwise_xor [as 别名]
def _colsum(self, i, j):
        """ Col_i = Col_j * Col_i where '*' is group action"""
        n, s = self.n, self.s
        for p in self.ps:
            p[i] = (p[i] + p[j] + 2 * float(_np.dot(s[:, i].T, _np.dot(self.u, s[:, j])))) % 4
        for k in range(n):
            s[k, i] = s[k, j] ^ s[k, i]
            s[k + n, i] = s[k + n, j] ^ s[k + n, i]
            #TODO: use _np.bitwise_xor or logical_xor here? -- keep it obvious (&slow) for now...
        return 
开发者ID:pyGSTio,项目名称:pyGSTi,代码行数:12,代码来源:stabilizer.py

示例9: test_truth_table_bitwise

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import bitwise_xor [as 别名]
def test_truth_table_bitwise(self):
        arg1 = [False, False, True, True]
        arg2 = [False, True, False, True]

        out = [False, True, True, True]
        assert_equal(np.bitwise_or(arg1, arg2), out)

        out = [False, False, False, True]
        assert_equal(np.bitwise_and(arg1, arg2), out)

        out = [False, True, True, False]
        assert_equal(np.bitwise_xor(arg1, arg2), out) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:14,代码来源:test_umath.py

示例10: test_types

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import bitwise_xor [as 别名]
def test_types(self):
        for dt in self.bitwise_types:
            zeros = np.array([0], dtype=dt)
            ones = np.array([-1], dtype=dt)
            msg = "dt = '%s'" % dt.char

            assert_(np.bitwise_not(zeros).dtype == dt, msg)
            assert_(np.bitwise_or(zeros, zeros).dtype == dt, msg)
            assert_(np.bitwise_xor(zeros, zeros).dtype == dt, msg)
            assert_(np.bitwise_and(zeros, zeros).dtype == dt, msg) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:12,代码来源:test_umath.py

示例11: test_identity

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import bitwise_xor [as 别名]
def test_identity(self):
        assert_(np.bitwise_or.identity == 0, 'bitwise_or')
        assert_(np.bitwise_xor.identity == 0, 'bitwise_xor')
        assert_(np.bitwise_and.identity == -1, 'bitwise_and') 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:6,代码来源:test_umath.py

示例12: hamming_distance

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import bitwise_xor [as 别名]
def hamming_distance(a, b):
  r = (1 << np.arange(8))[:,None]
  return np.count_nonzero((np.bitwise_xor(a,b) & r) != 0) 
开发者ID:geohot,项目名称:twitchslam,代码行数:5,代码来源:helpers.py


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