3
‡$a]  ã               @   s"   d dl mZ ddd„Zdd„ ZdS )	é    )ÚunitsÚ c             C   s   |r| d| 7 } t | tjƒS )z`
    Return a numeric value from a string holding a unit expression or by providing a unit.
    Ú*)Úevalr   Ú__dict__)ZvalstrZunit© r   ú9/home/yuhw/wc/wire-cell-python/wirecell/util/functions.pyÚunitify   s    r	   c             C   s&   dd„ | j dƒD ƒ}dd„ |D ƒ}|S )z¡
    Parse a string with unit expressions and return its value.  String
    assumed to be a comman separated list of scalar values.  A list is
    returned.
    c             S   s   g | ]}|j ƒ r|j ƒ ‘qS r   )Ústrip)Ú.0Úvr   r   r   ú
<listcomp>   s    z!unitify_parse.<locals>.<listcomp>ú,c             S   s   g | ]}t |tjƒ‘qS r   )r   r   r   )r   r   r   r   r   r      s    )Úsplit)ÚstringÚvalsr   r   r   Úunitify_parse   s    r   N)r   )Úwirecellr   r	   r   r   r   r   r   Ú<module>   s   
	