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


Python DB.count方法代碼示例

本文整理匯總了Python中db.DB.count方法的典型用法代碼示例。如果您正苦於以下問題:Python DB.count方法的具體用法?Python DB.count怎麽用?Python DB.count使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在db.DB的用法示例。


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

示例1: animate_density_plot

# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import count [as 別名]
def animate_density_plot(f, frames, precision=50, **kw):
    """
    """
    db = DB()
    total = db.count(f)
    n = int(total // frames)

    lst = list()

    ymax = 0
    for i in range(frames - 1):
        stop = (i + 1) * n
        lst.append(density(f, precision, stop=stop))

        if ymax < lst[-1].get_minmax_data()['ymax']:
            ymax = lst[-1].get_minmax_data()['ymax']

    lst.append(density(f, precision))

    # Plot options
    plot_opts = {'xmin': kw.get('xmin'),
                 'xmax': kw.get('xmax'),
                 'ymin': kw.get('ymin', 0),
                 'ymax': kw.get('ymax', ymax)}

    return animate(lst, **plot_opts)
開發者ID:barumrho,項目名稱:sage_polynomial,代碼行數:28,代碼來源:plots.py

示例2: plot

# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import count [as 別名]
    def plot(self):
        # Keyworded arugments
        start = kw.get('start', 0)
        stop = kw.get('stop')
        showlines = kw.get('showlines', True)
        showlabel = kw.get('showlabel', True)
        traces = kw.get('traces', 0)

        # Plot options
        plot_opts = {'xmin': kw.get('xmin'),
                     'xmax': kw.get('xmax'), 
                     'ymin': kw.get('ymin', 0.75 / precision), 
                     'ymax': kw.get('ymax', 1.25 / precision), 
                     'markersize': kw.get('markersize', 3)}

        db = DB()
        last_prime = db.last_prime(f)
        total = db.count(f, True, type_=type_)
        interval = 1 / precision

        # Calculate points where we take snapshots to show traces
        snapshots = list()
        unit = total // (traces + 1)
        for n in range(traces):
            snapshots.append(unit * (n + 1))

        snapshots.append(total)

        plot = scatter_plot([])
        counts = [0, ] * precision
        n = 0
        for p in db.roots_by_partition(f, precision, type_):
            counts[p] += 1

            if n == snapshots[0]:
                del snapshots[0]
                plot += plot_density([i / n for i in counts], 
                                     alpha=(n/total), **plot_opts)
            n += 1

        plot += plot_density([i / total for i in counts], show_lines=True,  **plot_opts)

        self.plot = plot
開發者ID:barumrho,項目名稱:sage_polynomial,代碼行數:45,代碼來源:plots.py

示例3: __init__

# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import count [as 別名]
    def __init__(self, f, **kw):
        """Create a density plot.

        Arguments:
        f -- Polynomial in database
        precision -- Number of bins
        type_ -- Type of roots

        Keyword Arguments:
        
        """
        self.f = f
        self.degree = f.degree()
        self.group = f.galois_group()._n
        
        self.precision = kw.get("precision", self.defaults["precision"])
        self.type_ = type_

        db = DB()
        self.count = db.count(f)
        self.last_prime = db.last_prime(f)
開發者ID:barumrho,項目名稱:sage_polynomial,代碼行數:23,代碼來源:plots.py


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