a
    yn„fû  ã                	   @  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Ze	 ¡ Zeƒ ddddd	ddd
œdd„ƒZdd„ ZdS )é    )Úannotations)ÚMappingN)Úhigh_level_function)ÚNumpyMetadata)Úregularize_axis)Úargcartesiané   T)ÚnestedÚ
parametersÚ	with_nameÚ	highlevelÚbehaviorÚattrsc             	   c  s2   t | tƒr|  ¡ V  n| V  t| |||||||ƒS )a  
    Args:
        arrays (mapping or sequence of arrays): Each value in this mapping or
            sequence can be any array-like data that #ak.to_layout recognizes.
        axis (int): The dimension at which this operation is applied. The
            outermost dimension is `0`, followed by `1`, etc., and negative
            values count backward from the innermost: `-1` is the innermost
            dimension, `-2` is the next level up, etc.
        nested (None, True, False, or iterable of str or int): If None or
            False, all combinations of elements from the `arrays` are
            produced at the same level of nesting; if True, they are grouped
            in nested lists by combinations that share a common item from
            each of the `arrays`; if an iterable of str or int, group common
            items for a chosen set of keys from the `array` dict or slots
            of the `array` iterable.
        parameters (None or dict): Parameters for the new
            #ak.contents.RecordArray node that is created by this operation.
        with_name (None or str): Assigns a `"__record__"` name to the new
            #ak.contents.RecordArray node that is created by this operation
            (overriding `parameters`, if necessary).
        highlevel (bool): If True, return an #ak.Array; otherwise, return
            a low-level #ak.contents.Content subclass.
        behavior (None or dict): Custom #ak.behavior for the output array, if
            high-level.
        attrs (None or dict): Custom attributes for the output array, if
            high-level.

    Computes a Cartesian product (i.e. cross product) of data from a set of
    `arrays`, like #ak.cartesian, but returning integer indexes for
    #ak.Array.__getitem__.

    For example, the Cartesian product of

        >>> one = ak.Array([1.1, 2.2, 3.3])
        >>> two = ak.Array(["a", "b"])

    is

        >>> ak.cartesian([one, two], axis=0).show()
        [(1.1, 'a'),
         (1.1, 'b'),
         (2.2, 'a'),
         (2.2, 'b'),
         (3.3, 'a'),
         (3.3, 'b')]

    But with argcartesian, only the indexes are returned.

        >>> ak.argcartesian([one, two], axis=0).show()
        [(0, 0),
         (0, 1),
         (1, 0),
         (1, 1),
         (2, 0),
         (2, 1)]

    These are the indexes that can select the items that go into the actual
    Cartesian product.

        >>> one_index, two_index = ak.unzip(ak.argcartesian([one, two], axis=0))
        >>> one[one_index]
        <Array [1.1, 1.1, 2.2, 2.2, 3.3, 3.3] type='6 * float64'>
        >>> two[two_index]
        <Array ['a', 'b', 'a', 'b', 'a', 'b'] type='6 * string'>

    All of the parameters for #ak.cartesian apply equally to #ak.argcartesian,
    so see the #ak.cartesian documentation for a more complete description.
    )Ú
isinstancer   ÚvaluesÚ_impl)ÚarraysÚaxisr	   r
   r   r   r   r   © r   úe/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/awkward/operations/ak_argcartesian.pyr      s    Q
ÿr   c           	        sv   t ˆ ƒ‰ t| tƒr*‡ fdd„|  ¡ D ƒ}ndd„ | D ƒ}|d ur^|d u rNi }nt|ƒ}||d< tjj|ˆ ||||d�S )Nc                   s   i | ]\}}|t  |ˆ ¡“qS r   ©ÚakZlocal_index)Ú.0ÚnÚx©r   r   r   Ú
<dictcomp>q   ó    z_impl.<locals>.<dictcomp>c                 S  s   g | ]}t  |¡‘qS r   r   )r   r   r   r   r   Ú
<listcomp>s   r   z_impl.<locals>.<listcomp>Z
__record__)r   r	   r
   r   r   )r   r   r   ÚitemsÚdictr   Ú
operationsZ	cartesian)	r   r   r	   r
   r   r   r   r   Zindex_arraysr   r   r   r   m   s"    
úr   )r   )Ú
__future__r   Úcollections.abcr   Zawkwardr   Zawkward._dispatchr   Zawkward._nplikes.numpy_liker   Zawkward._regularizer   Ú__all__ÚinstanceÚnpr   r   r   r   r   r   Ú<module>   s$    þ÷[