B
    ˜‘[×	  ã               @   sF   d Z ddlmZmZ ddlZddlmZ e d¡Zdd„ Z	dd	„ Z
dS )
z5
A few practical conventions common to all printers.
é    )Úprint_functionÚdivisionN)ÚIterablez^([a-zA-Z]+)([0-9]+)$c             C   sT  t | ƒdkr| g g fS d}d}g }g }xú|t | ƒk r |d }| ||d … dkrZ|d7 }|  d|¡}|dk rvt | ƒ}|  d|¡}|dk r’t | ƒ}t||ƒ}| ||… }	|}|dkrº|	}q(|	 d¡rØ| |	dd… ¡ q(|	 d¡rö| |	dd… ¡ q(|	 d¡r| |	dd… ¡ q(tdƒ‚q(W t |¡}
|
rJ|
 ¡ \}}| 	d|¡ |||fS )	a  Split a symbol name into a name, superscripts and subscripts

       The first part of the symbol name is considered to be its actual
       'name', followed by super- and subscripts. Each superscript is
       preceded with a "^" character or by "__". Each subscript is preceded
       by a "_" character.  The three return values are the actual name, a
       list with superscripts and a list with subscripts.

       >>> from sympy.printing.conventions import split_super_sub
       >>> split_super_sub('a_x^1')
       ('a', ['1'], ['x'])
       >>> split_super_sub('var_sub1__sup_sub2')
       ('var', ['sup'], ['sub1', 'sub2'])

    r   Né   é   Ú__ú^Ú_zThis should never happen.)
ÚlenÚfindÚminÚ
startswithÚappendÚRuntimeErrorÚ_name_with_digits_pÚmatchÚgroupsÚinsert)ÚtextÚposÚnameZsupersZsubsÚstartZpos_hatZpos_uscZpos_nextÚpartÚmÚsub© r   ú9lib/python3.7/site-packages/sympy/printing/conventions.pyÚsplit_super_sub   sB    




r   c             C   s6   t | jtƒstt| jƒƒdkS tdd„ | jD ƒƒdkS )a@  Return whether a partial derivative symbol is required for printing

    This requires checking how many free variables there are,
    filtering out the ones that are integers. Some expressions don't have
    free variables. In that case, check its variable list explicitly to
    get the context of the expression.
    r   c             s   s   | ]}|j  V  qd S )N)Ú
is_integer)Ú.0Úsr   r   r   ú	<genexpr>S   s    z#requires_partial.<locals>.<genexpr>)Ú
isinstanceZfree_symbolsr   r
   ÚsetZ	variablesÚsum)Úexprr   r   r   Úrequires_partialG   s    	r&   )Ú__doc__Z
__future__r   r   ÚreZsympy.core.compatibilityr   Úcompiler   r   r&   r   r   r   r   Ú<module>   s   
9