Example #1
0
def test_progress_bar():
    prefix = '<<'
    bar = '1234567890'
    suffix = '>>'
    p = progress_bar(10, prefix, bar, suffix)
    assert next(p) == prefix
    assert p.send(4) == '1234'
    assert p.send(4) == ''
    assert p.send(9) == '56789'
    assert p.send(9.999) == ''
    assert p.send(10) == '0' + suffix
Example #2
0
def test_progress_bar():
    prefix = '<<'
    bar = '1234567890'
    suffix = '>>'
    p = progress_bar(10, prefix, bar, suffix)
    assert next(p) == prefix
    assert p.send(4) == '1234'
    assert p.send(4) == ''
    assert p.send(9) == '56789'
    assert p.send(9.999) == ''
    assert p.send(10) == '0' + suffix
Example #3
0
 def __call__(self, epoch_nr, update_nr, net, stepper, logs):
     assert epoch_nr == 0 or math.ceil(update_nr / self.length) == epoch_nr
     if update_nr % self.length == 1:
         self.bar = progress_bar(self.length)
         print(next(self.bar), end='')
         sys.stdout.flush()
     elif update_nr % self.length == 0:
         if self.bar:
             print(self.bar.send(self.length))
     else:
         print(self.bar.send(update_nr % self.length), end='')
         sys.stdout.flush()
Example #4
0
 def __call__(self, epoch_nr, update_nr, net, stepper, logs):
     assert epoch_nr == 0 or math.ceil(update_nr / self.length) == epoch_nr
     if update_nr % self.length == 1:
         self.bar = progress_bar(self.length)
         print(next(self.bar), end='')
         sys.stdout.flush()
     elif update_nr % self.length == 0:
         if self.bar:
             print(self.bar.send(self.length))
     else:
         print(self.bar.send(update_nr % self.length), end='')
         sys.stdout.flush()