in_best_unit function

(Shortest import: from brian2 import in_best_unit)

brian2.units.fundamentalunits.in_best_unit(x, precision=None)[source]

Represent the value in the “best” unit.


x : {Quantity, array-like, number}

The value to display

precision : int, optional

The number of digits of precision (in the best unit, see Examples). If no value is given, numpy’s get_printoptions() value is used.


representation : str

A string representation of this Quantity.


>>> from brian2.units import *
>>> in_best_unit(0.00123456 * volt)
'1.23456 mV'
>>> in_best_unit(0.00123456 * volt, 2)
'1.23 mV'
>>> in_best_unit(0.123456)
>>> in_best_unit(0.123456, 2)