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


Python numpy.int64函数代码示例

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


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

示例1: step

	def step(self):
		'''
		For each timestep, a sparse linear system (Ax = C) need to be solved to update ice surface elevation
		'''

		### update diffusivity for each timestep
		self.diffusion_update()
		D_sum = self.D_IC_jc + self.D_IP_jc + self.D_ic_JC + self.D_ic_JP

		row = np.int64([[self.ic_jc],[self.ic_jc],[self.ic_jc],[self.ic_jc],[self.ic_jc]]).flatten()
		col = np.int64([[self.im_jc],[self.ip_jc],[self.ic_jm],[self.ic_jp],[self.ic_jc]]).flatten()
		val = np.array([[-self.OMEGA * self.D_IC_jc],[-self.OMEGA * self.D_IP_jc],[-self.OMEGA * self.D_ic_JC],[-self.OMEGA * self.D_ic_JP],[1/self.dt + self.OMEGA * D_sum]]).flatten()
		C = (1 - self.OMEGA) * ((self.D_IC_jc * self.S[self.im_jc]) + self.D_IP_jc * self.S[self.ip_jc] + self.D_ic_JC * self.S[self.ic_jm] + self.D_ic_JP * \
			self.S[self.ic_jp]) + (1/self.dt - (1 - self.OMEGA) * D_sum) * self.S[self.ic_jc] + self.b_dot
		C = C.flatten()

		### construct a sparse matrix A
		A = csr_matrix( (val,(row,col)), shape=(self.N, self.N))
		# print 'solving'
		S_out = linalg.spsolve(A,C)
		# print 'solved'

		### ice thickness couldn't be negative, ice surface elevation should not be less than bed elevation
		S_out[S_out < self.B] = self.B[S_out < self.B]

		t_n = self.t + self.dt
		return S_out, t_n
开发者ID:ericthred,项目名称:landlab,代码行数:27,代码来源:glacier.py

示例2: test_asset_comparisons

    def test_asset_comparisons(self):

        s_23 = Asset(23)
        s_24 = Asset(24)

        self.assertEqual(s_23, s_23)
        self.assertEqual(s_23, 23)
        self.assertEqual(23, s_23)
        self.assertEqual(int32(23), s_23)
        self.assertEqual(int64(23), s_23)
        self.assertEqual(s_23, int32(23))
        self.assertEqual(s_23, int64(23))
        # Check all int types (includes long on py2):
        for int_type in integer_types:
            self.assertEqual(int_type(23), s_23)
            self.assertEqual(s_23, int_type(23))

        self.assertNotEqual(s_23, s_24)
        self.assertNotEqual(s_23, 24)
        self.assertNotEqual(s_23, "23")
        self.assertNotEqual(s_23, 23.5)
        self.assertNotEqual(s_23, [])
        self.assertNotEqual(s_23, None)
        # Compare to a value that doesn't fit into a platform int:
        self.assertNotEqual(s_23, sys.maxsize + 1)

        self.assertLess(s_23, s_24)
        self.assertLess(s_23, 24)
        self.assertGreater(24, s_23)
        self.assertGreater(s_24, s_23)
开发者ID:280185386,项目名称:zipline,代码行数:30,代码来源:test_assets.py

示例3: calculateComplexDerefOpAddress

    def calculateComplexDerefOpAddress(complexDerefOp, registerMap):

        match = re.match("((?:\\-?0x[0-9a-f]+)?)\\(%([a-z0-9]+),%([a-z0-9]+),([0-9]+)\\)", complexDerefOp)
        if match != None:
            offset = 0L
            if len(match.group(1)) > 0:
                offset = long(match.group(1), 16)

            regA = RegisterHelper.getRegisterValue(match.group(2), registerMap)
            regB = RegisterHelper.getRegisterValue(match.group(3), registerMap)

            mult = long(match.group(4), 16)

            # If we're missing any of the two register values, return None
            if regA == None or regB == None:
                if regA == None:
                    return (None, "Missing value for register %s" % match.group(2))
                else:
                    return (None, "Missing value for register %s" % match.group(3))

            if RegisterHelper.getBitWidth(registerMap) == 32:
                val = int32(uint32(regA)) + int32(uint32(offset)) + (int32(uint32(regB)) * int32(uint32(mult)))
            else:
                # Assume 64 bit width
                val = int64(uint64(regA)) + int64(uint64(offset)) + (int64(uint64(regB)) * int64(uint64(mult)))
            return (long(val), None)

        return (None, "Unknown failure.")
开发者ID:terminiter,项目名称:FuzzManager,代码行数:28,代码来源:CrashInfo.py

示例4: KMeansConfig

def KMeansConfig(dataTable, k, eps = 0.00001, srcDims=100000000000,gpuMemSize = 512, settings = {}):
    """
    Creates all the memory/data settings to run GPU accelerated KMeans.
    """
    settings = dataConfig(dataTable,settings)
    settings["sourceDims"] = min(settings["sourceDims"],srcDims)
    
    #XXX: determine memory and thread sizes from device
    settings["memSize"] = gpuMemSize*1024*1024
    settings["maxThreads"] = 1024
    
    #set up chunk sizes
    memoryPerElement = 4*(settings["sourceDims"]*2+2) + 20*4 #this is an estimated memory used per element
    settings["chunkSize"] = min(int(math.ceil(float(settings["memSize"])/memoryPerElement)),settings["dataLength"])
    settings["lastChunkSize"] = ((settings["dataLength"]-1) % settings["chunkSize"]) + 1
    
    #create kernel gridsize tuples
    settings["block"] = (settings["maxThreads"],1,1)
    settings["grid"] = (max(int(math.ceil(float(settings["chunkSize"])/settings["maxThreads"])),1),1,1)
    
    #precalculate all constant kernel params
    settings["dimensions"] = numpy.int64(settings["sourceDims"])
    settings["k"] = numpy.int64(k)
    settings["eps"] = numpy.float32(eps)
    settings["dataSize"] = numpy.int64(settings["dataLength"])
    settings["chunkSize"] = numpy.int64(settings["chunkSize"])
    settings["maxThreads"] = numpy.int64(settings["maxThreads"])
    
    return settings
开发者ID:aanchan,项目名称:IsomapCUDA,代码行数:29,代码来源:KMeans.py

示例5: test_cf_timedelta

    def test_cf_timedelta(self):
        examples = [
            ('1D', 'days', np.int64(1)),
            (['1D', '2D', '3D'], 'days', np.array([1, 2, 3], 'int64')),
            ('1h', 'hours', np.int64(1)),
            ('1ms', 'milliseconds', np.int64(1)),
            ('1us', 'microseconds', np.int64(1)),
            (['NaT', '0s', '1s'], None, [np.nan, 0, 1]),
            (['30m', '60m'], 'hours', [0.5, 1.0]),
        ]
        if pd.__version__ >= '0.16':
            # not quite sure why, but these examples don't work on older pandas
            examples.extend([(np.timedelta64('NaT', 'ns'), 'days', np.nan),
                             (['NaT', 'NaT'], 'days', [np.nan, np.nan])])

        for timedeltas, units, numbers in examples:
            timedeltas = pd.to_timedelta(timedeltas, box=False)
            numbers = np.array(numbers)

            expected = numbers
            actual, _ = conventions.encode_cf_timedelta(timedeltas, units)
            self.assertArrayEqual(expected, actual)
            self.assertEqual(expected.dtype, actual.dtype)

            if units is not None:
                expected = timedeltas
                actual = conventions.decode_cf_timedelta(numbers, units)
                self.assertArrayEqual(expected, actual)
                self.assertEqual(expected.dtype, actual.dtype)

        expected = np.timedelta64('NaT', 'ns')
        actual = conventions.decode_cf_timedelta(np.array(np.nan), 'days')
        self.assertArrayEqual(expected, actual)
开发者ID:roxyboy,项目名称:xray,代码行数:33,代码来源:test_conventions.py

示例6: test_gh_5430

def test_gh_5430():
    # At least one of these raises an error unless gh-5430 is
    # fixed. In py2k an int is implemented using a C long, so
    # which one fails depends on your system. In py3k there is only
    # one arbitrary precision integer type, so both should fail.
    sigma = np.int32(1)
    out = sndi._ni_support._normalize_sequence(sigma, 1)
    assert_equal(out, [sigma])
    sigma = np.int64(1)
    out = sndi._ni_support._normalize_sequence(sigma, 1)
    assert_equal(out, [sigma])
    # This worked before; make sure it still works
    sigma = 1
    out = sndi._ni_support._normalize_sequence(sigma, 1)
    assert_equal(out, [sigma])
    # This worked before; make sure it still works
    sigma = [1, 1]
    out = sndi._ni_support._normalize_sequence(sigma, 2)
    assert_equal(out, sigma)
    # Also include the OPs original example to make sure we fixed the issue
    x = np.random.normal(size=(256, 256))
    perlin = np.zeros_like(x)
    for i in 2**np.arange(6):
        perlin += sndi.filters.gaussian_filter(x, i, mode="wrap") * i**2
    # This also fixes gh-4106, show that the OPs example now runs.
    x = np.int64(21)
    sndi._ni_support._normalize_sequence(x, 0)
开发者ID:BranYang,项目名称:scipy,代码行数:27,代码来源:test_filters.py

示例7: testInt

    def testInt(self):
        num = np.int(2562010)
        self.assertEqual(np.int(ujson.decode(ujson.encode(num))), num)

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

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

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

        num = np.int64(2562010)
        self.assertEqual(np.int64(ujson.decode(ujson.encode(num))), num)

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

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

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

        num = np.uint64(2562010)
        self.assertEqual(np.uint64(ujson.decode(ujson.encode(num))), num)
开发者ID:paddymul,项目名称:pandas,代码行数:27,代码来源:test_ujson.py

示例8: __init__

    def __init__(self, dmgr, channel, core_device="core"):
        self.core = dmgr.get(core_device)
        self.channel = channel

        # in RTIO cycles
        self.previous_timestamp = numpy.int64(0)
        self.acc_width = numpy.int64(24)
开发者ID:cjbe,项目名称:artiq,代码行数:7,代码来源:ttl.py

示例9: backward_propagation_with_regularization

def backward_propagation_with_regularization(X,Y,cache,lambd):
    '''
    实现我们添加了L2正则化的模型的后向传播
    :param X: 输入数据集,维度为(输入节点数量,数据集里面的数量
    :param Y: 标签,维度为(输出节点数量,数据集里面的数量
    :param cache: 来自forward_propagation()的cache输出
    :param lambd: regularization超参数,实数
    :return: 
    gradients - 一个包含了每个参数\激活值和预激活值变量的替独子点
    '''
    m = X.shape[1]
    (Z1,A1,W1,b1,Z2,A2,W2,b2,Z3,A3,W3,b3)=cache
    dZ3 = A3-Y

    dW3 = (1/m)*np.dot(dZ3,A2.T)+((lambd*W3)/m)
    db3 = (1/m)*np.sum(dZ3,axis = 1,keepdims=True)

    dA2 = np.dot(W3.T,dZ3)
    dZ2 = np.multiply(dA2,np.int64(A2>0))
    dW2 = (1/m)*np.dot(dZ2,A1.T)+((lambd*W2)/m)
    db2 = (1/m)*np.sum(dZ2,axis = 1,keepdims=True)

    dA1 = np.dot(W2.T,dZ2)
    dZ1 = np.multiply(dA1,np.int64(A1>0))
    dW1 = (1/m)*np.dot(dZ1,X.T)+((lambd*W1)/m)
    db1 = (1/m)*np.sum(dZ1,axis =1,keepdims = True)

    gradients = {
        'dZ3':dZ3,'dW3':dW3,'db3':db3,'dA2':dA2,
        'dZ2':dZ2,'dW2':dW2,'db2':db2,'dA1':dA1,
        'dZ1':dZ1,'dW1':dW1,'db1':db1
    }

    return gradients
开发者ID:491811030,项目名称:hellow-world,代码行数:34,代码来源:work2_regularization.py

示例10: histogram_on_speed

    def histogram_on_speed(self, probmap):
        cx = probmap.shape[1] / 2
        cy = probmap.shape[0] / 2



        binsize = 1
        binnum = np.int64(self.nbr_radius / binsize) + 1
        hist = np.zeros((binnum,1))


        if probmap[cy,cx] == probmap.max():
            return hist # no optical flow found and this observation will be discarded

        for y in range(probmap.shape[0]):
            for x in range(probmap.shape[1]):
                if probmap[y,x] < 0.0001:
                    continue 
                dx = np.abs(x - cx)
                dy = np.abs(y - cy)
                d = np.maximum( dx, dy )
                d = np.int64(d/binsize)
                if d >= binnum:
                    d = binnum - 1
                hist[d,0] += probmap[y,x]
        hist = hist /(0.001 + np.sum(hist) )
        return hist
开发者ID:z01nl1o02,项目名称:tests,代码行数:27,代码来源:fixedlocationmonitor.py

示例11: antnum_list_to_baselines

    def antnum_list_to_baselines(self, antnums=[]):
        '''
        antnums will be a list of either tuples of strings, or strings
        this implementation allows the user to input both 0_1 and 1_0
        and it will return the expected baseline (0_1) in both cases
        '''
        antnums_in_data = set(self.ant_1_array)
        baselines = set()
        
        for i in antnums:
            if isinstance(i, tuple):
                ant1, ant2 = np.int64(i)
                
                if ant1 not in antnums_in_data:
                    raise ValueError('No antenna {} found in data.'.format(ant1))
                if ant2 not in antnums_in_data:
                    raise ValueError('No antenna {} found in data.'.format(ant2))
                
                baselines.add(self.antnums_to_baseline(min(ant1, ant2), max(ant1, ant2)))
            
            else:
                ant = np.int64(i)

                if ant not in antnums_in_data:
                    raise ValueError('No antenna {} found in data.'.format(ant))
                
                for j in antnums_in_data:
                    baselines.add(self.antnums_to_baseline(min(ant, j), max(ant, j)))

        return baselines
开发者ID:jpober,项目名称:brownscripts,代码行数:30,代码来源:uvplot.py

示例12: test_trunc

    def test_trunc(self):
        xsg_test_data = loadmat('rounding_behavior_Fix_8_7_to_Fix_5_4.mat')

        input_fractWidth = int(xsg_test_data['input_fract_len'][0,0])
        input_bit_width = int(xsg_test_data['input_bit_width'][0,0])
        input_intWidth = input_bit_width - input_fractWidth - 1
        input_dtype = (input_intWidth, input_fractWidth)

        output_fractWidth = int(xsg_test_data['output_fract_len'][0,0])
        output_bit_width = int(xsg_test_data['output_bit_width'][0,0])
        output_intWidth = output_bit_width - output_fractWidth - 1
        output_dtype = (output_intWidth, output_fractWidth)

        input_int = np.int64(xsg_test_data['input_int'].ravel())
        input_float = input_int * (2 ** -input_fractWidth);

        trunc_int = np.int64(xsg_test_data['trunc_int'].ravel())
        trunc_float = trunc_int * (2 ** -output_fractWidth)

        N = len(input_int)
        for k in range(N):
            input = FixedInt(input_float[k], dtype=input_dtype)
            input_trunc = fixed_point.rounding.round_trunc(input, output_dtype)

            self.assertTrue(input_trunc.fValue == trunc_float[k])
开发者ID:sgowda,项目名称:py_fixed_point,代码行数:25,代码来源:test_rounding.py

示例13: __init__

 def __init__(self, dmgr, channel, core_device="core"):
     self.core = dmgr.get(core_device)
     self.ref_period_mu = seconds_to_mu(self.core.coarse_ref_period, self.core)
     self.channel = channel
     self.write_period_mu = numpy.int64(0)
     self.read_period_mu = numpy.int64(0)
     self.xfer_period_mu = numpy.int64(0)
开发者ID:cjbe,项目名称:artiq,代码行数:7,代码来源:spi.py

示例14: testSaveRestoreNumpyState

  def testSaveRestoreNumpyState(self):
    directory = self.get_temp_dir()
    prefix = os.path.join(directory, "ckpt")
    save_state = _NumpyState()
    saver = util.Checkpoint(numpy=save_state)
    save_state.a = numpy.ones([2, 2])
    save_state.b = numpy.ones([2, 2])
    save_state.b = numpy.zeros([2, 2])
    save_state.c = numpy.int64(3)
    self.assertAllEqual(numpy.ones([2, 2]), save_state.a)
    self.assertAllEqual(numpy.zeros([2, 2]), save_state.b)
    self.assertEqual(3, save_state.c)
    first_save_path = saver.save(prefix)
    save_state.a[1, 1] = 2.
    save_state.c = numpy.int64(4)
    second_save_path = saver.save(prefix)

    load_state = _NumpyState()
    loader = util.Checkpoint(numpy=load_state)
    loader.restore(first_save_path).initialize_or_restore()
    self.assertAllEqual(numpy.ones([2, 2]), load_state.a)
    self.assertAllEqual(numpy.zeros([2, 2]), load_state.b)
    self.assertEqual(3, load_state.c)
    load_state.a[0, 0] = 42.
    self.assertAllEqual([[42., 1.], [1., 1.]], load_state.a)
    loader.restore(first_save_path).run_restore_ops()
    self.assertAllEqual(numpy.ones([2, 2]), load_state.a)
    loader.restore(second_save_path).run_restore_ops()
    self.assertAllEqual([[1., 1.], [1., 2.]], load_state.a)
    self.assertAllEqual(numpy.zeros([2, 2]), load_state.b)
    self.assertEqual(4, load_state.c)
开发者ID:adit-chandra,项目名称:tensorflow,代码行数:31,代码来源:python_state_test.py

示例15: test_numpy_scalar_conversion_values

 def test_numpy_scalar_conversion_values(self):
     self.assertEqual(nd.as_py(nd.array(np.bool_(True))), True)
     self.assertEqual(nd.as_py(nd.array(np.bool_(False))), False)
     self.assertEqual(nd.as_py(nd.array(np.int8(100))), 100)
     self.assertEqual(nd.as_py(nd.array(np.int8(-100))), -100)
     self.assertEqual(nd.as_py(nd.array(np.int16(20000))), 20000)
     self.assertEqual(nd.as_py(nd.array(np.int16(-20000))), -20000)
     self.assertEqual(nd.as_py(nd.array(np.int32(1000000000))), 1000000000)
     self.assertEqual(nd.as_py(nd.array(np.int64(-1000000000000))),
                      -1000000000000)
     self.assertEqual(nd.as_py(nd.array(np.int64(1000000000000))),
                      1000000000000)
     self.assertEqual(nd.as_py(nd.array(np.int32(-1000000000))),
                      -1000000000)
     self.assertEqual(nd.as_py(nd.array(np.uint8(200))), 200)
     self.assertEqual(nd.as_py(nd.array(np.uint16(50000))), 50000)
     self.assertEqual(nd.as_py(nd.array(np.uint32(3000000000))), 3000000000)
     self.assertEqual(nd.as_py(nd.array(np.uint64(10000000000000000000))),
                      10000000000000000000)
     self.assertEqual(nd.as_py(nd.array(np.float32(2.5))), 2.5)
     self.assertEqual(nd.as_py(nd.array(np.float64(2.5))), 2.5)
     self.assertEqual(nd.as_py(nd.array(np.complex64(2.5-1j))), 2.5-1j)
     self.assertEqual(nd.as_py(nd.array(np.complex128(2.5-1j))), 2.5-1j)
     if np.__version__ >= '1.7':
         self.assertEqual(nd.as_py(nd.array(np.datetime64('2000-12-13'))),
                          date(2000, 12, 13))
开发者ID:garaud,项目名称:dynd-python,代码行数:26,代码来源:test_numpy_interop.py


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