MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / format_num

Method format_num

pager_lib/tqdm/std.py:420–436  ·  view source on GitHub ↗

Intelligent scientific notation (.3g). Parameters ---------- n : int or float or Numeric A Number. Returns ------- out : str Formatted number.

(n)

Source from the content-addressed store, hash-verified

418
419 @staticmethod
420 def format_num(n):
421 """
422 Intelligent scientific notation (.3g).
423
424 Parameters
425 ----------
426 n : int or float or Numeric
427 A Number.
428
429 Returns
430 -------
431 out : str
432 Formatted number.
433 """
434 f = f'{n:.3g}'.replace('e+0', 'e+').replace('e-0', 'e-')
435 n = str(n)
436 return f if len(f) < len(n) else n
437
438 @staticmethod
439 def status_printer(file):

Callers 1

set_postfixMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected