tidy,flake8

This commit is contained in:
Casper da Costa-Luis 2018-04-15 02:08:47 +01:00
parent 47df7d6d1b
commit 34457bd2b0
No known key found for this signature in database
GPG Key ID: 986B408043AE090D
1 changed files with 6 additions and 7 deletions

View File

@ -105,9 +105,9 @@ class tqdm_notebook(tqdm):
# Only way to place text to the right of the bar is to use a container
container = HBox(children=[pbar, ptext])
# Prepare layout
if ncols is not None: # if ncols is None, use default style of ipywidgets
if ncols is not None: # use default style of ipywidgets
# ncols could be 100, "100px", "100%"
ncols = str(ncols) # ipywidgets only accepts string,
ncols = str(ncols) # ipywidgets only accepts string
if ncols[-1].isnumeric():
# if last value is digit, assume the value is digit
ncols += 'px'
@ -185,12 +185,11 @@ class tqdm_notebook(tqdm):
# self.sp('', close=True)
# Get bar width
self.ncols = kwargs.get('ncols', None)
if self.dynamic_ncols:
self.ncols = '100%'
self.ncols = '100%' if self.dynamic_ncols else kwargs.get("ncols", None)
# Replace with IPython progress bar display (with correct total)
self.sp = self.status_printer(self.fp, self.total, self.desc, self.ncols)
self.sp = self.status_printer(
self.fp, self.total, self.desc, self.ncols)
self.desc = None # trick to place description before the bar
# Print initial bar state
@ -203,7 +202,7 @@ class tqdm_notebook(tqdm):
# return super(tqdm...) will not catch exception
yield obj
# NB: except ... [ as ...] breaks IPython async KeyboardInterrupt
except:
except: # NOQA
self.sp(bar_style='danger')
raise