B
    b                 @   s2  d Z ddlmZmZmZ dZdZddlmZ ddl	m
Z
mZ ddlZG d	d
 d
eZedddZedddZedddZedddZedddZedddZedddZed d!d"Zed#d$d%Zed&d'd(Zed)d*d+Zed,d*d+Zed-d.d/Zed0d1d2Zed3d4d5Zed6d7d8Zed9d:d;Zed<d=d>Z ed?d@dAZ!edBdCdDZ"edEdFdGZ#eeeeeeeeeeeeeeeeee e!e"e#fZ$ej%e& fdHdIZ'edJdKdLZ(edMdNdOZ)edPdQdRZ*edSdTdUZ+edVdWdXZ,edYdZd[Z-ed\d]d^Z.ed_d`daZ/e(e)e*e+e,e-e.e/fZ0e&dbkr.ddl1Z1ddlZe12ej%e&  dS )ca  
Module simtk.unit.prefix

This is part of the OpenMM molecular simulation toolkit originating from
Simbios, the NIH National Center for Physics-Based Simulation of
Biological Structures at Stanford, funded under the NIH Roadmap for
Medical Research, grant U54 GM072970. See https://simtk.org.

Portions copyright (c) 2012 Stanford University and the Authors.
Authors: Christopher M. Bruns
Contributors: Peter Eastman

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
    )print_functiondivisionabsolute_importzChristopher M. Brunsz0.6   )BaseUnit)Unit
ScaledUnitNc               @   s    e Zd ZdZdd Zdd ZdS )SiPrefixzn
    Unit prefix that can be multiplied by a unit to yield a new unit.

    e.g. millimeter = milli*meter
    c             C   s   || _ || _|| _d S )N)prefixfactorsymbol)selfr
   r   r    r   1lib/python3.7/site-packages/parmed/unit/prefix.py__init__3   s    zSiPrefix.__init__c       	      C   s  t |trF| j|j }| j|j }| j}t|j||}||| |S t |tr| j|j }| j|j }| j|j }t||j	||S t |t
rt| }dt|krtd| j d|d d krtd| j |d d }| | }t
|di}|S td| j dS )z
        SiPrefix * BaseUnit yields new BaseUnit
        SiPrefix * ScaledUnit yields new ScaledUnit
        SiPrefix * Unit with exactly one BaseUnit or ScaledUnit yields new Unit
        r   zHUnit prefix "%s" can only be with simple Units containing one component.r   zEUnit prefix "%s" can only be with simple Units with an exponent of 1.g      ?zHUnit prefix "%s" can only be applied to a Unit, BaseUnit, or ScaledUnit.N)
isinstancer   r   r
   namer   Z	dimensionZdefine_conversion_factor_tor   Zmasterr   listZiter_base_or_scaled_unitslen	TypeError)	r   unitr   r   r   new_base_unitZ
base_units	base_unitnew_unitr   r   r   __mul__8   s.    


zSiPrefix.__mul__N)__name__
__module____qualname____doc__r   r   r   r   r   r   r	   -   s   r	   yottogW:yzeptogO
;zattogC]r2<afemtogV瞯<fpicog-q=pnanog&.>nmicrogư>umilligMbP?mcentig{Gz?cdecig?ddekag      $@Zdadecahectog      Y@hkilog     @@kmegag    .AMgigag    eAGterag   mBTpetag  4&kCPexag NgmCEzettagPKDZyottagyCxDYc             C   sR   xLt D ]D}||  }|j}t|di}||j|d < ||j|< ||j|d < qW dS )aC  
    Create attributes for prefixed units derived from a particular BaseUnit, e.g. "kilometer" from "meter_base_unit"

    Parameters
     - base_unit (BaseUnit) existing base unit to use as a basis for prefixed units
     - module (Module) module which will contain the new attributes.  Defaults to simtk.unit module.
    g      ?Z
_base_unitsN)si_prefixesr   r   __dict__)r   moduler
   r   r   r   r   r   r   define_prefixed_units   s    

rK   kibig      @ZKimebig      0AZMigibig      AZGitebig      pBZTipebig      CZPiexbig      CZEizebig      PDZZiyobig      DZYi__main__)3r   Z
__future__r   r   r   
__author____version__Zbaseunitr   r   r   r   sysobjectr	   r   r!   r#   r%   r'   r)   r+   r-   r/   r1   r3   r4   r5   r7   r9   r;   r=   r?   rA   rC   rE   rH   modulesr   rK   rL   rM   rN   rO   rP   rQ   rR   rS   Zbinary_prefixesZdoctestZtestmodr   r   r   r   <module>   s   /
