本文整理匯總了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)
示例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
示例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)