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


Python numpy.uint32函数代码示例

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


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

示例1: radixSortKeysOnly

 def radixSortKeysOnly(self, keyBits):
     i = numpy.uint32(0)
     bitStep = self.bitStep
     
     while (keyBits > i*bitStep):
         self.radixSortStepKeysOnly(bitStep, i*bitStep)
         i+=numpy.uint32(1)
开发者ID:sabago,项目名称:pysph,代码行数:7,代码来源:radix_sort.py

示例2: testIntMax

    def testIntMax(self):
        num = np.int(np.iinfo(np.int).max)
        self.assertEqual(np.int(ujson.decode(ujson.encode(num))), num)

        num = np.int8(np.iinfo(np.int8).max)
        self.assertEqual(np.int8(ujson.decode(ujson.encode(num))), num)

        num = np.int16(np.iinfo(np.int16).max)
        self.assertEqual(np.int16(ujson.decode(ujson.encode(num))), num)

        num = np.int32(np.iinfo(np.int32).max)
        self.assertEqual(np.int32(ujson.decode(ujson.encode(num))), num)

        num = np.uint8(np.iinfo(np.uint8).max)
        self.assertEqual(np.uint8(ujson.decode(ujson.encode(num))), num)

        num = np.uint16(np.iinfo(np.uint16).max)
        self.assertEqual(np.uint16(ujson.decode(ujson.encode(num))), num)

        num = np.uint32(np.iinfo(np.uint32).max)
        self.assertEqual(np.uint32(ujson.decode(ujson.encode(num))), num)

        if platform.architecture()[0] != '32bit':
            num = np.int64(np.iinfo(np.int64).max)
            self.assertEqual(np.int64(ujson.decode(ujson.encode(num))), num)

            # uint64 max will always overflow as it's encoded to signed
            num = np.uint64(np.iinfo(np.int64).max)
            self.assertEqual(np.uint64(ujson.decode(ujson.encode(num))), num)
开发者ID:paddymul,项目名称:pandas,代码行数:29,代码来源:test_ujson.py

示例3: combine_scaled

def combine_scaled(r, g, b, a):
    """Combine components in [0, 1] to rgba uint32"""
    r2 = min(255, np.uint32(r * 255))
    g2 = min(255, np.uint32(g * 255))
    b2 = min(255, np.uint32(b * 255))
    a2 = min(255, np.uint32(a * 255))
    return np.uint32((a2 << 24) | (b2 << 16) | (g2 << 8) | r2)
开发者ID:jsignell,项目名称:datashader,代码行数:7,代码来源:composite.py

示例4: get_bucket

def get_bucket(uhash, pieces, first_bucket_vector, second_bucket_vector):
    h_index = np.uint64(first_bucket_vector[0]) + np.uint64(second_bucket_vector[0 + 2])
    if h_index >= const.prime_default:
        h_index -= const.prime_default
    assert(h_index < const.prime_default)
    h_index = np.uint32(h_index)
    h_index = h_index % uhash.table_size

    control = np.uint64(first_bucket_vector[1]) + np.uint64(second_bucket_vector[1 + 2])
    if control >= const.prime_default:
        control -= const.prime_default
    assert(control < const.prime_default)
    control = np.uint32(control)
    
    if uhash.t == 2:
        index_hybrid = uhash.hybrid_hash_table[h_index]

        while index_hybrid:
            if index_hybrid.control_value == control:
                index_hybrid = C.pointer(index_hybrid)[1]
                return index_hybrid
            else:
                index_hybrid = C.pointer(index_hybrid)[1]
                if index_hybrid.point.is_last_bucket:
                    return None
                l = index_hybrid.point.bucket_length
                index_hybrid = C.pointer(index_hybrid)[l]
        return None
开发者ID:ajauhri,项目名称:knn-exps,代码行数:28,代码来源:lsh_helper.py

示例5: pad

    def pad(self, max_pad):
        """
        Pad the timeseries data so that there are no missing values. We fill in
        missing power values using the previous power value in the series.
        """
        width = self.times[-1] - self.times[0] + 1
        padded_array = np.rec.array((0, 2), dtype=[('time', np.uint32),
                                                   ('power', np.float32)])
        padded_array.resize(width)

        cnt = 0
        for i in xrange(len(self.times)-1):
            padded_array[cnt] = (np.uint32(self.times[i]), self.powers[i])
            cnt += 1

            if self.times[i+1] - self.times[i] > max_pad:
                continue

            for t in xrange(self.times[i]+1, self.times[i+1]):
                padded_array[cnt] = (np.uint32(t), self.powers[i])
                cnt += 1

        padded_array[cnt] = (np.uint32(self.times[-1]), self.powers[-1])
        padded_array.resize(cnt + 1)

        self.array = padded_array
开发者ID:CMPUT-466-551-ML-Project,项目名称:NILM-Project,代码行数:26,代码来源:timeseries.py

示例6: __call__

    def __call__(self, queue, tgt, src, shape):
        w, h = shape
        assert w % block_size == 0
        assert h % block_size == 0

        return self.kernel(queue, (w, h), None,
            tgt, src, numpy.uint32(w), numpy.uint32(h))
开发者ID:imxiaohui,项目名称:PyOpenCL-Tutorial,代码行数:7,代码来源:08_transpose.py

示例7: decode

	def decode(self, server, block_header, target, job_id = None, extranonce2 = None):
		if block_header:
			job = Object()
	
			binary_data = block_header.decode('hex')
			data0 = np.zeros(64, np.uint32)
			data0 = np.insert(data0, [0] * 16, unpack('IIIIIIIIIIIIIIII', binary_data[:64]))
	
			job.target	  = np.array(unpack('IIIIIIII', target.decode('hex')), dtype=np.uint32)
			job.header	  = binary_data[:68]
			job.merkle_end  = np.uint32(unpack('I', binary_data[64:68])[0])
			job.time		= np.uint32(unpack('I', binary_data[68:72])[0])
			job.difficulty  = np.uint32(unpack('I', binary_data[72:76])[0])
			job.state	   = sha256(STATE, data0)
			job.f		   = np.zeros(8, np.uint32)
			job.state2	  = partial(job.state, job.merkle_end, job.time, job.difficulty, job.f)
			job.targetQ	 = 2**256 / int(''.join(list(chunks(target, 2))[::-1]), 16)
			job.job_id	  = job_id
			job.extranonce2 = extranonce2
			job.server	  = server
	
			calculateF(job.state, job.merkle_end, job.time, job.difficulty, job.f, job.state2)

			if job.difficulty != self.difficulty:
				self.set_difficulty(job.difficulty)
	
			return job
开发者ID:AngelMarc,项目名称:poclbm-1,代码行数:27,代码来源:Switch.py

示例8: color_count

def color_count(image):
    '''Considering a (w,h,3) image of (dtype=uint8),
       compute the number of unique colors
    
       Encoding (i,j,k) into single index N = i+R*j+R*C*k
       Decoding N into (i,j,k) = (N-k*R*C-j*R, (N-k*R*C)/R, N/(R*C))
       using integer division\n

        Inputs:  image
        Returns: NumPy array of unique colors,
                 number of pixels of each unique color in image
    '''
    #Need to convert image to uint32 before multiplication so numbers are not truncated
    F = np.uint32(image[...,0])*256*256 + np.uint32(image[...,1])*256 + np.uint32(image[...,2])
    unique, counts = np.unique(F, return_counts=True)
    colors = np.empty(shape=(len(unique),3),dtype=np.uint32)
    numcol = np.empty(len(unique),dtype=np.uint32)
    i = 0
    for col,num in zip(unique,counts):
        R = col/(256*256)
        G = (col-R*256*256)/256
        B = (col-R*256*256-G*256)
        colors[i] = (R,G,B)
        numcol[i] = num
        i+=1
    return colors, numcol
开发者ID:dedx,项目名称:StitchIt,代码行数:26,代码来源:StitchIt.py

示例9: calculate_pressure

	def calculate_pressure(self):
		# Calculate atmospheric pressure in [Pa]
		self.B6 = self.B5 - 4000
		print("B6=",self.B6)
		X1 = (self.B2 * (self.B6 * self.B6 / 2**12)) / 2**11
		print("X1=",X1)
		X2 = self.AC2 * self.B6 / 2**11
		print("X2=",X2)
		X3 = X1 + X2
		print("X3=",X3)
		self.B3 = (((self.AC1 * 4 + X3) << self.BMP183_CMD['OVERSAMPLE_3']) + 2 ) / 4
		print("B3=",self.B3)
		X1 = self.AC3 * self.B6 / 2**13
		print("X1=",X1)
		X2 = (self.B1 * (self.B6 * self.B6 / 2**12)) / 2**16
		print("X2=",X2)
		X3 = ((X1 + X2) + 2) / 2**2
		print("X3=",X3)
		self.B4 = numpy.uint32 (self.AC4 * (X3 + 32768) / 2**15)
		print("B4=",self.B4)
		self.B7 = (numpy.uint32 (self.UP) - self.B3) * (50000 >> self.BMP183_CMD['OVERSAMPLE_3'])
		print("B7=",self.B7)
		p = numpy.uint32 ((self.B7 * 2) / self.B4)
		print("p=",p)
		X1 = (p / 2**8) * ( p / 2**8)
		print("X1=",X1)
		X1 = int (X1 * 3038) / 2**16
		print("X1=",X1)
		X2 = int (-7357 * p) / 2**16
		print("X2=",X2)
		self.pressure = p + (X1 + X2 +3791) / 2**4
		print("pressure=",self.pressure)
开发者ID:mirabitl,项目名称:SDHCAL,代码行数:32,代码来源:bmp183.py

示例10: communion_encode

def communion_encode(msg):
    assert msg["mode"] in ("request", "response")
    m = 'SEAMLESS'.encode()
    tip = b'\x00' if msg["mode"] == "request" else b'\x01'
    m += tip

    m += np.uint32(msg["id"]).tobytes()
    remainder = msg.copy()
    remainder.pop("mode")
    remainder.pop("id")
    remainder.pop("content")    
    if len(remainder.keys()):
        rem = json.dumps(remainder).encode()
        nrem = np.uint32(len(rem))
        m += nrem
        m += rem
    else:
        m += b'\x00\x00\x00\x00'
    content = msg["content"]
    if content is None:
        m += b'\x00'
    else:
        assert isinstance(content, (str, bytes, bool)), content
        if isinstance(content, bool):
            is_str = b'\x01'
        else:
            is_str = b'\x03' if isinstance(content, str) else b'\x02'
        m += is_str
        if isinstance(content, str):
            content = content.encode()
        elif isinstance(content, bool):
            content = b'\x01' if content else b'\x00'
        m += content
    #assert communion_decode(m) == msg, (communion_decode(m), msg)
    return m
开发者ID:sjdv1982,项目名称:seamless,代码行数:35,代码来源:communionserver.py

示例11: set_demod

 def set_demod(self, data):
     @command()
     def set_demod_buffer(self, data): 
         pass
     data1 = np.uint32(np.mod(np.floor(8192 * data[0, :]) + 8192,16384) + 8192)
     data2 = np.uint32(np.mod(np.floor(8192 * data[1, :]) + 8192,16384) + 8192)
     set_demod_buffer(self, data1 + data2 * 2**16)
开发者ID:Koheron,项目名称:zynq-sdk,代码行数:7,代码来源:spectrum.py

示例12: set_dac

 def set_dac(self):
     @command()
     def set_dac_data(self, data):
         pass
     dac_data_1 = np.uint32(np.mod(np.floor(8192 * self.dac[0, :]) + 8192, 16384) + 8192)
     dac_data_2 = np.uint32(np.mod(np.floor(8192 * self.dac[1, :]) + 8192, 16384) + 8192)
     set_dac_data(self, dac_data_1 + 65536 * dac_data_2)
开发者ID:Koheron,项目名称:zynq-sdk,代码行数:7,代码来源:pulse.py

示例13: createSplitPerm

 def createSplitPerm(self, size, subset_ratio=0.8, seed=None):
     rng = np.random.RandomState(np.uint32((time.time())))
     if seed is not None:
         rng.seed(np.uint32(seed))
     perm = rng.permutation(size)
     k = int(size * subset_ratio)
     return perm[:k]
开发者ID:jeffbar,项目名称:ELEKTRONN,代码行数:7,代码来源:traindata.py

示例14: index_to_array

 def index_to_array(self, index, dim, result = None):
     '''
     index_to_array(float* index, float* result, uint r_col, uint r_row)
     '''
     if result is None:
         result = gpuarray.GPUArray([index.size, dim], dtype = self.dtype)
           
         self.index_to_array_kernel(index.gpudata, result.gpudata, \
                                    np.uint32(r_col), np.uint32(r_row), \
                                    block = self._2d_block, \
                                    grid = self._2d_grid(r_col, r_row) \
                                    )     
         return result   
     
     else:
         r_col = result.shape[0]
         r_row = result.shape[1]
         
         if r_col != index.size or r_row != dim:
             raise ValueError('index_to_array: the dim of the result dont match the input')
           
         self.index_to_array_kernel(index.gpudata, result.gpudata, \
                                    np.uint32(r_col), np.uint32(r_row), \
                                    block = self._2d_block, \
                                    grid = self._2d_grid(r_col, r_row) \
                                    )      
开发者ID:luyukunphy,项目名称:pycuda_tensor_module,代码行数:26,代码来源:linalg_cuda.py

示例15: getTimeBaseIndices

 def getTimeBaseIndices(self, name, tBegin, tEnd):
     """ Return time indices of name corresponding to tBegin and tEnd """
     if not self.status:
         raise Exception('Shotfile not open!')
     try:
         sigName = ctypes.c_char_p(name)
     except TypeError:
         sigName = ctypes.c_char_p(name.encode())
     error = ctypes.c_int32(0)
     info = self.getTimeBaseInfo(name)
     if tEnd < tBegin:
         temp = tEnd
         tEnd = tBegin
         tBegin = temp
     if tBegin < info.tBegin:
         tBegin = info.tBegin
     if tEnd > info.tEnd:
         tEnd = info.tEnd
     try:
         time1 = ctypes.c_float(tBegin)
     except TypeError:
         time1 = ctypes.c_float(tBegin.value)
     try:
         time2 = ctypes.c_float(tEnd)
     except TypeError:
         time2 = ctypes.c_float(tEnd.value)
     k1 = ctypes.c_uint32(0)
     k2 = ctypes.c_uint32(0)
     lname = ctypes.c_uint64(len(name))
     __libddww__.ddtindex_(ctypes.byref(error), ctypes.byref(self.diaref), sigName, ctypes.byref(time1), 
                           ctypes.byref(time2), ctypes.byref(k1), ctypes.byref(k2), lname)
     getError(error.value)
     return numpy.uint32(k1.value), numpy.uint32(k2.value)
开发者ID:tardini,项目名称:pyddww,代码行数:33,代码来源:dd.py


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