def set_unit_system(unit_system):
"""Activates a unit system.
The default unit system is 'mks'. Calling this function changes the active
unit system to the one with the specified name. Only constants associated
with the active unit system or not associated with a unit system are
available for use.
:arg str unit_system:
Name of the desired unit system.
A *KeyError* is raised if *unit_system* does not correspond to a known unit
system.
Example::
>>> from quantiphy import Quantity, set_unit_system
>>> set_unit_system('cgs')
>>> print(Quantity('h').render(show_label='f'))
h = 6.6261e-27 erg-s -- Plank's constant
>>> set_unit_system('mks')
>>> print(Quantity('h').render(show_label='f'))
h = 662.61e-36 J-s -- Plank's constant
"""
global _active_constants
_active_constants = ChainMap(
_constants[None],
_constants[unit_system]
)
评论列表
文章目录