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


Python numpy.longlong方法代码示例

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


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

示例1: _unsigned_subtract

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import longlong [as 别名]
def _unsigned_subtract(a, b):
    """
    Subtract two values where a >= b, and produce an unsigned result

    This is needed when finding the difference between the upper and lower
    bound of an int16 histogram
    """
    # coerce to a single type
    signed_to_unsigned = {
        np.byte: np.ubyte,
        np.short: np.ushort,
        np.intc: np.uintc,
        np.int_: np.uint,
        np.longlong: np.ulonglong
    }
    dt = np.result_type(a, b)
    try:
        dt = signed_to_unsigned[dt.type]
    except KeyError:
        return np.subtract(a, b, dtype=dt)
    else:
        # we know the inputs are integers, and we are deliberately casting
        # signed to unsigned
        return np.subtract(a, b, casting='unsafe', dtype=dt) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:26,代码来源:histograms.py

示例2: _unsigned_subtract

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import longlong [as 别名]
def _unsigned_subtract(a, b):
    """
    Subtract two values where a >= b, and produce an unsigned result

    This is needed when finding the difference between the upper and lower
    bound of an int16 histogram
    """
    # coerce to a single type
    signed_to_unsigned = {
        np.byte: np.ubyte,
        np.short: np.ushort,
        np.intc: np.uintc,
        np.int_: np.uint,
        np.longlong: np.ulonglong
    }
    dt = np.result_type(a, b)
    try:
        dt = signed_to_unsigned[dt.type]
    except KeyError:  # pragma: no cover
        return np.subtract(a, b, dtype=dt)
    else:
        # we know the inputs are integers, and we are deliberately casting
        # signed to unsigned
        return np.subtract(a, b, casting='unsafe', dtype=dt) 
开发者ID:mars-project,项目名称:mars,代码行数:26,代码来源:histogram.py

示例3: _open_and_load

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import longlong [as 别名]
def _open_and_load(f, dtype, multilabel, zero_based, query_id,
                   offset=0, length=-1):
    if hasattr(f, "read"):
        actual_dtype, data, ind, indptr, labels, query = \
            _load_svmlight_file(f, dtype, multilabel, zero_based, query_id,
                                offset, length)
    else:
        with closing(_gen_open(f)) as f:
            actual_dtype, data, ind, indptr, labels, query = \
                _load_svmlight_file(f, dtype, multilabel, zero_based, query_id,
                                    offset, length)

    # convert from array.array, give data the right dtype
    if not multilabel:
        labels = np.frombuffer(labels, np.float64)
    data = np.frombuffer(data, actual_dtype)
    indices = np.frombuffer(ind, np.longlong)
    indptr = np.frombuffer(indptr, dtype=np.longlong)   # never empty
    query = np.frombuffer(query, np.int64)

    data = np.asarray(data, dtype=dtype)    # no-op for float{32,64}
    return data, indices, indptr, labels, query 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:24,代码来源:svmlight_format.py

示例4: concatenateNeighborLists

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import longlong [as 别名]
def concatenateNeighborLists(meshPaths):
    neighbor = []
    for path in meshPaths:
        mesh = om.MFnMesh(path)
        _, indices = mesh.getTriangles()
        offset = len(neighbor)
        neighbor = neighbor + [set() for v in xrange(mesh.numVertices)]
        for l in xrange(len(indices) / 3):
            i0 = indices[l * 3 + 0] + offset
            i1 = indices[l * 3 + 1] + offset
            i2 = indices[l * 3 + 2] + offset
            neighbor[i0].add(i1)
            neighbor[i0].add(i2)
            neighbor[i1].add(i0)
            neighbor[i1].add(i2)
            neighbor[i2].add(i0)
            neighbor[i2].add(i1)
    maxlen = 0
    for i in xrange(len(neighbor)):
        maxlen = max(maxlen, len(neighbor[i]))
    retval = -np.ones([len(neighbor), maxlen], dtype = np.longlong)
    for i in xrange(len(neighbor)):
        retval[i, 0:len(neighbor[i])] = list(neighbor[i])
    return retval 
开发者ID:TomohikoMukai,项目名称:ssds,代码行数:26,代码来源:main.py

示例5: test_signed_overflow_bounds

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import longlong [as 别名]
def test_signed_overflow_bounds(self):
        self.do_signed_overflow_bounds(np.byte)
        self.do_signed_overflow_bounds(np.short)
        self.do_signed_overflow_bounds(np.intc)
        self.do_signed_overflow_bounds(np.int_)
        self.do_signed_overflow_bounds(np.longlong) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:8,代码来源:test_histograms.py

示例6: test_platform_dependent_aliases

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import longlong [as 别名]
def test_platform_dependent_aliases(self):
        if np.int64 is np.int_:
            assert_('int64' in np.int_.__doc__)
        elif np.int64 is np.longlong:
            assert_('int64' in np.longlong.__doc__) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:7,代码来源:test_numerictypes.py

示例7: testLongLong

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import longlong [as 别名]
def testLongLong(self):
    self.assertAllClose(
        onp.int64(7), npe.jit(lambda x: x)(onp.longlong(7)), check_dtypes=True) 
开发者ID:google,项目名称:trax,代码行数:5,代码来源:lax_numpy_test.py

示例8: test_eigvals_banded

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import longlong [as 别名]
def test_eigvals_banded(self):
        """Compare eigenvalues of eigvals_banded with those of linalg.eig."""
        w_sym = eigvals_banded(self.bandmat_sym)
        w_sym = w_sym.real
        assert_array_almost_equal(sort(w_sym), self.w_sym_lin)

        w_herm = eigvals_banded(self.bandmat_herm)
        w_herm = w_herm.real
        assert_array_almost_equal(sort(w_herm), self.w_herm_lin)

        # extracting eigenvalues with respect to an index range
        ind1 = 2
        ind2 = np.longlong(6)
        w_sym_ind = eigvals_banded(self.bandmat_sym,
                                    select='i', select_range=(ind1, ind2))
        assert_array_almost_equal(sort(w_sym_ind),
                                  self.w_sym_lin[ind1:ind2+1])
        w_herm_ind = eigvals_banded(self.bandmat_herm,
                                    select='i', select_range=(ind1, ind2))
        assert_array_almost_equal(sort(w_herm_ind),
                                  self.w_herm_lin[ind1:ind2+1])

        # extracting eigenvalues with respect to a value range
        v_lower = self.w_sym_lin[ind1] - 1.0e-5
        v_upper = self.w_sym_lin[ind2] + 1.0e-5
        w_sym_val = eigvals_banded(self.bandmat_sym,
                                select='v', select_range=(v_lower, v_upper))
        assert_array_almost_equal(sort(w_sym_val),
                                  self.w_sym_lin[ind1:ind2+1])

        v_lower = self.w_herm_lin[ind1] - 1.0e-5
        v_upper = self.w_herm_lin[ind2] + 1.0e-5
        w_herm_val = eigvals_banded(self.bandmat_herm,
                                select='v', select_range=(v_lower, v_upper))
        assert_array_almost_equal(sort(w_herm_val),
                                  self.w_herm_lin[ind1:ind2+1])

        w_sym = eigvals_banded(self.bandmat_sym, check_finite=False)
        w_sym = w_sym.real
        assert_array_almost_equal(sort(w_sym), self.w_sym_lin) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:42,代码来源:test_decomp.py

示例9: test_numpy

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import longlong [as 别名]
def test_numpy(self):
        """NumPy objects get serialized to readable JSON."""
        l = [
            np.float32(12.5),
            np.float64(2.0),
            np.float16(0.5),
            np.bool(True),
            np.bool(False),
            np.bool_(True),
            np.unicode_("hello"),
            np.byte(12),
            np.short(12),
            np.intc(-13),
            np.int_(0),
            np.longlong(100),
            np.intp(7),
            np.ubyte(12),
            np.ushort(12),
            np.uintc(13),
            np.ulonglong(100),
            np.uintp(7),
            np.int8(1),
            np.int16(3),
            np.int32(4),
            np.int64(5),
            np.uint8(1),
            np.uint16(3),
            np.uint32(4),
            np.uint64(5),
        ]
        l2 = [l, np.array([1, 2, 3])]
        roundtripped = loads(dumps(l2, cls=EliotJSONEncoder))
        self.assertEqual([l, [1, 2, 3]], roundtripped) 
开发者ID:itamarst,项目名称:eliot,代码行数:35,代码来源:test_json.py

示例10: get_dims

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import longlong [as 别名]
def get_dims(self):
        """ Gets the dimensions of the KHIVA array.

        :return: The dimensions of the KHIVA array.
        """
        c_array_n = (ctypes.c_longlong * 4)(*(np.zeros(4)).astype(np.longlong))
        error_code = ctypes.c_int(0)
        error_message = ctypes.create_string_buffer(KHIVA_ERROR_LENGTH)
        KhivaLibrary().c_khiva_library.get_dims(ctypes.pointer(self.arr_reference),
                                                ctypes.pointer(c_array_n),
                                                ctypes.pointer(error_code),
                                                error_message)
        return np.array(c_array_n) 
开发者ID:shapelets,项目名称:khiva-python,代码行数:15,代码来源:array.py

示例11: test_return_arrcrt_zeros

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import longlong [as 别名]
def test_return_arrcrt_zeros(a, b, c):
    d = np.zeros(3)
    d[:] = 2
    d[0] = 1
    return d

# TODO: fix for np.ulonglong, np.longlong and uint64 
开发者ID:jakeret,项目名称:hope,代码行数:9,代码来源:test_return.py

示例12: test_return_scalar

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import longlong [as 别名]
def test_return_scalar(dtype):
    def fkt(a): return a
    ao, ah = random(dtype, [])
    ro, rh = fkt(ao), hope.jit(fkt)(ah)
    assert check(ro, rh)

# TODO: fix for np.ulonglong, np.longlong and uint64 
开发者ID:jakeret,项目名称:hope,代码行数:9,代码来源:test_return.py

示例13: test_return_arrayscalar

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import longlong [as 别名]
def test_return_arrayscalar(dtype):
    def fkt(a): return a[2]
    ao, ah = random(dtype, [10])
    ro, rh = fkt(ao), hope.jit(fkt)(ah)
    assert check(ro, rh)

# TODO: fix for np.ulonglong, np.longlong and uint64 
开发者ID:jakeret,项目名称:hope,代码行数:9,代码来源:test_return.py

示例14: _to_qtimestamp

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import longlong [as 别名]
def _to_qtimestamp(dt):
    t_dt = type(dt)
    if t_dt == numpy.int64:
        return dt
    elif t_dt == numpy.datetime64:
        return (dt - _EPOCH_TIMESTAMP).astype(longlong) if not dt == _NUMPY_NULL[QTIMESTAMP] else _QTIMESTAMP_NULL
    else:
        raise ValueError('Cannot convert %s of type %s to q value.' % (dt, type(dt))) 
开发者ID:exxeleron,项目名称:qPython,代码行数:10,代码来源:qtemporal.py

示例15: _to_qtimespan

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import longlong [as 别名]
def _to_qtimespan(dt):
    t_dt = type(dt)
    if t_dt == numpy.int64:
        return dt
    elif t_dt == numpy.timedelta64:
        return dt.astype(longlong) if not dt == _NUMPY_NULL[QTIMESPAN] else _QTIMESTAMP_NULL
    else:
        raise ValueError('Cannot convert %s of type %s to q value.' % (dt, type(dt))) 
开发者ID:exxeleron,项目名称:qPython,代码行数:10,代码来源:qtemporal.py


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