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.
Parameters: x : {
Quantity
, array-like, number}The value to display
precision :
int
, optionalThe number of digits of precision (in the best unit, see Examples). If no value is given, numpy’s
get_printoptions()
value is used.Returns: representation :
str
A string representation of this
Quantity
.See also
Examples
>>> 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) '0.123456' >>> in_best_unit(0.123456, 2) '0.12'