quantiphy.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:quantiphy 作者: KenKundert 项目源码 文件源码
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]
    )
评论列表


问题


面经


文章

微信
公众号

扫码关注公众号