sigfigs#

sigfigs(x, sigfigs=4, SI=False, sep=False, keepints=False)#

Return a string representation of variable x with sigfigs number of significant figures

Note: sc.sigfig() and sc.sigfigs() are aliases.

Parameters:
  • x (int/float/list/arr) – the number(s) to round

  • sigfigs (int) – number of significant figures to round to

  • SI (bool) – whether to use SI notation (only for numbers >1)

  • sep (bool/str) – if provided, use as thousands separator

  • keepints (bool) – never round ints

Examples:

x = 3432.3842
sc.sigfig(x, SI=True) # Returns '3.432k'
sc.sigfig(x, sep=True) # Returns '3,432'

vals = np.random.rand(5)
sc.sigfig(vals, sigfigs=3)

New in version 3.0.0: changed default number of significant figures from 5 to 4; return list rather than tuple; changed SI suffixes to uppercase