mirror of https://github.com/m-labs/artiq.git
21 lines
494 B
Python
21 lines
494 B
Python
__all__ = []
|
|
|
|
_prefixes_str = "pnum_kMG"
|
|
_smallest_prefix_exp = -12
|
|
|
|
|
|
def _register_unit(unit, prefixes):
|
|
exponent = _smallest_prefix_exp
|
|
for prefix in _prefixes_str:
|
|
if prefix in prefixes:
|
|
full_name = prefix + unit if prefix != "_" else unit
|
|
globals()[full_name] = 10.**exponent
|
|
__all__.append(full_name)
|
|
exponent += 3
|
|
|
|
|
|
_register_unit("s", "pnum_")
|
|
_register_unit("Hz", "_kMG")
|
|
_register_unit("dB", "_")
|
|
_register_unit("V", "um_k")
|