- bugfix in parpool.get_newest
- make TqdmMeter bar decrease when necessary
This commit is contained in:
@@ -114,12 +114,13 @@ class ExternalBar:
|
|||||||
class TqdmMeter(tqdm):
|
class TqdmMeter(tqdm):
|
||||||
""" Overload tqdm to make a special version of tqdm functioning as a meter. """
|
""" Overload tqdm to make a special version of tqdm functioning as a meter. """
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, iterable=None, desc=None, total=None, *args, **kwargs):
|
||||||
self._n = 0
|
self._n = 0
|
||||||
|
self._total = total
|
||||||
self.disable = False
|
self.disable = False
|
||||||
if 'bar_format' not in kwargs and len(args) < 16:
|
if 'bar_format' not in kwargs and len(args) < 16:
|
||||||
kwargs['bar_format'] = '{desc}{bar}{n}/{total}'
|
kwargs['bar_format'] = '{desc}{bar}{n}/{total}'
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(iterable, desc, total, *args, **kwargs)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def n(self):
|
def n(self):
|
||||||
@@ -131,6 +132,16 @@ class TqdmMeter(tqdm):
|
|||||||
self._n = int(value)
|
self._n = int(value)
|
||||||
self.refresh()
|
self.refresh()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def total(self):
|
||||||
|
return self._total
|
||||||
|
|
||||||
|
@total.setter
|
||||||
|
def total(self, value):
|
||||||
|
self._total = value
|
||||||
|
if hasattr(self, 'container'):
|
||||||
|
self.container.children[1].max = value
|
||||||
|
|
||||||
def __exit__(self, exc_type=None, exc_value=None, traceback=None):
|
def __exit__(self, exc_type=None, exc_value=None, traceback=None):
|
||||||
if not self.leave:
|
if not self.leave:
|
||||||
self.n = self.total
|
self.n = self.total
|
||||||
@@ -457,9 +468,11 @@ class Parpool:
|
|||||||
""" Request the newest key and result and delete its record. Wait if result not yet available. """
|
""" Request the newest key and result and delete its record. Wait if result not yet available. """
|
||||||
while len(self.tasks):
|
while len(self.tasks):
|
||||||
self._get_from_queue()
|
self._get_from_queue()
|
||||||
for task in self.tasks:
|
for task in self.tasks.values():
|
||||||
if task.done:
|
if task.done:
|
||||||
return task.handle, task.result
|
handle, result = task.handle, task.result
|
||||||
|
self.tasks.pop(handle)
|
||||||
|
return handle, result
|
||||||
|
|
||||||
def __delitem__(self, handle):
|
def __delitem__(self, handle):
|
||||||
self.tasks.pop(handle)
|
self.tasks.pop(handle)
|
||||||
|
|||||||
2
setup.py
2
setup.py
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
|
|||||||
|
|
||||||
setuptools.setup(
|
setuptools.setup(
|
||||||
name="parfor",
|
name="parfor",
|
||||||
version="2022.5.0",
|
version="2022.6.0",
|
||||||
author="Wim Pomp",
|
author="Wim Pomp",
|
||||||
author_email="wimpomp@gmail.com",
|
author_email="wimpomp@gmail.com",
|
||||||
description="A package to mimic the use of parfor as done in Matlab.",
|
description="A package to mimic the use of parfor as done in Matlab.",
|
||||||
|
|||||||
Reference in New Issue
Block a user