Skip to content

Commit b41d77a

Browse files
committed
Merge pull request #5 from adamlerer/master
Clear correct number of progress bar spaces.
2 parents 59d2bcf + 76aa0a0 commit b41d77a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

init.lua

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ end
231231
do
232232
local barDone = true
233233
local previous = -1
234+
local tm = ''
234235
local timer
235236
local times
236237
local indices
@@ -247,6 +248,7 @@ do
247248
if (barDone and ((previous == -1) or (percent < previous))) then
248249
barDone = false
249250
previous = -1
251+
tm = ''
250252
timer = torch.Timer()
251253
times = {timer:time().real}
252254
indices = {current}
@@ -266,8 +268,8 @@ do
266268
end
267269
glob.io.write('] ')
268270
-- time stats
269-
for i=1,50 do glob.io.write(' ') end
270-
for i=1,50 do glob.io.write('\b') end
271+
for i=1,#tm do glob.io.write(' ') end
272+
for i=1,#tm do glob.io.write('\b') end
271273
local elapsed = timer:time().real
272274
local step = (elapsed-times[1]) / (current-indices[1])
273275
if current==indices[1] then step = 0 end
@@ -278,7 +280,7 @@ do
278280
indices = table.splice(indices)
279281
times = table.splice(times)
280282
end
281-
local tm = 'ETA: ' .. formatTime(remaining) .. ' | Step: ' .. formatTime(step)
283+
tm = 'ETA: ' .. formatTime(remaining) .. ' | Step: ' .. formatTime(step)
282284
glob.io.write(tm)
283285
-- go back to center of bar, and print progress
284286
for i=1,47+#tm do glob.io.write('\b') end

0 commit comments

Comments
 (0)