本文整理匯總了Python中pyprind.ProgBar方法的典型用法代碼示例。如果您正苦於以下問題:Python pyprind.ProgBar方法的具體用法?Python pyprind.ProgBar怎麽用?Python pyprind.ProgBar使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pyprind
的用法示例。
在下文中一共展示了pyprind.ProgBar方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: validate
# 需要導入模塊: import pyprind [as 別名]
# 或者: from pyprind import ProgBar [as 別名]
def validate(self):
"""
Runs Instrument.validate for every Instrument in the Portfolio and returns a DataFrame. Used for trading.
"""
import concurrent.futures
bar = pyprind.ProgBar(len(self.instruments.values()), title='Validating instruments')
with concurrent.futures.ThreadPoolExecutor(max_workers=2) as executor:
dl = {executor.submit(x.validate): x.name for x in self.instruments.values()}
d = {}
for fut in concurrent.futures.as_completed(dl):
bar.update(item_id=dl[fut])
d[dl[fut]] = fut.result()
d = pd.DataFrame(d).transpose()
# blacklist instruments that didn't pass validation
self.inst_blacklist = d[d['is_valid'] == False].index.tolist()
return d
示例2: main
# 需要導入模塊: import pyprind [as 別名]
# 或者: from pyprind import ProgBar [as 別名]
def main(sname, iteration, cropped, full, flipped, force, dataset, storage_name):
new_name = '%s-%d' % (sname, iteration)
if dataset == 'segmented':
cub = CUB_200_2011_Segmented(settings.CUB_ROOT, full=full)
elif dataset == 'part-head':
cub = CUB_200_2011_Parts_Head(settings.CUB_ROOT, full=full)
elif dataset == 'part-body':
cub = CUB_200_2011_Parts_Body(settings.CUB_ROOT, full=full)
elif dataset == 'part-head-rf-new':
cub = CUB_200_2011(settings.CUB_ROOT, 'images_head_rf_new')
elif dataset == 'part-body-rf-new':
cub = CUB_200_2011(settings.CUB_ROOT, 'images_body_rf_new')
else:
cub = CUB_200_2011(settings.CUB_ROOT, images_folder_name=dataset, full=full)
if not storage_name:
ft_storage = datastore(settings.storage(new_name))
else:
ft_storage = datastore(settings.storage(storage_name))
ft_extractor = CNN_Features_CAFFE_REFERENCE(ft_storage, model_file=settings.model(new_name), pretrained_file=settings.pretrained(new_name), full=full, crop_index=0)
number_of_images_in_dataset = sum(1 for _ in cub.get_all_images())
bar = pyprind.ProgBar(number_of_images_in_dataset, width=80)
for t, des in ft_extractor.extract_all(cub.get_all_images(), flip=flipped, crop=cropped, bbox=cub.get_bbox(), force=force):
bar.update()
print 'DONE'
示例3: delete_instances
# 需要導入模塊: import pyprind [as 別名]
# 或者: from pyprind import ProgBar [as 別名]
def delete_instances(self, verbose=False):
"""
deletes all associated resource instances
"""
if verbose is True:
bar = pyprind.ProgBar(Resource.objects.filter(graph_id=self.graphid).count())
for resource in Resource.objects.filter(graph_id=self.graphid):
resource.delete()
if verbose is True:
bar.update()
if verbose is True:
print(bar)
示例4: generate_zincid_smile_csv
# 需要導入模塊: import pyprind [as 別名]
# 或者: from pyprind import ProgBar [as 別名]
def generate_zincid_smile_csv(zincid_list, out_file,
print_progress_bar=True, backend='zinc12'):
"""
Generates a CSV file of ZINC_ID,SMILE_string entries
by querying the ZINC online database.
Keyword arguments:
zincid_list (str): Path to a UTF-8 or ASCII formatted file
that contains 1 ZINC_ID per row. E.g.,
ZINC0000123456
ZINC0000234567
[...]
out_file (str): Path to a new output CSV file that will be written.
print_prgress_bar (bool): Prints a progress bar to the screen if True.
"""
id_smile_pairs = []
with open(zincid_list, 'r') as infile:
all_lines = infile.readlines()
if print_progress_bar:
pbar = pyprind.ProgBar(len(all_lines), title='Downloading SMILES')
for line in all_lines:
line = line.strip()
id_smile_pairs.append((line, get_zinc_smile(line,
backend=backend)))
if print_progress_bar:
pbar.update()
with open(out_file, 'w') as out:
for p in id_smile_pairs:
out.write('{},{}\n'.format(p[0], p[1]))
示例5: example_3
# 需要導入模塊: import pyprind [as 別名]
# 或者: from pyprind import ProgBar [as 別名]
def example_3():
n = 1000000
my_bar = pyprind.ProgBar(n, stream=1, title='example3', monitor=True)
for i in range(n):
# do some computation
my_bar.update()
print(my_bar)
示例6: example_2
# 需要導入模塊: import pyprind [as 別名]
# 或者: from pyprind import ProgBar [as 別名]
def example_2():
n = 1000000
my_bar = pyprind.ProgBar(n, stream=1, width=30, track_time=True, title='My Progress Bar', monitor=True)
for i in range(n):
# do some computation
my_bar.update()
print('\n\nPrint tracking object ...\n')
print(my_bar)
示例7: example_1
# 需要導入模塊: import pyprind [as 別名]
# 或者: from pyprind import ProgBar [as 別名]
def example_1():
n = 1000000
my_bar = pyprind.ProgBar(n, width=40, stream=2)
for i in range(n):
my_bar.update()
示例8: example_1
# 需要導入模塊: import pyprind [as 別名]
# 或者: from pyprind import ProgBar [as 別名]
def example_1():
n = 1000000
my_bar = pyprind.ProgBar(n, stream=1)
for i in range(n):
# do some computation
my_bar.update()
示例9: test_bar
# 需要導入模塊: import pyprind [as 別名]
# 或者: from pyprind import ProgBar [as 別名]
def test_bar():
bar = pyprind.ProgBar(n)
for i in range(n):
time.sleep(sleeptime)
bar.update()
示例10: test_monitoring
# 需要導入模塊: import pyprind [as 別名]
# 或者: from pyprind import ProgBar [as 別名]
def test_monitoring():
bar = pyprind.ProgBar(n, monitor=True)
for i in range(n):
time.sleep(sleeptime)
bar.update()
print(bar)
示例11: test_width
# 需要導入模塊: import pyprind [as 別名]
# 或者: from pyprind import ProgBar [as 別名]
def test_width():
bar = pyprind.ProgBar(n, width=10)
for i in range(n):
time.sleep(sleeptime)
bar.update()
示例12: test_item_tracking
# 需要導入模塊: import pyprind [as 別名]
# 或者: from pyprind import ProgBar [as 別名]
def test_item_tracking():
items = ['file_%s.csv' % i for i in range(0, n)]
bar = pyprind.ProgBar(len(items))
for i in items:
time.sleep(sleeptime)
bar.update(item_id=i)
示例13: test_character
# 需要導入模塊: import pyprind [as 別名]
# 或者: from pyprind import ProgBar [as 別名]
def test_character():
bar = pyprind.ProgBar(n, bar_char='>')
for i in range(n):
time.sleep(sleeptime)
bar.update()
示例14: test_force_flush
# 需要導入模塊: import pyprind [as 別名]
# 或者: from pyprind import ProgBar [as 別名]
def test_force_flush():
bar = pyprind.ProgBar(n)
for i in range(n):
time.sleep(sleeptime)
bar.update(force_flush=True)
示例15: download_all
# 需要導入模塊: import pyprind [as 別名]
# 或者: from pyprind import ProgBar [as 別名]
def download_all(prov_name, qtype, recent, concurrent):
if qtype == QuotesType.futures:
instruments = Instrument.load(config.portfolios.p_all)
dl_fn = partial(dl_inst, prov_name=prov_name, recent=recent)
attr = 'name'
title_name = 'contracts'
elif qtype == QuotesType.currency:
instruments = Currency.load_all()
dl_fn = partial(dl_cur, prov_name=prov_name)
attr = 'code'
title_name = 'currencies'
elif qtype == QuotesType.others:
instruments = Spot.load_all()
dl_fn = partial(dl_spot, prov_name=prov_name)
attr = 'name'
title_name = 'spot prices'
else:
raise Exception('Unknown quotes type')
title = 'Downloading %s history for %s' % (title_name, prov_name)
if concurrent: title += ' (parallel)'
bar = pyprind.ProgBar(len(instruments.values()), title=title)
if concurrent:
import concurrent.futures
with concurrent.futures.ThreadPoolExecutor(max_workers=2) as executor:
download_futures = {executor.submit(lambda v: dl_fn(v), x):
getattr(x, attr) for x in instruments.values()}
for future in concurrent.futures.as_completed(download_futures):
bar.update(item_id=download_futures[future])
else:
for i in instruments.values():
dl_fn(i)