Skip to content

Commit 3fe5254

Browse files
smgtfchollet
authored andcommitted
Skip newlines in TTY AND ipykernel. (#8318)
* Skip newlines in TTY AND ipykernel. After the addition of tty check output was ruined in jupyter. Go back to the old ways when running jupyter notebooks and ipython. * Trigger travis * Only check for ipykernel once when initiating progbar * Add colon
1 parent e5f2fb7 commit 3fe5254

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

keras/utils/generic_utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,8 @@ def __init__(self, target, width=30, verbose=1, interval=0.05):
266266
self.interval = interval
267267
self.total_width = 0
268268
self.seen_so_far = 0
269-
self.verbose = verbose
269+
self.verbose = verbose
270+
self.is_jupyter = 'ipykernel' in sys.modules
270271

271272
def update(self, current, values=None, force=False):
272273
"""Updates the progress bar.
@@ -296,7 +297,7 @@ def update(self, current, values=None, force=False):
296297
return
297298

298299
prev_total_width = self.total_width
299-
if sys.stdout.isatty():
300+
if sys.stdout.isatty() or self.is_jupyter:
300301
sys.stdout.write('\b' * prev_total_width)
301302
sys.stdout.write('\r')
302303
else:

0 commit comments

Comments
 (0)