當前位置: 首頁>>代碼示例>>Python>>正文


Python histogram.Histogram類代碼示例

本文整理匯總了Python中histogram.Histogram的典型用法代碼示例。如果您正苦於以下問題:Python Histogram類的具體用法?Python Histogram怎麽用?Python Histogram使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Histogram類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_cut_2d

    def test_cut_2d(self):
        h2 = Histogram((100,[0,10]),(90,[-3,3]))
        #h2a = h2.cut((-1,1),axis=0)

        h3 = Histogram((100,[-30,330]), (100,[-50,50]))
        #h3a = h3.cut(-30,30,axis=0)
        h3b = h3.cut(270,330,axis=0)
開發者ID:theodoregoetz,項目名稱:histogram,代碼行數:7,代碼來源:test_histogram.py

示例2: producerLoop

def producerLoop(exclusiveUnprocessedFileQueue, processedHistogramBuffer, numProducers):
    '''
    loops through, each time grabs a file from the unprocessed queue
    and creates an individual histogram for that file.
    Then adds that histogram to the processed buffer
    for the consumer to acess
    '''
    global doneProducing

    #while not doneProducing:
    while not exclusiveUnprocessedFileQueue.isEmpty():    
        fileToProcess = exclusiveUnprocessedFileQueue.pop()

        if fileToProcess != None:  #none returned if unprocessed q was empty
            #makes individual file histogram
            fileHistogram = Histogram(fileToProcess)   
            fileHistogram.buildHistogram()
            processedHistogramBuffer.add(fileHistogram)
            itemsAvailable.release()
        else:
            continue

        producerProcessedLock.acquire()
        if exclusiveUnprocessedFileQueue.isEmpty() and not doneProducing:
            doneProducing = 1
        producerProcessedLock.release()
    #tells consumer that a thread is done processing
    itemsAvailable.release()
開發者ID:ctgowrie,項目名稱:Concurrent-Programming,代碼行數:28,代碼來源:word_histogram.py

示例3: _get_ping_property

def _get_ping_property(cursor, path):
    is_histogram = False
    is_keyed_histogram = False

    if path[0] == "histograms":
        is_histogram = True
    elif path[0] == "keyedHistograms":
        # Deal with histogram names that contain a slash...
        path = path[:2] + (["/".join(path[2:])] if len(path) > 2 else [])
        is_keyed_histogram = True

    for partial in path:
        cursor = cursor.get(partial, None)

        if cursor is None:
            break

    if cursor is None:
        return None
    if is_histogram:
        return Histogram(path[-1], cursor)
    elif is_keyed_histogram:
        histogram = Histogram(path[-2], cursor)
        histogram.name = "/".join(path[1:])
        return histogram
    else:
        return cursor
開發者ID:SamPenrose,項目名稱:python_moztelemetry,代碼行數:27,代碼來源:spark.py

示例4: _get_ping_property

def _get_ping_property(cursor, path, histograms_url, additional_histograms):
    is_histogram = False
    is_keyed_histogram = False

    if path[0] == "histograms":
        is_histogram = True
    elif path[0] == "keyedHistograms":
        # Deal with histogram names that contain a slash...
        path = path[:2] + (["/".join(path[2:])] if len(path) > 2 else [])
        is_keyed_histogram = True

    try:
        for field in path:
            cursor = cursor[field]
    except:
        return None

    if cursor is None:
        return None
    if is_histogram:
        return Histogram(path[-1], cursor, histograms_url=histograms_url,
                         additional_histograms=additional_histograms)
    elif is_keyed_histogram:
        histogram = Histogram(path[-2], cursor, histograms_url=histograms_url,
                              additional_histograms=additional_histograms)
        histogram.name = "/".join(path[-2:])
        return histogram
    else:
        return cursor
開發者ID:andymckay,項目名稱:python_moztelemetry,代碼行數:29,代碼來源:spark.py

示例5: __init__

    def __init__(self, dates, open, high, low, close, vol, start, end):
        
        if start > end:
            (start, end) = (end, start)
        
        self.report_log = []    
        
        max = None
        max_date = None
        min = None
        min_date = None
        
        seq_start = dates[0]
        seq_end = dates[0]
        
        series = []
        
        n = 0
     
        for i in range(len(dates)):    
         
            d = dates[i]
            if (d > start) and (d < end):      
                
                series.append(close[i])
                
                if (d < seq_start):
                    seq_start = d
                if (d > seq_end):
                    seq_end = d

                n = n + 1 
                
                h = high[i]
                if max == None:
                    max = h
                    max_date = d
                else:
                    if h > max:
                        max = h
                        max_date = d
                        
                l = low[i]
                if min == None:
                    min = l
                    min_date = d
                else:
                    if l < min:
                        min = l
                        min_date = d
        
        self.report_log.append('%s - %s' % (seq_start, seq_end))
        self.report_log.append('%d trading days' % n)
        self.report_log.append('Max = %s - %s' % (str(max), max_date))
        self.report_log.append('Min = %s - %s' % (str(min), min_date))
        
        h = Histogram(series)
        for l in h.report():
            self.report_log.append(l)
開發者ID:davidbarkhuizen,項目名稱:dart,代碼行數:59,代碼來源:OHLCVAnalysis.py

示例6: load_hue_histograms

 def load_hue_histograms(self):
     for h in self.known_histograms.keys():
         hist = Histogram()
         hist.load(self.known_histograms[h][0])
         self.known_histograms[h][1] = hist
     for h in self.known_histograms:
         print h
         print self.known_histograms[h][1]
開發者ID:EduFill,項目名稱:components,代碼行數:8,代碼來源:cube_color_detector.py

示例7: test_plot_hist2d

def test_plot_hist2d():
    npoints = 100000
    h2 = Histogram((100,(0,10),'x'),(100,(0,10),'y'),'z','title')
    h2.fill(rand.normal(5,2,npoints),
            rand.uniform(0,10,npoints))
    fig,ax = pyplot.subplots(1,2)
    ax[0].plothist(h2)
    ax[1].plothist(h2)
    ax[1].plothist(h2.smooth(1), style='contour', overlay=True)

    pyplot.savefig('test_images/test_plotting_fig_hist2d.png')
開發者ID:theodoregoetz,項目名稱:histogram,代碼行數:11,代碼來源:test_plotting.py

示例8: test_1dfit

    def test_1dfit(self):
        p = [100, -20, 1, -0.2]
        h = Histogram(100, [0, 10])
        x = h.axes[0].bincenters
        h.data = poly(p)(x) + rand.normal(0, np.sqrt(p[0]), len(x))

        p0 = [1, 1, 1, 1]
        popt, pcov, ptest = h.fit(lambda x, *p: poly(p)(x), p0)

        assert np.allclose(popt, p, rtol=0.03, atol=0.5)
        assert pcov.shape == (len(p), len(p))
開發者ID:theodoregoetz,項目名稱:histogram,代碼行數:11,代碼來源:test_fitting.py

示例9: test_plot_hist1d

def test_plot_hist1d():
    npoints = 100000
    h1 = Histogram(100,(0,10),'x','y','title')
    h1.fill(rand.normal(5,2,npoints))

    fig,ax = pyplot.subplots(2,2)
    ax[0,0].plothist(h1, style='polygon' , baseline='bottom')
    ax[0,1].plothist(h1, style='errorbar', baseline='bottom')
    ax[1,0].plothist(h1, style='polygon' )#, baseline='left')
    ax[1,1].plothist(h1, style='errorbar')#, baseline='left')

    pyplot.savefig('test_images/test_plotting_fig_hist1d.png')
開發者ID:theodoregoetz,項目名稱:histogram,代碼行數:12,代碼來源:test_plotting.py

示例10: HistogramTest

class HistogramTest(unittest.TestCase):

    def setUp(self):
        self.h = Histogram()
        self.h.add("Apache")
        self.h.add("Apache")

    def test_add(self):
        assert self.h.get_dict().get("Apache") is not None

    def test_count(self):
        self.assertEqual(self.h.count("Apache"), 2)
開發者ID:ivannborisov,項目名稱:Programming-101-v3,代碼行數:12,代碼來源:histogram_test.py

示例11: test_2dfit

    def test_2dfit(self):
        fn = lambda xy, *p: poly(p[:4])(xy[0]) + poly([0] + list(p[4:]))(xy[1])
        p = [100, -20, 1, -0.2, 80, -5, 0.8]
        h = Histogram(100, [0, 10], 100, [0, 10])
        xy = h.grid
        h.data = fn(xy, *p)
        h.data += rand.normal(0, np.sqrt(p[0]), h.data.shape)

        p0 = [1, 1, 1, 1, 1, 1, 1]
        popt, pcov, ptest = h.fit(fn, p0)

        assert np.allclose(popt, p, rtol=0.01, atol=0.01)
        assert pcov.shape == (len(p), len(p))
開發者ID:theodoregoetz,項目名稱:histogram,代碼行數:13,代碼來源:test_fitting.py

示例12: test_1dfit_zeros

    def test_1dfit_zeros(self):
        p = [100, -20, 1, -0.2]
        h = Histogram(100, [0, 10])
        x = h.axes[0].bincenters
        h.data = poly(p)(x) + rand.normal(0, np.sqrt(p[0]), len(x))

        ii = rand.randint(0, h.axes[0].nbins, 5)
        h.data[ii] = 0

        p0 = [1, 1, 1, 1]
        popt, pcov, ptest = h.fit(lambda x, *p: poly(p)(x), p0)

        assert np.allclose(popt, p, rtol=0.1, atol=1.0)
        assert pcov.shape == (len(p), len(p))
開發者ID:theodoregoetz,項目名稱:histogram,代碼行數:14,代碼來源:test_fitting.py

示例13: test_mean

    def test_mean(self):
        h = Histogram(10,[0,10])
        h.fill([3,3,3])
        assert_almost_equal(h.mean()[0],3.5)

        h.fill([1,5])
        assert_almost_equal(h.mean()[0],3.5)
開發者ID:theodoregoetz,項目名稱:histogram,代碼行數:7,代碼來源:test_histogram.py

示例14: test_rebin

 def test_rebin(self):
     h = Histogram(10,[0,10])
     h.set(1)
     hexpect = Histogram(5,[0,10])
     hexpect.set(2)
     hrebin = h.rebin(2)
     assert_array_almost_equal(hrebin.data, hexpect.data)
     assert_array_almost_equal(hrebin.axes[0].edges, hexpect.axes[0].edges)
開發者ID:theodoregoetz,項目名稱:histogram,代碼行數:8,代碼來源:test_histogram.py

示例15: test_hdf5

 def test_hdf5(self):
     try:
         import h5py
         h = self.h.clone()
         filename = 'h.hdf5'
         h.save(filename)
         hh = Histogram.load(filename)
         assert h.isidentical(hh)
     except ImportError:
         pass
開發者ID:theodoregoetz,項目名稱:histogram,代碼行數:10,代碼來源:test_serialization.py


注:本文中的histogram.Histogram類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。