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


Python numpy.uint64方法代码示例

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


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

示例1: argunique_ctypes

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import uint64 [as 别名]
def argunique_ctypes(strs):
    nstrs, nset = strs.shape

    sort_idx = numpy.empty(nstrs, dtype=numpy.uint64)

    strs = numpy.asarray(strs, order='C')
    sort_idx = numpy.asarray(sort_idx, order='C')

    nstrs_ = numpy.array([nstrs])

    libhci.argunique(strs.ctypes.data_as(ctypes.c_void_p), 
                     sort_idx.ctypes.data_as(ctypes.c_void_p), 
                     nstrs_.ctypes.data_as(ctypes.c_void_p), 
                     ctypes.c_int(nset))

    sort_idx = sort_idx[:nstrs_[0]]

    return sort_idx.tolist() 
开发者ID:pyscf,项目名称:pyscf,代码行数:20,代码来源:hci.py

示例2: test_able_int_type

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import uint64 [as 别名]
def test_able_int_type():
    # The integer type cabable of containing values
    for vals, exp_out in (
        ([0, 1], np.uint8),
        ([0, 255], np.uint8),
        ([-1, 1], np.int8),
        ([0, 256], np.uint16),
        ([-1, 128], np.int16),
        ([0.1, 1], None),
        ([0, 2**16], np.uint32),
        ([-1, 2**15], np.int32),
        ([0, 2**32], np.uint64),
        ([-1, 2**31], np.int64),
        ([-1, 2**64-1], None),
        ([0, 2**64-1], np.uint64),
        ([0, 2**64], None)):
        assert_equal(able_int_type(vals), exp_out) 
开发者ID:ME-ICA,项目名称:me-ica,代码行数:19,代码来源:test_casting.py

示例3: testChunkReadPoints2D

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import uint64 [as 别名]
def testChunkReadPoints2D(self):
        chunk_id = "c-00de6a9c-6aff5c35-15d5-3864dd-0740f8_3_4"
        chunk_layout = (100,100)
        chunk_arr = np.zeros((100,100))
        chunk_arr[:,12] = 69
        chunk_arr[12,:] = 96

        point_arr = np.array([[312,498],[312,412],[355,412],[398,497]], dtype=np.uint64)
        arr = chunkReadPoints(chunk_id=chunk_id, chunk_layout=chunk_layout, chunk_arr=chunk_arr, point_arr=point_arr)
        self.assertEqual(arr.tolist(), [96,96,69,0])

        point_arr = np.array([[312,498],[312,412],[355,412],[398,397]], dtype=np.uint64)
        try:
            chunkReadPoints(chunk_id=chunk_id, chunk_layout=chunk_layout, chunk_arr=chunk_arr, point_arr=point_arr)
            self.assertTrue(False)  # expected exception
        except IndexError:
            pass # expected 
开发者ID:HDFGroup,项目名称:hsds,代码行数:19,代码来源:chunkUtilTest.py

示例4: check

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import uint64 [as 别名]
def check(self, stream):
        """Check that the CRC at the end of athe stream is correct.

        Parameters
        ----------
        stream : int or array of unsigned int
            For an integer, the value is the stream to check the CRC for.
            For arrays, the dimension is treated as the index into the bits.
            A single stream would thus be of type `bool`. Unsigned integers
            represent multiple streams. E.g., for a 64-track Mark 4 header,
            the stream would be an array of ``np.uint64`` words.

        Returns
        -------
        ok : bool
             `True` if the calculated CRC is all zero (which should be the
             case if the CRC at the end of the stream is correct).
        """
        return self._crc(stream) == 0 
开发者ID:mhvk,项目名称:baseband,代码行数:21,代码来源:utils.py

示例5: reorder64_Ft

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import uint64 [as 别名]
def reorder64_Ft(x):
        """Reorder 64-track bits to bring signs & magnitudes together.

        Special version for the Ft station, which has unusual settings.
        """
        return (((x & 0xFFFFFAAFFFFFFAAF))
                | ((x & 0x0000050000000500) >> 4)
                | ((x & 0x0000005000000050) << 4))
    # Check on 2015-JUL-12: C code: 738811025863578102 -> 738829572664316278
    # 118, 209, 53, 244, 148, 217, 64, 10
    # reorder64(np.array([738811025863578102], dtype=np.uint64))
    # # array([738829572664316278], dtype=uint64)
    # reorder64(np.array([738811025863578102], dtype=np.uint64)).view(np.uint8)
    # # array([118, 209,  53, 244, 148, 217,  64,  10], dtype=uint8)
    # decode_2bit_64track_fanout4(
    #     np.array([738811025863578102], dtype=np.int64)).astype(int).T
    # -1  1  3  1  array([[-1,  1,  3,  1],
    #  1  1  3 -3         [ 1,  1,  3, -3],
    #  1 -3  1  3         [ 1, -3,  1,  3],
    # -3  1  3  3         [-3,  1,  3,  3],
    # -3  1  1 -1         [-3,  1,  1, -1],
    # -3 -3 -3  1         [-3, -3, -3,  1],
    #  1 -1  1  3         [ 1, -1,  1,  3],
    # -1 -1 -3 -3         [-1, -1, -3, -3]]) 
开发者ID:mhvk,项目名称:baseband,代码行数:26,代码来源:payload.py

示例6: encode_16chan_2bit_fanout2_ft

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import uint64 [as 别名]
def encode_16chan_2bit_fanout2_ft(values):
    """Encode payload for 16 channels using 2 bits, fan-out 2 (64 tracks)."""
    # words encode 32 values (above) in order ch&0x8, ch&0x3, sample, ch&0x4
    # First reshape goes to time, sample, ch&0x8, ch&0x4, ch&0x3,
    # transpose makes this time, ch&0x8, ch&0x3, sample, ch&0x4.
    # second reshape future bytes, sample+ch&0x4.
    values = (values.reshape(-1, 2, 2, 2, 4).transpose(0, 2, 4, 1, 3)
              .reshape(-1, 4))
    bitvalues = encode_2bit_base(values)
    # values are -3, -1, +1, 3 -> 00, 01, 10, 11;
    # get first bit (sign) as 1, second bit (magnitude) as 16
    reorder_bits = np.array([0, 16, 1, 17], dtype=np.uint8)
    reorder_bits.take(bitvalues, out=bitvalues)
    bitvalues <<= np.array([0, 1, 2, 3], dtype=np.uint8)
    out = np.bitwise_or.reduce(bitvalues, axis=-1).ravel().view(np.uint64)
    return reorder64_Ft(out).view('<u8') 
开发者ID:mhvk,项目名称:baseband,代码行数:18,代码来源:payload.py

示例7: squeeze_bits

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import uint64 [as 别名]
def squeeze_bits(arr: numpy.ndarray) -> numpy.ndarray:
    """Return a copy of an integer numpy array with the minimum bitness."""
    assert arr.dtype.kind in ("i", "u")
    if arr.size == 0:
        return arr
    if arr.dtype.kind == "i":
        assert arr.min() >= 0
    mlbl = int(arr.max()).bit_length()
    if mlbl <= 8:
        dtype = numpy.uint8
    elif mlbl <= 16:
        dtype = numpy.uint16
    elif mlbl <= 32:
        dtype = numpy.uint32
    else:
        dtype = numpy.uint64
    return arr.astype(dtype) 
开发者ID:src-d,项目名称:modelforge,代码行数:19,代码来源:model.py

示例8: test_int64_uint64_corner_case

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import uint64 [as 别名]
def test_int64_uint64_corner_case(self):
        # When stored in Numpy arrays, `lbnd` is casted
        # as np.int64, and `ubnd` is casted as np.uint64.
        # Checking whether `lbnd` >= `ubnd` used to be
        # done solely via direct comparison, which is incorrect
        # because when Numpy tries to compare both numbers,
        # it casts both to np.float64 because there is
        # no integer superset of np.int64 and np.uint64. However,
        # `ubnd` is too large to be represented in np.float64,
        # causing it be round down to np.iinfo(np.int64).max,
        # leading to a ValueError because `lbnd` now equals
        # the new `ubnd`.

        dt = np.int64
        tgt = np.iinfo(np.int64).max
        lbnd = np.int64(np.iinfo(np.int64).max)
        ubnd = np.uint64(np.iinfo(np.int64).max + 1)

        # None of these function calls should
        # generate a ValueError now.
        actual = np.random.randint(lbnd, ubnd, dtype=dt)
        assert_equal(actual, tgt) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:24,代码来源:test_random.py

示例9: test_constructor

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import uint64 [as 别名]
def test_constructor(self):
        idx = UInt64Index([1, 2, 3])
        res = Index([1, 2, 3], dtype=np.uint64)
        tm.assert_index_equal(res, idx)

        idx = UInt64Index([1, 2**63])
        res = Index([1, 2**63], dtype=np.uint64)
        tm.assert_index_equal(res, idx)

        idx = UInt64Index([1, 2**63])
        res = Index([1, 2**63])
        tm.assert_index_equal(res, idx)

        idx = Index([-1, 2**63], dtype=object)
        res = Index(np.array([-1, 2**63], dtype=object))
        tm.assert_index_equal(res, idx) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:18,代码来源:test_numeric.py

示例10: test_sum_uint64_overflow

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import uint64 [as 别名]
def test_sum_uint64_overflow():
    # see gh-14758
    # Convert to uint64 and don't overflow
    df = pd.DataFrame([[1, 2], [3, 4], [5, 6]], dtype=object)
    df = df + 9223372036854775807

    index = pd.Index([9223372036854775808,
                      9223372036854775810,
                      9223372036854775812],
                     dtype=np.uint64)
    expected = pd.DataFrame({1: [9223372036854775809,
                                 9223372036854775811,
                                 9223372036854775813]},
                            index=index)

    expected.index.name = 0
    result = df.groupby(0).sum()
    tm.assert_frame_equal(result, expected) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:20,代码来源:test_other.py

示例11: test_setitem

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import uint64 [as 别名]
def test_setitem(self):

        df = self.df
        idx = self.idx

        # setitem
        df['C'] = idx
        assert_series_equal(df['C'], Series(idx, name='C'))

        df['D'] = 'foo'
        df['D'] = idx
        assert_series_equal(df['D'], Series(idx, name='D'))
        del df['D']

        # With NaN: because uint64 has no NaN element,
        # the column should be cast to object.
        df2 = df.copy()
        df2.iloc[1, 1] = pd.NaT
        df2.iloc[1, 2] = pd.NaT
        result = df2['B']
        assert_series_equal(notna(result), Series(
            [True, False, True], name='B'))
        assert_series_equal(df2.dtypes, Series([np.dtype('uint64'),
                                                np.dtype('O'), np.dtype('O')],
                                               index=['A', 'B', 'C'])) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:27,代码来源:test_indexing.py

示例12: test_constructor_overflow_int64

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import uint64 [as 别名]
def test_constructor_overflow_int64(self):
        # see gh-14881
        values = np.array([2 ** 64 - i for i in range(1, 10)],
                          dtype=np.uint64)

        result = DataFrame({'a': values})
        assert result['a'].dtype == np.uint64

        # see gh-2355
        data_scores = [(6311132704823138710, 273), (2685045978526272070, 23),
                       (8921811264899370420, 45),
                       (long(17019687244989530680), 270),
                       (long(9930107427299601010), 273)]
        dtype = [('uid', 'u8'), ('score', 'u8')]
        data = np.zeros((len(data_scores),), dtype=dtype)
        data[:] = data_scores
        df_crawls = DataFrame(data)
        assert df_crawls['uid'].dtype == np.uint64 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:20,代码来源:test_constructors.py

示例13: test_coerce_uint64_conflict

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import uint64 [as 别名]
def test_coerce_uint64_conflict(self):
        # see gh-17007 and gh-17125
        #
        # Still returns float despite the uint64-nan conflict,
        # which would normally force the casting to object.
        df = pd.DataFrame({"a": [200, 300, "", "NaN", 30000000000000000000]})
        expected = pd.Series([200, 300, np.nan, np.nan,
                              30000000000000000000], dtype=float, name="a")
        result = to_numeric(df["a"], errors="coerce")
        tm.assert_series_equal(result, expected)

        s = pd.Series(["12345678901234567890", "1234567890", "ITEM"])
        expected = pd.Series([12345678901234567890,
                              1234567890, np.nan], dtype=float)
        result = to_numeric(s, errors="coerce")
        tm.assert_series_equal(result, expected)

        # For completeness, check against "ignore" and "raise"
        result = to_numeric(s, errors="ignore")
        tm.assert_series_equal(result, s)

        msg = "Unable to parse string"
        with pytest.raises(ValueError, match=msg):
            to_numeric(s, errors="raise") 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:26,代码来源:test_numeric.py

示例14: test_hash_collisions

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import uint64 [as 别名]
def test_hash_collisions():
    # Hash collisions are bad.
    #
    # https://github.com/pandas-dev/pandas/issues/14711#issuecomment-264885726
    hashes = ["Ingrid-9Z9fKIZmkO7i7Cn51Li34pJm44fgX6DYGBNj3VPlOH50m7HnBlPxfIwFMrcNJNMP6PSgLmwWnInciMWrCSAlLEvt7JkJl4IxiMrVbXSa8ZQoVaq5xoQPjltuJEfwdNlO6jo8qRRHvD8sBEBMQASrRa6TsdaPTPCBo3nwIBpE7YzzmyH0vMBhjQZLx1aCT7faSEx7PgFxQhHdKFWROcysamgy9iVj8DO2Fmwg1NNl93rIAqC3mdqfrCxrzfvIY8aJdzin2cHVzy3QUJxZgHvtUtOLxoqnUHsYbNTeq0xcLXpTZEZCxD4PGubIuCNf32c33M7HFsnjWSEjE2yVdWKhmSVodyF8hFYVmhYnMCztQnJrt3O8ZvVRXd5IKwlLexiSp4h888w7SzAIcKgc3g5XQJf6MlSMftDXm9lIsE1mJNiJEv6uY6pgvC3fUPhatlR5JPpVAHNSbSEE73MBzJrhCAbOLXQumyOXigZuPoME7QgJcBalliQol7YZ9",  # noqa
              "Tim-b9MddTxOWW2AT1Py6vtVbZwGAmYCjbp89p8mxsiFoVX4FyDOF3wFiAkyQTUgwg9sVqVYOZo09Dh1AzhFHbgij52ylF0SEwgzjzHH8TGY8Lypart4p4onnDoDvVMBa0kdthVGKl6K0BDVGzyOXPXKpmnMF1H6rJzqHJ0HywfwS4XYpVwlAkoeNsiicHkJUFdUAhG229INzvIAiJuAHeJDUoyO4DCBqtoZ5TDend6TK7Y914yHlfH3g1WZu5LksKv68VQHJriWFYusW5e6ZZ6dKaMjTwEGuRgdT66iU5nqWTHRH8WSzpXoCFwGcTOwyuqPSe0fTe21DVtJn1FKj9F9nEnR9xOvJUO7E0piCIF4Ad9yAIDY4DBimpsTfKXCu1vdHpKYerzbndfuFe5AhfMduLYZJi5iAw8qKSwR5h86ttXV0Mc0QmXz8dsRvDgxjXSmupPxBggdlqUlC828hXiTPD7am0yETBV0F3bEtvPiNJfremszcV8NcqAoARMe"]  # noqa

    # These should be different.
    result1 = hash_array(np.asarray(hashes[0:1], dtype=object), "utf8")
    expected1 = np.array([14963968704024874985], dtype=np.uint64)
    tm.assert_numpy_array_equal(result1, expected1)

    result2 = hash_array(np.asarray(hashes[1:2], dtype=object), "utf8")
    expected2 = np.array([16428432627716348016], dtype=np.uint64)
    tm.assert_numpy_array_equal(result2, expected2)

    result = hash_array(np.asarray(hashes, dtype=object), "utf8")
    tm.assert_numpy_array_equal(result, np.concatenate([expected1,
                                                        expected2], axis=0)) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:21,代码来源:test_hashing.py

示例15: test_maybe_convert_objects_uint64

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import uint64 [as 别名]
def test_maybe_convert_objects_uint64(self):
        # see gh-4471
        arr = np.array([2**63], dtype=object)
        exp = np.array([2**63], dtype=np.uint64)
        tm.assert_numpy_array_equal(lib.maybe_convert_objects(arr), exp)

        # NumPy bug: can't compare uint64 to int64, as that
        # results in both casting to float64, so we should
        # make sure that this function is robust against it
        arr = np.array([np.uint64(2**63)], dtype=object)
        exp = np.array([2**63], dtype=np.uint64)
        tm.assert_numpy_array_equal(lib.maybe_convert_objects(arr), exp)

        arr = np.array([2, -1], dtype=object)
        exp = np.array([2, -1], dtype=np.int64)
        tm.assert_numpy_array_equal(lib.maybe_convert_objects(arr), exp)

        arr = np.array([2**63, -1], dtype=object)
        exp = np.array([2**63, -1], dtype=object)
        tm.assert_numpy_array_equal(lib.maybe_convert_objects(arr), exp) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:22,代码来源:test_inference.py


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