a
    yn„f4  ã                   @  sª   d dl mZ d dlmZ d dlZd dlmZ d dlm	Z	 d dl
mZ d dlmZmZmZmZmZ d dlmZ d d	lmZmZmZ d
Ze	 ¡ ZeG dd„ dee eƒƒZdS )é    )Úannotations)ÚCallableN)ÚIndexedMeta)ÚNumpyMetadata)Úparameters_union)ÚAnyÚDTypeÚIteratorÚSelfÚfinal)ÚUNSET)ÚFormÚ_SpecifierMatcherÚindex_to_dtype)ÚIndexedFormc                   @  sä   e Zd ZU ded< d.dddœdd„Zedd„ ƒZed	d
„ ƒZeefeedœdd„Z	e
dddœdd„ƒZdd„ Zdd„ Zedd„ ƒZdd„ Zdddœdd„Zdddœdd „Zd!d"„ Zd#d$„ Zd%dd&d'œd(d)„Zd*dddd+œd,d-„ZdS )/r   r   Ú_contentN©Ú
parametersÚform_keyc                C  sb   t |tƒs"tt| ƒj› d|›�ƒ‚t |tƒsDtt| ƒj› d|›�ƒ‚|| _|| _| j||d� d S )Nz" 'index' must be of type str, not z- all 'contents' must be Form subclasses, not r   )	Ú
isinstanceÚstrÚ	TypeErrorÚtypeÚ__name__r   Ú_indexr   Ú_init©ÚselfÚindexÚcontentr   r   © r    ú\/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/awkward/forms/indexedform.pyÚ__init__   s    
ÿ
ÿzIndexedForm.__init__c                 C  s   | j S ©N)r   ©r   r    r    r!   r   /   s    zIndexedForm.indexc                 C  s   | j S r#   )r   r$   r    r    r!   r   3   s    zIndexedForm.contentc                C  sH   t |tu r| jn||tu r | jn||tu r0| jn||tu r@| jn|d�S )Nr   )r   r   r   r   Ú_parametersZ	_form_keyr   r    r    r!   Úcopy7   s    üzIndexedForm.copyc                C  sŠ   |d uo|  d¡dk}|jr4|s4|jt|j|ƒd�S |jrXtjjj	d|j
t|j|ƒd�S |jrvtd|j
t|j|ƒd�S | ||||d�S d S )NÚ	__array__Úcategorical)r   Zi64r   )ÚgetZis_unionr&   r   r%   Z	is_optionÚakZformsZIndexedOptionFormÚ
simplifiedr   Z
is_indexedr   )Úclsr   r   r   r   Zis_catr    r    r!   r+   F   s$    	

ÿ
ý
ýzIndexedForm.simplifiedc                 C  s4   t | jƒt | jƒg|  ¡ ¢}d t| ƒjd |¡¡S )Nz{}({})z, )Úreprr   r   Z
_repr_argsÚformatr   r   Újoin)r   Úargsr    r    r!   Ú__repr__g   s    zIndexedForm.__repr__c                 C  s"   |   d| j| jj|dd�dœ|¡S )NZIndexedArrayF)Útoplevel)Úclassr   r   )Z_to_dict_extrar   r   Ú_to_dict_part)r   Úverboser2   r    r    r!   r4   k   s    ýúzIndexedForm._to_dict_partc                 C  s”   | j j}| jd ur�|jd u r&| j|_nt|j| jƒ|_| j d¡dkr�|j| ju r^t|jƒ|_| j  d¡}|d ur~||jd< n|jd= d|jd< |S )Nr'   r(   TZ__categorical__)r   r   r%   r   r)   ÚdictZ	parameter)r   ÚoutZ	out_arrayr    r    r!   r   u   s    



zIndexedForm.typec                 C  s   | j  |||¡ d S r#   )r   Ú_columns)r   ÚpathÚoutputZlist_indicatorr    r    r!   r8   �   s    zIndexedForm._columnsÚboolzSelf | None)Úis_inside_record_or_unionÚreturnc                 C  s(   | j  |¡}|d u rd S | j|d�S d S ©N)r   )r   Ú_prune_columnsr&   )r   r<   Znext_contentr    r    r!   r?   �   s    zIndexedForm._prune_columnsr   r
   )Úmatch_specifierr=   c                 C  s   | j | j |¡d�S r>   )r&   r   Ú_select_columns)r   r@   r    r    r!   rA   —   s    zIndexedForm._select_columnsc                 C  s
   | j  ¡ S r#   )r   Ú_column_typesr$   r    r    r!   rB   š   s    zIndexedForm._column_typesc                 C  sL   t |tƒr| j |¡ n0|\}}}}}|d ur6d| }| j||||d� d S )Nzpart0-r   )r   r6   Ú__dict__Úupdater"   )r   ÚstateZhas_identitiesr   r   r   r   r    r    r!   Ú__setstate__�   s    
zIndexedForm.__setstate__zCallable[[Form, str], str]zIterator[tuple[str, DType]])ÚgetkeyÚ	recursiver=   c                 c  s2   || dƒt | j fV  |r.| j ||¡E d H  d S )Nr   )r   r   r   Ú_expected_from_buffers)r   rG   rH   r    r    r!   rI   ¬   s    z"IndexedForm._expected_from_buffersr   )ÚotherÚall_parametersr   r=   c                 C  s,   |   |||¡o*| j|jko*| j |j||¡S r#   )Z_is_equal_to_genericr   r   Ú_is_equal_to)r   rJ   rK   r   r    r    r!   rL   ³   s
    
ÿýzIndexedForm._is_equal_to)N)r   Ú
__module__Ú__qualname__Ú__annotations__r"   Úpropertyr   r   r   r&   Úclassmethodr+   r1   r4   r   r8   r?   rA   rB   rF   rI   rL   r    r    r    r!   r      s>   
 ýú

ýúú 

r   )Ú
__future__r   Úcollections.abcr   Zawkwardr*   Zawkward._meta.indexedmetar   Zawkward._nplikes.numpy_liker   Zawkward._parametersr   Zawkward._typingr   r   r	   r
   r   Zawkward._utilr   Zawkward.forms.formr   r   r   Ú__all__ÚinstanceÚnpr   r    r    r    r!   Ú<module>   s   