Closed Erotemic closed 1 year ago
I added some logic in show_func to widen columns if necessary. I also added an associated doctest that demonstrates the issue.
show_func
Before when hits or time was large enough it would overflow the column and make the lines have bad indentation:
Total time: 1.32e+11 s File: /home/joncrall/code/line_profiler/line_profiler/line_profiler.py Function: show_text at line 306 Line # Hits Time Per Hit % Time Line Contents ============================================================== 306 def show_text(stats, unit, output_unit=None, stream=None, stripzeros=False): 307 """ Show text for the given timings. 308 """ 309 100000000.0 2000000000.0 20.0 1.5 if stream is None: 310 200000000.0 4000000000.0 20.0 3.0 stream = sys.stdout 311 312 300000000.0 6000000000.0 20.0 4.5 if output_unit is not None: 313 400000000.0 8000000000.0 20.0 6.1 stream.write('Timer unit: %g s\n\n' % output_unit) 314 else: 315 500000000.0 10000000000.0 20.0 7.6 stream.write('Timer unit: %g s\n\n' % unit) 316 317 1100000000.0 22000000000.0 20.0 16.7 for (fn, lineno, name), timings in sorted(stats.items()): 318 1000000000.0 20000000000.0 20.0 15.2 show_func(fn, lineno, name, stats[fn, lineno, name], unit, 319 800000000.0 16000000000.0 20.0 12.1 output_unit=output_unit, stream=stream, 320 900000000.0 18000000000.0 20.0 13.6 stripzeros=stripzeros)
With the fix the column width increases to accomidate the largest number in the column:
Total time: 1.32e+11 s File: /home/joncrall/code/line_profiler/line_profiler/line_profiler.py Function: show_text at line 327 Line # Hits Time Per Hit % Time Line Contents ======================================================================= 327 def show_text(stats, unit, output_unit=None, stream=None, stripzeros=False): 328 """ Show text for the given timings. 329 """ 330 10000000000000.0 2000000000.0 0.0 1.5 if stream is None: 331 20000000000000.0 4000000000.0 0.0 3.0 stream = sys.stdout 332 333 30000000000000.0 6000000000.0 0.0 4.5 if output_unit is not None: 334 40000000000000.0 8000000000.0 0.0 6.1 stream.write('Timer unit: %g s\n\n' % output_unit) 335 else: 336 50000000000000.0 10000000000.0 0.0 7.6 stream.write('Timer unit: %g s\n\n' % unit) 337 338 110000000000000.0 22000000000.0 0.0 16.7 for (fn, lineno, name), timings in sorted(stats.items()): 339 100000000000000.0 20000000000.0 0.0 15.2 show_func(fn, lineno, name, stats[fn, lineno, name], unit, 340 80000000000000.0 16000000000.0 0.0 12.1 output_unit=output_unit, stream=stream, 341 90000000000000.0 18000000000.0 0.0 13.6 stripzeros=stripzeros)
Merging #209 (8695883) into main (6ffb10d) will increase coverage by 2.36%. The diff coverage is 100.00%.
2.36%
100.00%
I added some logic in
show_func
to widen columns if necessary. I also added an associated doctest that demonstrates the issue.Before when hits or time was large enough it would overflow the column and make the lines have bad indentation:
With the fix the column width increases to accomidate the largest number in the column: