§
    ¹³Ùg/  ã                  óP   — d Z ddlmZ ddlmZ ddlZddlmZ 	 	 	 ddd„Z	ddd„Z
dS )z*
Object ND-array initialization function.
é    )Úannotations)ÚSequenceN)Ú	ArrayLikeT© Úarrr   Úorderú
str | NoneÚcopyÚboolÚ
list_typesúSequence[type] | NoneÚreturnú
np.ndarrayc                ó0  ‡— t          | t          j        ¦  «        r5| j        t          k    s|€|du r|                      t          ||¬¦  «        } | S t          | t          |¦  «        ¬¦  «        }t          j        |t          |¬¦  «        }|s| 	                    | ¦  «         nsˆfd„Š ‰| t          |¦  «        ¦  «        }t          |¦  «        |j        k    rt          d¦  «        ‚t          j        |t          t          |¦  «        ¬¦  «        |_        |S )	a;  Convert an array-like of objects into an object array.

    .. note::

        If the objects in the array like input define ``__array__`` methods
        this avoids calling them and will instead set the returned array values
        to the Python objects themselves.

    Args:
        arr: An array-like input.
        order: Optional, the order of the returned array (C, F, A, K). If None
               the default NumPy ordering of C is used.
        copy: If True make a copy of the input if it is already an array.
        list_types: Optional, a sequence of types to treat as lists of array
            element objects when inferring the array shape from the input.

    Returns:
        A NumPy ND-array with ``dtype=object``.

    Raises:
        ValueError: If the input cannot be coerced into an object array.
    NT)r   r
   ©r   )Údtyper   c                ó4   •‡— ‰dk    r| S ˆˆfd„| D ¦   «         S )Né   c                ó8   •— g | ]} ‰|‰d z
  ¦  «        D ]}|‘ŒŒS )r   r   )Ú.0ÚsublistÚitemÚ_flattenÚks      €€ú_/granary/edev/quantum/lib/python3.11/site-packages/qiskit/primitives/containers/object_array.pyú
<listcomp>z2object_array.<locals>._flatten.<locals>.<listcomp>H   s9   ø€ ÐXÐXÐX ¸x¸xÈÐQRÐUVÑQVÑ?WÔ?WÐXÐX°t˜ÐXÐXÐXÐXó    r   )Únestedr   r   s    `€r   r   zobject_array.<locals>._flattenD   s/   øø€ Ø�AŠvˆvØ�àXÐXÐXÐXÐX¨FÐXÑXÔXÐXr   ztInput object size does not match the inferred array shape. This most likely occurs when the input is a ragged array.)r   Úcount)Ú
isinstanceÚnpÚndarrayr   ÚobjectÚastypeÚ_infer_shapeÚtupleÚemptyÚfillÚlenÚsizeÚ
ValueErrorÚfromiterÚflat)r   r   r
   r   ÚshapeÚobj_arrÚ	flattenedr   s          @r   Úobject_arrayr1      s&  ø€ õ8 �#•r”zÑ"Ô"ð ØŒ9�ÒÐ %Ð"3°t¸t°|°|Ø—*’*�V¨5°t�*Ñ<Ô<ˆCØˆ
å˜­¨zÑ):Ô):Ð;Ñ;Ô;€EÝŒh�u¥F°%Ð8Ñ8Ô8€GØð Rð 	�Š�SÑÔÐÐð	Yð 	Yð 	Yð 	Yð 	Yð �H˜S¥# e¡*¤*Ñ-Ô-ˆ	Ýˆy‰>Œ>˜Wœ\Ò)Ð)ÝðMñô ð õ ”{ 9µFÅ#ÀiÁ.Ä.ÐQÑQÔQˆŒà€Nr   Úobjútuple[type, ...]útuple[int, ...]c                óà   — t          | t          j        ¦  «        r| j        S t          | t          g|¢R ¦  «        sdS t          | ¦  «        }|dk    r|fS |gt          | d         |¬¦  «        ¢R S )z7Infer the shape of an array-like object without castingr   r   r   )r    r!   r"   r.   Úlistr)   r%   )r2   r   r*   s      r   r%   r%   U   s}   € å�#•r”zÑ"Ô"ð ØŒyÐÝ�c�DÐ. :Ð.Ð.Ñ/Ô/ð ØˆrÝˆs‰8Œ8€DØˆq‚y€yØˆwˆØÐ?•<  A¤°:Ð>Ñ>Ô>Ð?Ð?Ð?r   )NTr   )
r   r   r   r	   r
   r   r   r   r   r   )r   )r2   r   r   r3   r   r4   )Ú__doc__Ú
__future__r   Úcollections.abcr   Únumpyr!   Únumpy.typingr   r1   r%   r   r   r   ú<module>r<      s¢   ððð ð #Ð "Ð "Ð "Ð "Ð "à $Ð $Ð $Ð $Ð $Ð $à Ð Ð Ð Ø "Ð "Ð "Ð "Ð "Ð "ð
 ØØ(*ð	:ð :ð :ð :ð :ðz	@ð 	@ð 	@ð 	@ð 	@ð 	@ð 	@r   