• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python numpy.float128函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: calcPosteriorProb

    def calcPosteriorProb(self, dir, priors, condProb):

         totalCmap = {}
         # vocabCalc = VocabularyCalculator()
         # vocabCalc.calculate(dir)
         #
         # print "Test class vocab count: ", vocabCalc.getClassVocabCount()
         testDir = "earn"
         for classDir in os.listdir(dir):
             # if classDir == testDir:
             if 1:
                 numberOfFiles = len(os.listdir(os.path.join(dir, classDir)))
                 correctClassEstimation = 0
                 for filename in os.listdir(os.path.join(dir, classDir)):
                     docVocab = {}
                     currentCmap = {}
                     testFile = open(os.path.join(dir, classDir, filename), "r")

                     for line in testFile:
                         words = line.split()

                         for word in words:
                             if word in docVocab:
                                 docVocab[word] += 1
                             else:
                                 docVocab[word] = 1


                     # calculate currentCmap
                     totalCmap[filename] = {}
                     tempFile = open("temp.txt", "w")
                     for trainClass, classPrior in priors.iteritems():
                         prod = np.float128(1.0)

                         for word, count in docVocab.iteritems():
                             # print word, count
                             if word in condProb[trainClass]:
                                 prod = prod * condProb[trainClass][word]
                                 # print prod
                                 # if condProb[trainClass][word] == 0.0:
                                 # print trainClass, word, condProb[trainClass][word]
                                 tempFile.write(trainClass + " " + word + " " + str(condProb[trainClass][word]) + " "
                                                + str(prod))
                                 tempFile.write("\n")


                         currentCmap[trainClass] = prod * np.float128(classPrior)

                     totalCmap[filename] = currentCmap
                     estimatedClass = max(currentCmap.iteritems(), key=operator.itemgetter(1))[0]
                     # print "Actual file class: ", classDir, ", Estimated file class: " , estimatedClass
                     # print "\n"
                     if(estimatedClass == testDir):
                         correctClassEstimation += 1

                 accuracy = (correctClassEstimation / numberOfFiles) * 100
                 print "Accuracy for ", classDir, ": ", accuracy, "%"


         return totalCmap
开发者ID:girishc13,项目名称:Python-ML,代码行数:60,代码来源:PosteriorProbabilityCalculator.py


示例2: _data_to_file

    def _data_to_file(self, data):
        # process the datatypes
        if self.file_dtype is None:
            # load from data
            self.file_dtype = data.dtype
        else:
            # make sure it's a dtype
            if not isinstance(self.file_dtype, np.dtype):
                try:
                    self.file_dtype = np.dtype(self.file_dtype)
                except:
                    ValueError("file_dtype should be a numpy dtype.")

        # process the gain
        if self.gain is None:
            # default to 1.0
            self.gain = 1.0
            # calc it if we are going from float to int
            if (self.file_dtype.kind == 'i') and (self.data_dtype.kind == 'f'):
                fr = np.float128(np.iinfo(self.file_dtype).max*2)
                dr = np.float128(np.abs(data).max()*2 * (1.+self.gain_buffer))
                self.gain = np.float64(dr/fr)
                
        # calc and apply gain if necessary
        if self.apply_gain and self.gain != 1.0:
            return np.asarray(data/self.gain,dtype=self.file_dtype)
        else:
            return np.asarray(data,dtype=self.file_dtype)
开发者ID:maciekswat,项目名称:ptsa,代码行数:28,代码来源:hdf5wrapper.py


示例3: sec_ord_corr

def sec_ord_corr(chains,t1,emission_symbol_1,t2,emission_symbol_2):
    
    ones_at_t1_t2 = 0
    ones_at_t1 = 0
    ones_at_t2 = 0
    
    for i in range(0,len(chains)): 
        a_t1 = chains[i][t1]
        b_t1 = emission_symbol_1
        
        a_t2 = chains[i][t2]
        b_t2 = emission_symbol_2

        if a_t1 == b_t1:
            ones_at_t1 += 1
        
        if a_t2 == b_t2:
            ones_at_t2 += 1

        if a_t1 == b_t1 and a_t2 == b_t2:
            ones_at_t1_t2 += 1
    try:
        soc = (np.float128(ones_at_t1_t2) / ones_at_t1) /  (np.float128(ones_at_t2) / len(chains))
    except ZeroDivisionError:
        soc = np.Inf
    return soc
开发者ID:mmubashirkhan,项目名称:QHMM_Simulation,代码行数:26,代码来源:QHMM_V6.py


示例4: test_numpy

    def test_numpy(self):
        assert chash(np.bool_(True)) == chash(np.bool_(True))

        assert chash(np.int8(1)) == chash(np.int8(1))
        assert chash(np.int16(1))
        assert chash(np.int32(1))
        assert chash(np.int64(1))

        assert chash(np.uint8(1))
        assert chash(np.uint16(1))
        assert chash(np.uint32(1))
        assert chash(np.uint64(1))

        assert chash(np.float32(1)) == chash(np.float32(1))
        assert chash(np.float64(1)) == chash(np.float64(1))
        assert chash(np.float128(1)) == chash(np.float128(1))

        assert chash(np.complex64(1+1j)) == chash(np.complex64(1+1j))
        assert chash(np.complex128(1+1j)) == chash(np.complex128(1+1j))
        assert chash(np.complex256(1+1j)) == chash(np.complex256(1+1j))

        assert chash(np.datetime64('2000-01-01')) == chash(np.datetime64('2000-01-01'))
        assert chash(np.timedelta64(1,'W')) == chash(np.timedelta64(1,'W'))

        self.assertRaises(ValueError, chash, np.object())

        assert chash(np.array([[1, 2], [3, 4]])) == \
            chash(np.array([[1, 2], [3, 4]]))
        assert chash(np.array([[1, 2], [3, 4]])) != \
            chash(np.array([[1, 2], [3, 4]]).T)
        assert chash(np.array([1, 2, 3])) == chash(np.array([1, 2, 3]))
        assert chash(np.array([1, 2, 3], dtype=np.int32)) != \
            chash(np.array([1, 2, 3], dtype=np.int64))
开发者ID:lebedov,项目名称:chash,代码行数:33,代码来源:test_chash.py


示例5: fisher

		def fisher(theta, i, j = None):
			"""
			Fisher information using the first order derivative

			:param theta: the theta of the density
			:param i: The ith component of the diagonal of the fisher information matrix will be returned (if j is None)
			:param j: The i,j th component of the fisher information matrix will be returned
			"""

			#Bring it in a form that we can derive
			fh = lambda ti, t0, tn, x: np.log(self.density(x, list(t0) + [ti] + list(tn)))

			# The derivative
			f_d_theta_i = lambda x: derivative(fh, theta[i], dx=1e-5, n=1, args=(theta[0:i], theta[i + 1:], x))

			if j is not None:
				f_d_theta_j = lambda x: derivative(fh, theta[j], dx=1e-5, n=1, args=(theta[0:j], theta[j + 1:], x))
				f = lambda x: np.float128(0) if fabs(self.density(x, theta)) < 1e-5 else f_d_theta_i(x) * f_d_theta_j(x) * self.density(x, theta)
			else:
				# The function to integrate
				f = lambda x: np.float128(0) if fabs(self.density(x, theta)) < 1e-5 else f_d_theta_i(x) ** 2 * self.density(x, theta)


			#First order
			result = integrate(f, self.support)
			return result
开发者ID:snphbaum,项目名称:scikit-gpuppy,代码行数:26,代码来源:MLE.py


示例6: alignRec

def alignRec(record, template=template, bgfile='image_Ch1.nrrd', alignSet='', threshold=0.6):
    record = checkDir(record)
    record['last_host'] = host
    print 'Finalising alignment for: ' + record['name']
    # bgfile = record['original_nrrd'][('Ch' + str(record['background_channel']) + '_file')]
    record['aligned_bg'], r = cmtk.align(bgfile, template=template, settings=alignSet)
    record['aligned_avgslice_score'] = str(
        ci.rateOne(record['aligned_bg'], results=None, methord=slicescore.avgOverlapCoeff, template=template))
    record['aligned_slice_score'] = str(
        ci.rateOne(record['aligned_bg'], results=None, methord=slicescore.OverlapCoeff, template=template))
    record['aligned_score'] = str(
        np.mean([np.float128(record['aligned_avgslice_score']), np.float128(record['aligned_slice_score'])]))
    # Note: np.float128 array score converted to string as mongoDB only supports float(64/32 dependant on machine).
    record['aligned_bg'] = str(record['aligned_bg']).replace(tempfolder, '')
    print 'Result: ' + record['aligned_score']
    if record['aligned_score'] > threshold:
        record['alignment_stage'] = 6
        print 'Passed!'
    else:
        record['alignment_stage'] = 0
        print 'Failed!'
    if r > 0:
        print 'Error Code:' + str(r)
        record['alignment_stage'] = 0
    record['max_stage'] = 6
    return record
开发者ID:Robbie1977,项目名称:AlignmentPipe,代码行数:26,代码来源:align.py


示例7: parse_vecfile

def parse_vecfile(a_fname):
    """Parse files containing word vectors

    @param a_fname - name of the wordvec file

    @return \c dimension of the vectors
    """
    global POS, NEG
    ivec = None
    with codecs.open(a_fname, 'r', ENCODING) as ifile:
        fnr = True
        toks = None
        for iline in ifile:
            iline = iline.strip()
            if fnr:
                ndim = int(iline.split()[-1])
                fnr = False
                continue
            elif not iline:
                continue
            toks = iline.split()
            assert (len(toks) - 1) == ndim, "Wrong vector dimension: {:d}".format(\
                len(toks) - 1)
            if toks[0] in POS:
                ivec = np.array([np.float128(i) for i in toks[1:]])
                # ivec /= _get_vec_len(ivec)
                POS[toks[0]] = ivec
            elif toks[0] in NEG:
                ivec = np.array([np.float128(i) for i in toks[1:]])
                # ivec /= _get_vec_len(ivec)
                NEG[toks[0]] = ivec
    # prune words for which there were no vectors
    POS = {iword: ivec for iword, ivec in POS.iteritems() if ivec is not None}
    NEG = {iword: ivec for iword, ivec in NEG.iteritems() if ivec is not None}
    return ndim
开发者ID:WladimirSidorenko,项目名称:SentiLex,代码行数:35,代码来源:find_prj_line.py


示例8: main

def main():
    g  = geolocation_table('128.173.90.68')
    g.start_db()

    l= []
    start = g.get_start()
    end = g.get_end()

    i = start
    while ( i <= end ):
        data = g.get_data(i)
        loc = data[6]
        loc = loc.strip(' ()')        # format location
        loc = loc.split(',')
        loc[0] = np.float128(loc[0])
        loc[1] = np.float128(loc[1])
        l.append(loc)
        i += 1

    g.stop_db()


    # print l[0]
    # print 'type(l[0]): ',type(l[0][0])

    kml_write = sdr_kml_writer.kml_writer()
    kml_write.add_colored_pushpin('red-pushpin','ff0000ff')
    n = 1
    for i in l:
        s = 'Guess' + str(n)
        kml_write.add_placemark(s,s,i,'red-pushpin')
        n += 1
    filename = 'guesses_degen.kml'
    kml_write.write_to_file(filename)
开发者ID:saschayoung,项目名称:fessenden,代码行数:34,代码来源:plot_guesses.py


示例9: _merge_trigger_into

def _merge_trigger_into(trigger, cluster):
    trigger_snr = trigger["snr"]

    cluster['time_min'] = min(trigger['time_min'], cluster['time_min'])
    cluster['time_max'] = max(trigger['time_max'], cluster['time_max'])
    cluster['freq_min'] = min(trigger['freq_min'], cluster['freq_min'])
    cluster['freq_max'] = max(trigger['freq_max'], cluster['freq_max'])

    if trigger_snr > cluster['snr']:
        cluster['time'] = trigger['time']
        cluster['freq'] = trigger['freq']
        cluster['snr'] = trigger_snr
        cluster['amplitude'] = max(trigger['amplitude'], cluster['amplitude'])
        cluster['q'] = max(trigger['q'], cluster['q'])

    cluster["trigger_count"] += trigger.get("trigger_count", 1)
    cluster["weighted_time"] += trigger.get("weighted_time", 
                                            trigger_snr
                                            *np.float128(trigger["time"]))
    cluster["weighted_freq"] += trigger.get("weighted_freq", 
                                            trigger_snr
                                            *np.float128(trigger["freq"]))
    cluster["snr_sum"] += trigger.get("snr_sum", trigger_snr)

    return cluster
开发者ID:chase-ok,项目名称:lsc-seis-gcm,代码行数:25,代码来源:triggers.py


示例10: calc_ev_dos

 def calc_ev_dos(self, ev_from=-100, ev_to=20, delta=0.01, sigma=0.1):
   """
   Calculates dos of electronic eigenvalues    
   
   """
   
   success = True
   error = ""
   
   if ((self.eigenvalues is None) and (self.evs_up is None) and (self.evs_down is None)):
     success = False
     error = "Eigenvalues were not read in"
     
     return success, error
   
   _extraBins = 2
 
   # get min and max 
   ev_dos_min = np.float128(ev_from)
   ev_dos_max = np.float128(ev_to)
       
   # number of bins
   ev_dos_n_bins = np.around(int((ev_dos_max - ev_dos_min) / delta) + _extraBins, decimals=0)
       
   # array to hold the ev bin values
   ev_dos_bins = np.arange(ev_dos_min, np.around(ev_dos_min + ev_dos_n_bins * delta, decimals=4), delta)
   self.ev_dos_bins = copy.deepcopy(ev_dos_bins)
   
   if (self.eigenvalues is not None):
     # array for the dos values
     ev_dos = np.zeros(ev_dos_n_bins, dtype=np.float128) 
         
     # calculating DOS
     for i in range(ev_dos_n_bins):
       ev_dos[i] = np.sum((1/(sigma*np.pi**0.5)) * np.exp(-(ev_dos_bins[i] - self.eigenvalues)**2 / sigma**2))
     
     self.ev_dos = copy.deepcopy(ev_dos)
   
   if (self.evs_up is not None):
     # array for the dos values
     ev_dos = np.zeros(ev_dos_n_bins, dtype=np.float128) 
         
     # calculating DOS
     for i in range(ev_dos_n_bins):
       ev_dos[i] = np.sum((1/(sigma*np.pi**0.5)) * np.exp(-(ev_dos_bins[i] - self.evs_up)**2 / sigma**2))
     
     self.ev_up_dos = copy.deepcopy(ev_dos)
   
   if (self.evs_down is not None):
     # array for the dos values
     ev_dos = np.zeros(ev_dos_n_bins, dtype=np.float128) 
         
     # calculating DOS
     for i in range(ev_dos_n_bins):
       ev_dos[i] = np.sum((1/(sigma*np.pi**0.5)) * np.exp(-(ev_dos_bins[i] - self.evs_down)**2 / sigma**2))
     
     self.ev_down_dos = copy.deepcopy(ev_dos)
    
   return success, error
开发者ID:tomaslaz,项目名称:KLMC_Analysis,代码行数:59,代码来源:System.py


示例11: unpack_time

def unpack_time(payload):
################################################################################
    (t_c,) = struct.unpack('!I', payload[0:4])
    (t_m,) = struct.unpack('!d', payload[4:12])

    t = repr(np.float128(t_c) + np.float128(t_m))

    return t
开发者ID:saschayoung,项目名称:fessenden,代码行数:8,代码来源:pack_utils.py


示例12: get_i

def get_i(k, I):
    assert k >= 0
    assert 1 >= I >= 0
    if k == 1:
        return I
    else:
        k = np.float128(k)
        I = np.float128(I)
        return np.log(I * (k - 1) + 1) / np.log(k)
开发者ID:docBase,项目名称:macg,代码行数:9,代码来源:__init__.py


示例13: foldlight

 def foldlight(self,period,nbins,ephemeris=0):
     '''
     folds a lightcurve on a known linear ephemeris
     v1.0 Kieran O'Brien - Dec 2011
     '''
     phase=(self.obstimes-np.float128(ephemeris))/np.float128(period)
     phase=phase-phase.astype('int')
     self.phase,self.phasebins=np.histogram(phase,nbins)
     return
开发者ID:RupertDodkins,项目名称:ARCONS-pipeline-1,代码行数:9,代码来源:ARCONS_Cubes.py


示例14: test_ppc64_ibm_double_double128

    def test_ppc64_ibm_double_double128(self):
        # check that the precision decreases once we get into the subnormal
        # range. Unlike float64, this starts around 1e-292 instead of 1e-308,
        # which happens when the first double is normal and the second is
        # subnormal.
        x = np.float128('2.123123123123123123123123123123123e-286')
        got = [str(x/np.float128('2e' + str(i))) for i in range(0,40)]
        expected = [
            "1.06156156156156156156156156156157e-286",
            "1.06156156156156156156156156156158e-287",
            "1.06156156156156156156156156156159e-288",
            "1.0615615615615615615615615615616e-289",
            "1.06156156156156156156156156156157e-290",
            "1.06156156156156156156156156156156e-291",
            "1.0615615615615615615615615615616e-292",
            "1.0615615615615615615615615615615e-293",
            "1.061561561561561561561561561562e-294",
            "1.06156156156156156156156156155e-295",
            "1.0615615615615615615615615616e-296",
            "1.06156156156156156156156156e-297",
            "1.06156156156156156156156157e-298",
            "1.0615615615615615615615616e-299",
            "1.06156156156156156156156e-300",
            "1.06156156156156156156155e-301",
            "1.0615615615615615615616e-302",
            "1.061561561561561561562e-303",
            "1.06156156156156156156e-304",
            "1.0615615615615615618e-305",
            "1.06156156156156156e-306",
            "1.06156156156156157e-307",
            "1.0615615615615616e-308",
            "1.06156156156156e-309",
            "1.06156156156157e-310",
            "1.0615615615616e-311",
            "1.06156156156e-312",
            "1.06156156154e-313",
            "1.0615615616e-314",
            "1.06156156e-315",
            "1.06156155e-316",
            "1.061562e-317",
            "1.06156e-318",
            "1.06155e-319",
            "1.0617e-320",
            "1.06e-321",
            "1.04e-322",
            "1e-323",
            "0.0",
            "0.0"]
        assert_equal(got, expected)

        # Note: we follow glibc behavior, but it (or gcc) might not be right.
        # In particular we can get two values that print the same but are not
        # equal:
        a = np.float128('2')/np.float128('3')
        b = np.float128(str(a))
        assert_equal(str(a), str(b))
        assert_(a != b)
开发者ID:Jengel1,项目名称:SunriseSunsetTimeFinder,代码行数:57,代码来源:test_scalarprint.py


示例15: get_I

def get_I(k, i):
    assert k >= 0
    assert 1 >= i >= 0
    if k == 1:
        return i
    else:
        k = np.float128(k)
        i = np.float128(i)
        return (pow(k, i) - 1) / (k-1)
开发者ID:docBase,项目名称:macg,代码行数:9,代码来源:__init__.py


示例16: test_legendre_gauss_lobatto_nodes_weights

def test_legendre_gauss_lobatto_nodes_weights():
    from polynomials import legendre_gauss_lobatto_nodes_weights as gll

    # n = 6 
    x_ref = numpy.float128([-1, -0.830223896278567, -0.468848793470714, 0])
    w_ref = numpy.float128( \
            [0.04761904761904762, 0.276826047361566, 0.431745381209863, 0.487619047619048])
    x, w = gll(6)
    aaae(x_ref, x[:4], 15, 'n=6, x')
    aaae(w_ref, w[:4], 15, 'n=6, w')
开发者ID:wbkifun,项目名称:my_stuff,代码行数:10,代码来源:test_polynomials.py


示例17: _loadTrailer

def _loadTrailer(tree):
    output = []
    all_trailers_element = tree.xpath("/IRP_Roadef_Challenge_Instance/trailers/IRP_Roadef_Challenge_Instance_Trailers")
    for trailer_element in all_trailers_element:
        index = int(trailer_element.find("index").text)
        capacity = np.float128(trailer_element.find("Capacity").text)
        initial_quantity = np.float128(trailer_element.find("InitialQuantity").text)
        distance_cost = float(trailer_element.find("DistanceCost").text)
        output.append(Trailer(index, capacity, initial_quantity, distance_cost))
    return output;
开发者ID:mmPaumard,项目名称:MAOA,代码行数:10,代码来源:instance_loader.py


示例18: convert_quad_sum

def convert_quad_sum(arr1, arr2):
    qsum1 = numpy.float128(0)
    qsum2 = numpy.float128(0)
    for i in xrange(nx):
        qsum1 += numpy.float128(arr1[i])
        qsum2 += numpy.float128(arr2[i])

    sum1 = numpy.float64(qsum1)
    sum2 = numpy.float64(qsum2)

    return sum1, sum2
开发者ID:wbkifun,项目名称:my_stuff,代码行数:11,代码来源:reproducible_sum.py


示例19: EqFTh

def EqFTh(x,pars):
    Ncell = pars[0]
    #Nsrc = pars[2]
    Nc=Ncell
    FAP_ = pars[1]
    Nsrc = pars[2]
    #return 1.-(1.-(1.+x)*np.exp(-x))**(Nc)-FAP_
    sumx=(1.+x)
    for i in range(2,2*Nsrc):
        sumx = sumx + x**i * invfactorial[i]
    return Nc*np.log(np.float128(1.)-np.float128(sumx*np.exp(-x)))-np.log(1.-FAP_)
开发者ID:pabloarosado,项目名称:RosadoSesanaGair2015,代码行数:11,代码来源:ComputeFeTh.py


示例20: bigkahansum

def bigkahansum(a):
    b = np.float128(0.0)
    c = np.float128(0.0)
    y = np.float128(0.0)
    t = np.float128(0.0)
    for i in xrange(a.size):
        y = a[i] - c
        t = b + y
        c = (t - b) - y
        b = t
    return b
开发者ID:IAlibay,项目名称:algorithms,代码行数:11,代码来源:sumtest.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python numpy.float16函数代码示例发布时间:2022-05-27
下一篇:
Python numpy.float函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap