????

Your IP : 18.118.10.2


Current Path : /opt/cloudlinux/venv/lib/python3.11/site-packages/numpy/lib/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/numpy/lib/__pycache__/shape_base.cpython-311.pyc

�

If#���r�ddlZddlmcmZddlmZmZmZmZddl	m
Z
mZddlm
Z
ddlmZddlmZmZddlmZddlmZdd	lmZdd
lmZgd�Zejejd�
��Zd�Zd�Zee��d���Zd�Zee��d���Z d�Z!ee!��d���Z"d�Z#ee#��d���Z$d�Z%ee%��d���Z&eZ'd�Z(ee(��d���Z)d�Z*ee*��d���Z+d�Z,d,d�Z-ee-��d-d���Z.d,d �Z/ee/��d-d!���Z0d"�Z1ee1��d#���Z2ee1��d$���Z3ee1��d%���Z4d&�Z5d'�Z6d(�Z7ee7��d)���Z8d*�Z9ee9��d+���Z:dS).�N)�asarray�zeros�array�
asanyarray)�reshape�	transpose)�normalize_axis_index)�	overrides)�vstack�
atleast_3d)�normalize_axis_tuple��_arrays_for_stack_dispatcher)�ndindex)�matrix)�column_stack�	row_stack�dstack�array_split�split�hsplit�vsplit�dsplit�apply_over_axes�expand_dims�apply_along_axis�kron�tile�get_array_wrap�take_along_axis�put_along_axis�numpy)�modulec�~�tj|jtj��st	d���t|��|jkrtd���d|jz}tt|����dgztt|dz|j����z}g}t||��D]r\}}|�|�|���|d|�dz||dzd�z}|�tj|���
|�����st|��S)Nz"`indices` must be an integer arrayz;`indices` and `arr` must have the same number of dimensions��r&)���)�_nx�
issubdtype�dtype�integer�
IndexError�len�ndim�
ValueError�list�range�zip�append�aranger�tuple)	�	arr_shape�indices�axis�
shape_ones�	dest_dims�fancy_index�dim�n�	ind_shapes	         �K/opt/cloudlinux/venv/lib64/python3.11/site-packages/numpy/lib/shape_base.py�_make_along_axis_idxr@s9���>�'�-���5�5�?��=�>�>�>�
�9�~�~���%�%��I�K�K�	K����$�J��U�4�[�[�!�!�T�F�*�T�%��Q����2M�2M�-N�-N�N�I��K��i��+�+�A�A���Q��;����w�'�'�'�'�"�4�C�4�(�5�0�:�c�!�e�f�f�3E�E�I����s�z�!�}�}�4�4�Y�?�?�@�@�@�@������c�
�||fS�N�)�arrr7r8s   r?�_take_along_axis_dispatcherrF2s����>�rAc��|�|j}t|��f}d}nt||j��}|j}|t|||��S)ay
    Take values from the input array by matching 1d index and data slices.

    This iterates over matching 1d slices oriented along the specified axis in
    the index and data arrays, and uses the former to look up values in the
    latter. These slices can be different lengths.

    Functions returning an index along an axis, like `argsort` and
    `argpartition`, produce suitable indices for this function.

    .. versionadded:: 1.15.0

    Parameters
    ----------
    arr : ndarray (Ni..., M, Nk...)
        Source array
    indices : ndarray (Ni..., J, Nk...)
        Indices to take along each 1d slice of `arr`. This must match the
        dimension of arr, but dimensions Ni and Nj only need to broadcast
        against `arr`.
    axis : int
        The axis to take 1d slices along. If axis is None, the input array is
        treated as if it had first been flattened to 1d, for consistency with
        `sort` and `argsort`.

    Returns
    -------
    out: ndarray (Ni..., J, Nk...)
        The indexed result.

    Notes
    -----
    This is equivalent to (but faster than) the following use of `ndindex` and
    `s_`, which sets each of ``ii`` and ``kk`` to a tuple of indices::

        Ni, M, Nk = a.shape[:axis], a.shape[axis], a.shape[axis+1:]
        J = indices.shape[axis]  # Need not equal M
        out = np.empty(Ni + (J,) + Nk)

        for ii in ndindex(Ni):
            for kk in ndindex(Nk):
                a_1d       = a      [ii + s_[:,] + kk]
                indices_1d = indices[ii + s_[:,] + kk]
                out_1d     = out    [ii + s_[:,] + kk]
                for j in range(J):
                    out_1d[j] = a_1d[indices_1d[j]]

    Equivalently, eliminating the inner loop, the last two lines would be::

                out_1d[:] = a_1d[indices_1d]

    See Also
    --------
    take : Take along an axis, using the same indices for every 1d slice
    put_along_axis :
        Put values into the destination array by matching 1d index and data slices

    Examples
    --------

    For this sample array

    >>> a = np.array([[10, 30, 20], [60, 40, 50]])

    We can sort either by using sort directly, or argsort and this function

    >>> np.sort(a, axis=1)
    array([[10, 20, 30],
           [40, 50, 60]])
    >>> ai = np.argsort(a, axis=1)
    >>> ai
    array([[0, 2, 1],
           [1, 2, 0]])
    >>> np.take_along_axis(a, ai, axis=1)
    array([[10, 20, 30],
           [40, 50, 60]])

    The same works for max and min, if you maintain the trivial dimension
    with ``keepdims``:

    >>> np.max(a, axis=1, keepdims=True)
    array([[30],
           [60]])
    >>> ai = np.argmax(a, axis=1, keepdims=True)
    >>> ai
    array([[1],
           [0]])
    >>> np.take_along_axis(a, ai, axis=1)
    array([[30],
           [60]])

    If we want to get the max and min at the same time, we can stack the
    indices first

    >>> ai_min = np.argmin(a, axis=1, keepdims=True)
    >>> ai_max = np.argmax(a, axis=1, keepdims=True)
    >>> ai = np.concatenate([ai_min, ai_max], axis=1)
    >>> ai
    array([[0, 1],
           [1, 0]])
    >>> np.take_along_axis(a, ai, axis=1)
    array([[10, 30],
           [40, 60]])
    Nr��flatr-r	r.�shaper@)rEr7r8r6s    r?r r 6sW��V�|��h����X�X�K�	����#�D�#�(�3�3���I�	��#�I�w��=�=�>�>rAc��|||fSrCrD)rEr7�valuesr8s    r?�_put_along_axis_dispatcherrM�s����&�!�!rAc��|�|j}d}t|��f}nt||j��}|j}||t|||��<dS)a�
    Put values into the destination array by matching 1d index and data slices.

    This iterates over matching 1d slices oriented along the specified axis in
    the index and data arrays, and uses the former to place values into the
    latter. These slices can be different lengths.

    Functions returning an index along an axis, like `argsort` and
    `argpartition`, produce suitable indices for this function.

    .. versionadded:: 1.15.0

    Parameters
    ----------
    arr : ndarray (Ni..., M, Nk...)
        Destination array.
    indices : ndarray (Ni..., J, Nk...)
        Indices to change along each 1d slice of `arr`. This must match the
        dimension of arr, but dimensions in Ni and Nj may be 1 to broadcast
        against `arr`.
    values : array_like (Ni..., J, Nk...)
        values to insert at those indices. Its shape and dimension are
        broadcast to match that of `indices`.
    axis : int
        The axis to take 1d slices along. If axis is None, the destination
        array is treated as if a flattened 1d view had been created of it.

    Notes
    -----
    This is equivalent to (but faster than) the following use of `ndindex` and
    `s_`, which sets each of ``ii`` and ``kk`` to a tuple of indices::

        Ni, M, Nk = a.shape[:axis], a.shape[axis], a.shape[axis+1:]
        J = indices.shape[axis]  # Need not equal M

        for ii in ndindex(Ni):
            for kk in ndindex(Nk):
                a_1d       = a      [ii + s_[:,] + kk]
                indices_1d = indices[ii + s_[:,] + kk]
                values_1d  = values [ii + s_[:,] + kk]
                for j in range(J):
                    a_1d[indices_1d[j]] = values_1d[j]

    Equivalently, eliminating the inner loop, the last two lines would be::

                a_1d[indices_1d] = values_1d

    See Also
    --------
    take_along_axis :
        Take values from the input array by matching 1d index and data slices

    Examples
    --------

    For this sample array

    >>> a = np.array([[10, 30, 20], [60, 40, 50]])

    We can replace the maximum values with:

    >>> ai = np.argmax(a, axis=1, keepdims=True)
    >>> ai
    array([[1],
           [0]])
    >>> np.put_along_axis(a, ai, 99, axis=1)
    >>> a
    array([[10, 99, 20],
           [99, 40, 50]])

    NrrH)rEr7rLr8r6s     r?r!r!�s]��T�|��h������X�X�K�	�	�#�D�#�(�3�3���I�	�;A�C��Y���6�6�7�7�7rAc��|fSrCrD)�func1dr8rE�args�kwargss     r?�_apply_along_axis_dispatcherrSs	���6�MrAc�D�t|��}|j}t||��}tt	|����}t||d|�||dzd�z|gz��}t
|jdd���}d�|D��}	t|��}	n#t$rtd��d�wxYwt|||	g|�Ri|����}
t|jdd�|
jz|
j��}tt	|j����}|d|�||j|
jz
|j�z|||j|
jz
�z}
t|
t��s|
�|��}|
||	<|D]$}t|||g|�Ri|����||<�%t|
t��s%|
�|��}t||
��St||
��}|
�|��S)aU
    Apply a function to 1-D slices along the given axis.

    Execute `func1d(a, *args, **kwargs)` where `func1d` operates on 1-D arrays
    and `a` is a 1-D slice of `arr` along `axis`.

    This is equivalent to (but faster than) the following use of `ndindex` and
    `s_`, which sets each of ``ii``, ``jj``, and ``kk`` to a tuple of indices::

        Ni, Nk = a.shape[:axis], a.shape[axis+1:]
        for ii in ndindex(Ni):
            for kk in ndindex(Nk):
                f = func1d(arr[ii + s_[:,] + kk])
                Nj = f.shape
                for jj in ndindex(Nj):
                    out[ii + jj + kk] = f[jj]

    Equivalently, eliminating the inner loop, this can be expressed as::

        Ni, Nk = a.shape[:axis], a.shape[axis+1:]
        for ii in ndindex(Ni):
            for kk in ndindex(Nk):
                out[ii + s_[...,] + kk] = func1d(arr[ii + s_[:,] + kk])

    Parameters
    ----------
    func1d : function (M,) -> (Nj...)
        This function should accept 1-D arrays. It is applied to 1-D
        slices of `arr` along the specified axis.
    axis : integer
        Axis along which `arr` is sliced.
    arr : ndarray (Ni..., M, Nk...)
        Input array.
    args : any
        Additional arguments to `func1d`.
    kwargs : any
        Additional named arguments to `func1d`.

        .. versionadded:: 1.9.0


    Returns
    -------
    out : ndarray  (Ni..., Nj..., Nk...)
        The output array. The shape of `out` is identical to the shape of
        `arr`, except along the `axis` dimension. This axis is removed, and
        replaced with new dimensions equal to the shape of the return value
        of `func1d`. So if `func1d` returns a scalar `out` will have one
        fewer dimensions than `arr`.

    See Also
    --------
    apply_over_axes : Apply a function repeatedly over multiple axes.

    Examples
    --------
    >>> def my_func(a):
    ...     """Average first and last element of a 1-D array"""
    ...     return (a[0] + a[-1]) * 0.5
    >>> b = np.array([[1,2,3], [4,5,6], [7,8,9]])
    >>> np.apply_along_axis(my_func, 0, b)
    array([4., 5., 6.])
    >>> np.apply_along_axis(my_func, 1, b)
    array([2.,  5.,  8.])

    For a function that returns a 1D array, the number of dimensions in
    `outarr` is the same as `arr`.

    >>> b = np.array([[8,1,7], [4,3,9], [5,2,6]])
    >>> np.apply_along_axis(sorted, 1, b)
    array([[1, 7, 8],
           [3, 4, 9],
           [2, 5, 6]])

    For a function that returns a higher dimensional array, those dimensions
    are inserted in place of the `axis` dimension.

    >>> b = np.array([[1,2,3], [4,5,6], [7,8,9]])
    >>> np.apply_along_axis(np.diag, -1, b)
    array([[[1, 0, 0],
            [0, 2, 0],
            [0, 0, 3]],
           [[4, 0, 0],
            [0, 5, 0],
            [0, 0, 6]],
           [[7, 0, 0],
            [0, 8, 0],
            [0, 0, 9]]])
    Nr&r'c3�,K�|]}|tfzV��dSrC)�Ellipsis)�.0�inds  r?�	<genexpr>z#apply_along_axis.<locals>.<genexpr>rs)����.�.�#�C�8�+��.�.�.�.�.�.rAz;Cannot apply_along_axis when any iteration dimensions are 0r)rr.r	r0r1rrrJ�next�
StopIterationr/rr*�
isinstancer�__array_prepare__�__array_wrap__)rPr8rErQrR�nd�in_dims�
inarr_view�inds�ind0�res�buff�	buff_dims�buff_permuterX�out_arrs                r?rrsb��x�S�/�/�C�	��B���b�)�)�D��5��9�9�o�o�G��3��������a����1A� A�T�F� J�K�K�J��:�#�C�R�C�(�)�)�D�.�.��.�.�.�D���D�z�z���������I�
�
��	������V�V�J�t�,�>�t�>�>�>�v�>�>�
?�
?�C���!�#�2�#�&���2�C�I�>�>�D��U�4�9�%�%�&�&�I��!�d�(���$�)�C�H�$�t�y�0�1�	2��$���3�8�+�+�,�	-���c�6�"�"�+��$�$�T�*�*���D��J��I�I���v�v�j��o�G��G�G�G��G�G�H�H��S�	�	��c�6�"�"�
+��!�!�$�'�'����|�,�,�,��D�,�/�/���!�!�'�*�*�*s�B&�&Cc��|fSrCrD)�func�a�axess   r?�_apply_over_axes_dispatcherrm��	��
�4�KrAc�"�t|��}|j}t|��jdkr|f}|D]Z}|dkr||z}||f}||�}|j|jkr|}�)t||��}|j|jkr|}�Lt	d���|S)ay
    Apply a function repeatedly over multiple axes.

    `func` is called as `res = func(a, axis)`, where `axis` is the first
    element of `axes`.  The result `res` of the function call must have
    either the same dimensions as `a` or one less dimension.  If `res`
    has one less dimension than `a`, a dimension is inserted before
    `axis`.  The call to `func` is then repeated for each axis in `axes`,
    with `res` as the first argument.

    Parameters
    ----------
    func : function
        This function must take two arguments, `func(a, axis)`.
    a : array_like
        Input array.
    axes : array_like
        Axes over which `func` is applied; the elements must be integers.

    Returns
    -------
    apply_over_axis : ndarray
        The output array.  The number of dimensions is the same as `a`,
        but the shape can be different.  This depends on whether `func`
        changes the shape of its output with respect to its input.

    See Also
    --------
    apply_along_axis :
        Apply a function to 1-D slices of an array along the given axis.

    Notes
    -----
    This function is equivalent to tuple axis arguments to reorderable ufuncs
    with keepdims=True. Tuple axis arguments to ufuncs have been available since
    version 1.7.0.

    Examples
    --------
    >>> a = np.arange(24).reshape(2,3,4)
    >>> a
    array([[[ 0,  1,  2,  3],
            [ 4,  5,  6,  7],
            [ 8,  9, 10, 11]],
           [[12, 13, 14, 15],
            [16, 17, 18, 19],
            [20, 21, 22, 23]]])

    Sum over axes 0 and 2. The result has same number of dimensions
    as the original array:

    >>> np.apply_over_axes(np.sum, a, [0,2])
    array([[[ 60],
            [ 92],
            [124]]])

    Tuple axis arguments to ufuncs are equivalent:

    >>> np.sum(a, axis=(0,2), keepdims=True)
    array([[[ 60],
            [ 92],
            [124]]])

    rz7function is not returning an array of the correct shape)rr.rrr/)rjrkrl�val�Nr8rQrds        r?rr�s���D�!�*�*�C�	��A��T�{�{��1����w���
B�
B���!�8�8��t�8�D��T�{���d�D�k���8�s�x����C�C��c�4�(�(�C��x�3�8�#�#���� �"A�B�B�B��JrAc��|fSrCrD)rkr8s  r?�_expand_dims_dispatcherrs�rnrAc����t|t��rt|��}nt|��}t	���t
tfvr�f�t���|jz}t�|���t|j�����fd�t|��D��}|�
|��S)a.
    Expand the shape of an array.

    Insert a new axis that will appear at the `axis` position in the expanded
    array shape.

    Parameters
    ----------
    a : array_like
        Input array.
    axis : int or tuple of ints
        Position in the expanded axes where the new axis (or axes) is placed.

        .. deprecated:: 1.13.0
            Passing an axis where ``axis > a.ndim`` will be treated as
            ``axis == a.ndim``, and passing ``axis < -a.ndim - 1`` will
            be treated as ``axis == 0``. This behavior is deprecated.

        .. versionchanged:: 1.18.0
            A tuple of axes is now supported.  Out of range axes as
            described above are now forbidden and raise an `AxisError`.

    Returns
    -------
    result : ndarray
        View of `a` with the number of dimensions increased.

    See Also
    --------
    squeeze : The inverse operation, removing singleton dimensions
    reshape : Insert, remove, and combine dimensions, and resize existing ones
    doc.indexing, atleast_1d, atleast_2d, atleast_3d

    Examples
    --------
    >>> x = np.array([1, 2])
    >>> x.shape
    (2,)

    The following is equivalent to ``x[np.newaxis, :]`` or ``x[np.newaxis]``:

    >>> y = np.expand_dims(x, axis=0)
    >>> y
    array([[1, 2]])
    >>> y.shape
    (1, 2)

    The following is equivalent to ``x[:, np.newaxis]``:

    >>> y = np.expand_dims(x, axis=1)
    >>> y
    array([[1],
           [2]])
    >>> y.shape
    (2, 1)

    ``axis`` may also be a tuple:

    >>> y = np.expand_dims(x, axis=(0, 1))
    >>> y
    array([[[1, 2]]])

    >>> y = np.expand_dims(x, axis=(2, 0))
    >>> y
    array([[[1],
            [2]]])

    Note that some examples may use ``None`` instead of ``np.newaxis``.  These
    are the same objects:

    >>> np.newaxis is None
    True

    c�:��g|]}|�vrdnt�����Sr%)rZ)rW�axr8�shape_its  ��r?�
<listcomp>zexpand_dims.<locals>.<listcomp>Xs+���K�K�K�R�"��*�*�Q�Q�$�x�.�.�K�K�KrA)r\rrr�typer5r0r-r.r
�iterrJr1r)rkr8�out_ndimrJrws `  @r?rrs�����X�!�V�����A�J�J����q�M�M���D�z�z�%���&�&��w���4�y�y�1�6�!�H���h�/�/�D��A�G�}�}�H�K�K�K�K�K�5��?�?�K�K�K�E��9�9�U���rAc� �t|��SrCr��tups r?�_column_stack_dispatcherr`���'��,�,�,rAc���g}|D]I}t|��}|jdkrt|ddd���j}|�|���Jtj|d��S)a�
    Stack 1-D arrays as columns into a 2-D array.

    Take a sequence of 1-D arrays and stack them as columns
    to make a single 2-D array. 2-D arrays are stacked as-is,
    just like with `hstack`.  1-D arrays are turned into 2-D columns
    first.

    Parameters
    ----------
    tup : sequence of 1-D or 2-D arrays.
        Arrays to stack. All of them must have the same first dimension.

    Returns
    -------
    stacked : 2-D array
        The array formed by stacking the given arrays.

    See Also
    --------
    stack, hstack, vstack, concatenate

    Examples
    --------
    >>> a = np.array((1,2,3))
    >>> b = np.array((2,3,4))
    >>> np.column_stack((a,b))
    array([[1, 2],
           [2, 3],
           [3, 4]])

    �FT��copy�subok�ndminr&)rr.r�Tr3r(�concatenate)r~�arrays�vrEs    r?rrdso��D�F�
������m�m���8�a�<�<���%�t�1�=�=�=�?�C��
�
�c������?�6�1�%�%�%rAc� �t|��SrCrr}s r?�_dstack_dispatcherr��r�rAc�n�t|�}t|t��s|g}tj|d��S)a�
    Stack arrays in sequence depth wise (along third axis).

    This is equivalent to concatenation along the third axis after 2-D arrays
    of shape `(M,N)` have been reshaped to `(M,N,1)` and 1-D arrays of shape
    `(N,)` have been reshaped to `(1,N,1)`. Rebuilds arrays divided by
    `dsplit`.

    This function makes most sense for arrays with up to 3 dimensions. For
    instance, for pixel-data with a height (first axis), width (second axis),
    and r/g/b channels (third axis). The functions `concatenate`, `stack` and
    `block` provide more general stacking and concatenation operations.

    Parameters
    ----------
    tup : sequence of arrays
        The arrays must have the same shape along all but the third axis.
        1-D or 2-D arrays must have the same shape.

    Returns
    -------
    stacked : ndarray
        The array formed by stacking the given arrays, will be at least 3-D.

    See Also
    --------
    concatenate : Join a sequence of arrays along an existing axis.
    stack : Join a sequence of arrays along a new axis.
    block : Assemble an nd-array from nested lists of blocks.
    vstack : Stack arrays in sequence vertically (row wise).
    hstack : Stack arrays in sequence horizontally (column wise).
    column_stack : Stack 1-D arrays as columns into a 2-D array.
    dsplit : Split array along third axis.

    Examples
    --------
    >>> a = np.array((1,2,3))
    >>> b = np.array((2,3,4))
    >>> np.dstack((a,b))
    array([[[1, 2],
            [2, 3],
            [3, 4]]])

    >>> a = np.array([[1],[2],[3]])
    >>> b = np.array([[2],[3],[4]])
    >>> np.dstack((a,b))
    array([[[1, 2]],
           [[2, 3]],
           [[3, 4]]])

    r�)rr\r0r(r�)r~�arrss  r?rr�s:��j�s��D��d�D�!�!���v���?�4��#�#�#rAc	��tt|����D]�}tj||��dkr%tjd||j���||<�Etjtjtj||��d����r$tjd||j���||<��|S)Nr�r*)	r1r-r(r.�emptyr*�sometrue�equalrJ)�sub_arys�is  r?�_replace_zero_by_x_arraysr��s���
�3�x�=�=�
!�
!�@�@���8�H�Q�K� � �A�%�%��)�A�X�a�[�->�?�?�?�H�Q�K�K�
�\�#�)�C�I�h�q�k�$:�$:�A�>�>�
?�
?�	@��)�A�X�a�[�->�?�?�?�H�Q�K���OrAc�
�||fSrCrD��ary�indices_or_sectionsr8s   r?�_array_split_dispatcherr������$�%�%rAc��	|j|}n#t$rt|��}YnwxYw	t|��dz}dgt|��z|gz}n�#t$r�t|��}|dkrt
d��d�t||��\}}dg||dzgzz||z
|gzz}tj	|tj
������}YnwxYwg}	tj||d��}
t|��D]F}||}||dz}
|	�tj|
||
�|d�����G|	S)a

    Split an array into multiple sub-arrays.

    Please refer to the ``split`` documentation.  The only difference
    between these functions is that ``array_split`` allows
    `indices_or_sections` to be an integer that does *not* equally
    divide the axis. For an array of length l that should be split
    into n sections, it returns l % n sub-arrays of size l//n + 1
    and the rest of size l//n.

    See Also
    --------
    split : Split array into multiple sub-arrays of equal size.

    Examples
    --------
    >>> x = np.arange(8.0)
    >>> np.array_split(x, 3)
    [array([0.,  1.,  2.]), array([3.,  4.,  5.]), array([6.,  7.])]

    >>> x = np.arange(9)
    >>> np.array_split(x, 4)
    [array([0, 1, 2]), array([3, 4]), array([5, 6]), array([7, 8])]

    r&rz&number sections must be larger than 0.Nr�)rJ�AttributeErrorr-r0�	TypeError�intr/�divmodr(r�intp�cumsum�swapaxesr1r3)r�r�r8�Ntotal�	Nsections�
div_points�
Neach_section�extras�
section_sizesr��saryr��st�ends              r?rr�s���6���4����������S����������
G��+�,�,�q�0�	��S�4� 3�4�4�4��x�?�
�
���	G�	G�	G��+�,�,�	���>�>��E�F�F�D�P� &�v�y� 9� 9��
�v����=��?�"3�3�4�#�F�*�}�o�=�>�
��Y�}�C�H�=�=�=�D�D�F�F�
�
�
�	G�����H��<��T�1�%�%�D�
�9�
�
�=�=��
��]����Q���������T�"�S�&�\�4��;�;�<�<�<�<��Os�
�,�,�)A�BC(�'C(c�
�||fSrCrDr�s   r?�_split_dispatcherr�r�rAc��	t|��n4#t$r'|}|j|}||zrtd��d�YnwxYwt	|||��S)a�
    Split an array into multiple sub-arrays as views into `ary`.

    Parameters
    ----------
    ary : ndarray
        Array to be divided into sub-arrays.
    indices_or_sections : int or 1-D array
        If `indices_or_sections` is an integer, N, the array will be divided
        into N equal arrays along `axis`.  If such a split is not possible,
        an error is raised.

        If `indices_or_sections` is a 1-D array of sorted integers, the entries
        indicate where along `axis` the array is split.  For example,
        ``[2, 3]`` would, for ``axis=0``, result in

          - ary[:2]
          - ary[2:3]
          - ary[3:]

        If an index exceeds the dimension of the array along `axis`,
        an empty sub-array is returned correspondingly.
    axis : int, optional
        The axis along which to split, default is 0.

    Returns
    -------
    sub-arrays : list of ndarrays
        A list of sub-arrays as views into `ary`.

    Raises
    ------
    ValueError
        If `indices_or_sections` is given as an integer, but
        a split does not result in equal division.

    See Also
    --------
    array_split : Split an array into multiple sub-arrays of equal or
                  near-equal size.  Does not raise an exception if
                  an equal division cannot be made.
    hsplit : Split array into multiple sub-arrays horizontally (column-wise).
    vsplit : Split array into multiple sub-arrays vertically (row wise).
    dsplit : Split array into multiple sub-arrays along the 3rd axis (depth).
    concatenate : Join a sequence of arrays along an existing axis.
    stack : Join a sequence of arrays along a new axis.
    hstack : Stack arrays in sequence horizontally (column wise).
    vstack : Stack arrays in sequence vertically (row wise).
    dstack : Stack arrays in sequence depth wise (along third dimension).

    Examples
    --------
    >>> x = np.arange(9.0)
    >>> np.split(x, 3)
    [array([0.,  1.,  2.]), array([3.,  4.,  5.]), array([6.,  7.,  8.])]

    >>> x = np.arange(8.0)
    >>> np.split(x, [3, 5, 6, 10])
    [array([0.,  1.,  2.]),
     array([3.,  4.]),
     array([5.]),
     array([6.,  7.]),
     array([], dtype=float64)]

    z0array split does not result in an equal divisionN)r-r�rJr/r)r�r�r8�sectionsrqs     r?rrs���FN��� � � � ���N�N�N�&���I�d�O���x�<�	N��B�D�D�IM�
N�	N�	N�N�����s�/��6�6�6s��.A�Ac�
�||fSrCrD�r�r�s  r?�_hvdsplit_dispatcherr�er�rAc��tj|��dkrtd���|jdkrt||d��St||d��S)a]
    Split an array into multiple sub-arrays horizontally (column-wise).

    Please refer to the `split` documentation.  `hsplit` is equivalent
    to `split` with ``axis=1``, the array is always split along the second
    axis except for 1-D arrays, where it is split at ``axis=0``.

    See Also
    --------
    split : Split an array into multiple sub-arrays of equal size.

    Examples
    --------
    >>> x = np.arange(16.0).reshape(4, 4)
    >>> x
    array([[ 0.,   1.,   2.,   3.],
           [ 4.,   5.,   6.,   7.],
           [ 8.,   9.,  10.,  11.],
           [12.,  13.,  14.,  15.]])
    >>> np.hsplit(x, 2)
    [array([[  0.,   1.],
           [  4.,   5.],
           [  8.,   9.],
           [12.,  13.]]),
     array([[  2.,   3.],
           [  6.,   7.],
           [10.,  11.],
           [14.,  15.]])]
    >>> np.hsplit(x, np.array([3, 6]))
    [array([[ 0.,   1.,   2.],
           [ 4.,   5.,   6.],
           [ 8.,   9.,  10.],
           [12.,  13.,  14.]]),
     array([[ 3.],
           [ 7.],
           [11.],
           [15.]]),
     array([], shape=(4, 0), dtype=float64)]

    With a higher dimensional array the split is still along the second axis.

    >>> x = np.arange(8.0).reshape(2, 2, 2)
    >>> x
    array([[[0.,  1.],
            [2.,  3.]],
           [[4.,  5.],
            [6.,  7.]]])
    >>> np.hsplit(x, 2)
    [array([[[0.,  1.]],
           [[4.,  5.]]]),
     array([[[2.,  3.]],
           [[6.,  7.]]])]

    With a 1-D array, the split is along axis 0.

    >>> x = np.array([0, 1, 2, 3, 4, 5])
    >>> np.hsplit(x, 2)
    [array([0, 1, 2]), array([3, 4, 5])]

    rz3hsplit only works on arrays of 1 or more dimensionsr&�r(r.r/rr�s  r?rrisX��|�x��}�}�����N�O�O�O�
�x�!�|�|��S�-�q�1�1�1��S�-�q�1�1�1rAc�r�tj|��dkrtd���t||d��S)a
    Split an array into multiple sub-arrays vertically (row-wise).

    Please refer to the ``split`` documentation.  ``vsplit`` is equivalent
    to ``split`` with `axis=0` (default), the array is always split along the
    first axis regardless of the array dimension.

    See Also
    --------
    split : Split an array into multiple sub-arrays of equal size.

    Examples
    --------
    >>> x = np.arange(16.0).reshape(4, 4)
    >>> x
    array([[ 0.,   1.,   2.,   3.],
           [ 4.,   5.,   6.,   7.],
           [ 8.,   9.,  10.,  11.],
           [12.,  13.,  14.,  15.]])
    >>> np.vsplit(x, 2)
    [array([[0., 1., 2., 3.],
           [4., 5., 6., 7.]]), array([[ 8.,  9., 10., 11.],
           [12., 13., 14., 15.]])]
    >>> np.vsplit(x, np.array([3, 6]))
    [array([[ 0.,  1.,  2.,  3.],
           [ 4.,  5.,  6.,  7.],
           [ 8.,  9., 10., 11.]]), array([[12., 13., 14., 15.]]), array([], shape=(0, 4), dtype=float64)]

    With a higher dimensional array the split is still along the first axis.

    >>> x = np.arange(8.0).reshape(2, 2, 2)
    >>> x
    array([[[0.,  1.],
            [2.,  3.]],
           [[4.,  5.],
            [6.,  7.]]])
    >>> np.vsplit(x, 2)
    [array([[[0., 1.],
            [2., 3.]]]), array([[[4., 5.],
            [6., 7.]]])]

    r�z3vsplit only works on arrays of 2 or more dimensionsrr�r�s  r?rr�s:��X�x��}�}�q����N�O�O�O���)�1�-�-�-rAc�r�tj|��dkrtd���t||d��S)am
    Split array into multiple sub-arrays along the 3rd axis (depth).

    Please refer to the `split` documentation.  `dsplit` is equivalent
    to `split` with ``axis=2``, the array is always split along the third
    axis provided the array dimension is greater than or equal to 3.

    See Also
    --------
    split : Split an array into multiple sub-arrays of equal size.

    Examples
    --------
    >>> x = np.arange(16.0).reshape(2, 2, 4)
    >>> x
    array([[[ 0.,   1.,   2.,   3.],
            [ 4.,   5.,   6.,   7.]],
           [[ 8.,   9.,  10.,  11.],
            [12.,  13.,  14.,  15.]]])
    >>> np.dsplit(x, 2)
    [array([[[ 0.,  1.],
            [ 4.,  5.]],
           [[ 8.,  9.],
            [12., 13.]]]), array([[[ 2.,  3.],
            [ 6.,  7.]],
           [[10., 11.],
            [14., 15.]]])]
    >>> np.dsplit(x, np.array([3, 6]))
    [array([[[ 0.,   1.,   2.],
            [ 4.,   5.,   6.]],
           [[ 8.,   9.,  10.],
            [12.,  13.,  14.]]]),
     array([[[ 3.],
            [ 7.]],
           [[11.],
            [15.]]]),
    array([], shape=(2, 2, 0), dtype=float64)]
    �z3dsplit only works on arrays of 3 or more dimensionsr�r�r�s  r?rr�s:��P�x��}�}�q����N�O�O�O���)�1�-�-�-rAc�r�td�t|��D����}|r|ddSdS)��Find the wrapper for the array with the highest priority.

    In case of ties, leftmost wins. If no wrapper is found, return None
    c3�pK�|]1\}}t|d���t|dd��||jfV��2dS)r]�__array_priority__rN)�hasattr�getattrr]�rWr��xs   r?rYz$get_array_prepare.<locals>.<genexpr>so����G�G�*.�!�Q�&-�a�1D�&E�&E�G�w�q�"6��:�:�Q�B��$�&�G�G�G�G�G�GrAr'N��sorted�	enumerate�rQ�wrapperss  r?�get_array_preparer�
sZ��
�G�G�2;�D�/�/�G�G�G�G�G�H�� ���|�B����4rAc�r�td�t|��D����}|r|ddSdS)r�c3�pK�|]1\}}t|d���t|dd��||jfV��2dS)r^r�rN)r�r�r^r�s   r?rYz!get_array_wrap.<locals>.<genexpr>so����D�D�'+�q�!�&-�a�1A�&B�&B�D�w�q�"6��:�:�Q�B��!�#�D�D�D�D�D�DrAr'Nr�r�s  r?rrsZ��
�D�D�/8����D�D�D�D�D�H�� ���|�B����4rAc�
�||fSrCrD)rk�bs  r?�_kron_dispatcherr�'s��
�q�6�MrAc
�4�t|��}t|dd|j���}t|t��pt|t��}|j|j}}t||��}|dks|dkrt
j||��S|j}|j}|j	j
st||��}|j	j
st||��}dtd||z
��z|z}dtd||z
��z|z}t|tt||z
�������}t|tt||z
�������}	t|ttd|dzd�������}t|	ttd|dzd�������}	t
j||	|�	��}
|
�t
j||����}
|s|
nt	|
d�
��S)a
    Kronecker product of two arrays.

    Computes the Kronecker product, a composite array made of blocks of the
    second array scaled by the first.

    Parameters
    ----------
    a, b : array_like

    Returns
    -------
    out : ndarray

    See Also
    --------
    outer : The outer product

    Notes
    -----
    The function assumes that the number of dimensions of `a` and `b`
    are the same, if necessary prepending the smallest with ones.
    If ``a.shape = (r0,r1,..,rN)`` and ``b.shape = (s0,s1,...,sN)``,
    the Kronecker product has shape ``(r0*s0, r1*s1, ..., rN*SN)``.
    The elements are products of elements from `a` and `b`, organized
    explicitly by::

        kron(a,b)[k0,k1,...,kN] = a[i0,i1,...,iN] * b[j0,j1,...,jN]

    where::

        kt = it * st + jt,  t = 0,...,N

    In the common 2-D case (N=1), the block structure can be visualized::

        [[ a[0,0]*b,   a[0,1]*b,  ... , a[0,-1]*b  ],
         [  ...                              ...   ],
         [ a[-1,0]*b,  a[-1,1]*b, ... , a[-1,-1]*b ]]


    Examples
    --------
    >>> np.kron([1,10,100], [5,6,7])
    array([  5,   6,   7, ..., 500, 600, 700])
    >>> np.kron([5,6,7], [1,10,100])
    array([  5,  50, 500, ...,   7,  70, 700])

    >>> np.kron(np.eye(2), np.ones((2,2)))
    array([[1.,  1.,  0.,  0.],
           [1.,  1.,  0.,  0.],
           [0.,  0.,  1.,  1.],
           [0.,  0.,  1.,  1.]])

    >>> a = np.arange(100).reshape((2,5,2,5))
    >>> b = np.arange(24).reshape((2,3,4))
    >>> c = np.kron(a,b)
    >>> c.shape
    (2, 10, 6, 20)
    >>> I = (1,3,0,2)
    >>> J = (0,2,1)
    >>> J1 = (0,) + J             # extend to ndim=4
    >>> S1 = (1,) + b.shape
    >>> K = tuple(np.array(I) * np.array(S1) + np.array(J1))
    >>> c[K] == a[I]*b[J]
    True

    FTr�rr%)r8r&r�)r�)r�)rrr.r\r�maxr(�multiplyrJ�flags�
contiguousrrr5r1)rkr��
is_any_mat�ndb�ndar_�as_�bs�a_arr�b_arr�results           r?rr+s���\	�1�
�
�A�
�a�e�4�q�v�6�6�6�A��A�v�&�&�?�*�Q��*?�*?�J��v�q�v��C�	�S�#���B��q���C�1�H�H��|�A�q�!�!�!�
�'�C�	
��B��7����A�s�O�O���7����A�r�N�N���s�1�c�#�g���
��
$�C�	
�c�!�S��W�o�o�	��	"�B�
���e�C��G�n�n� 5� 5�6�6�6�E����e�C��G�n�n� 5� 5�6�6�6�E�
��E�%��2�a�4��*;�*;�$<�$<�=�=�=�E���E�%��2�a�4��*;�*;�$<�$<�=�=�=�E�
�\�%��:�~�
?�
?�
?�F��^�^�C�L��b�1�1�
2�
2�F�#�C�6�6���U�)C�)C�)C�CrAc�
�||fSrCrD)�A�repss  r?�_tile_dispatcherr��s��
�t�9�rAc��	t|��}n#t$r|f}YnwxYwt|��}td�|D����r2t	|t
j��rtj|dd|���Stj|dd|���}||jkrd|j|z
z|z}td�t|j
|��D����}|j}|dkrPt|j
|��D]:\}}|dkr*|�d	|���
|d��}||z}�;|�|��S)
a
    Construct an array by repeating A the number of times given by reps.

    If `reps` has length ``d``, the result will have dimension of
    ``max(d, A.ndim)``.

    If ``A.ndim < d``, `A` is promoted to be d-dimensional by prepending new
    axes. So a shape (3,) array is promoted to (1, 3) for 2-D replication,
    or shape (1, 1, 3) for 3-D replication. If this is not the desired
    behavior, promote `A` to d-dimensions manually before calling this
    function.

    If ``A.ndim > d``, `reps` is promoted to `A`.ndim by pre-pending 1's to it.
    Thus for an `A` of shape (2, 3, 4, 5), a `reps` of (2, 2) is treated as
    (1, 1, 2, 2).

    Note : Although tile may be used for broadcasting, it is strongly
    recommended to use numpy's broadcasting operations and functions.

    Parameters
    ----------
    A : array_like
        The input array.
    reps : array_like
        The number of repetitions of `A` along each axis.

    Returns
    -------
    c : ndarray
        The tiled output array.

    See Also
    --------
    repeat : Repeat elements of an array.
    broadcast_to : Broadcast an array to a new shape

    Examples
    --------
    >>> a = np.array([0, 1, 2])
    >>> np.tile(a, 2)
    array([0, 1, 2, 0, 1, 2])
    >>> np.tile(a, (2, 2))
    array([[0, 1, 2, 0, 1, 2],
           [0, 1, 2, 0, 1, 2]])
    >>> np.tile(a, (2, 1, 2))
    array([[[0, 1, 2, 0, 1, 2]],
           [[0, 1, 2, 0, 1, 2]]])

    >>> b = np.array([[1, 2], [3, 4]])
    >>> np.tile(b, 2)
    array([[1, 2, 1, 2],
           [3, 4, 3, 4]])
    >>> np.tile(b, (2, 1))
    array([[1, 2],
           [3, 4],
           [1, 2],
           [3, 4]])

    >>> c = np.array([1,2,3,4])
    >>> np.tile(c,(4,1))
    array([[1, 2, 3, 4],
           [1, 2, 3, 4],
           [1, 2, 3, 4],
           [1, 2, 3, 4]])
    c3�"K�|]
}|dkV��dS)r&NrD)rWr�s  r?rYztile.<locals>.<genexpr>�s&����
�
�a�1��6�
�
�
�
�
�
rATr�Fr%c3�&K�|]\}}||zV��
dSrCrD)rW�s�ts   r?rYztile.<locals>.<genexpr>�s*����8�8�d�a��a��c�8�8�8�8�8�8rArr&r')r5r�r-�allr\r(�ndarrayrr.r2rJ�sizer�repeat)	r�r�r~�d�c�	shape_outr=�dim_in�nreps	         r?rr�sl��F��D�k�k���������g���������C���A�
�
�
�3�
�
�
���:�J�q�#�+�$>�$>�:��y���T��;�;�;�;�
�I�a�e�4�q�9�9�9��	�A�F�
�
��A�F�1�H�o��#���8�8�c�!�'�3�&7�&7�8�8�8�8�8�I�	��A��1�u�u�����-�-�	�	�L�F�D��q�y�y��I�I�b�!�$�$�+�+�D�!�4�4��
�&�L�A�A��9�9�Y���s��
"�"rC)r);�	functools�numpy.core.numeric�core�numericr(rrrr�numpy.core.fromnumericrr�numpy.core.multiarrayr	�
numpy.corer
rrr
�numpy.core.shape_baser�numpy.lib.index_tricksr�numpy.matrixlib.defmatrixr�__all__�partial�array_function_dispatchr@rFr rMr!rSrrmrrsrrrrr�rr�r�rr�rr�rrrr�rr�rr�rrDrAr?�<module>r�s������� � � � � � � � � �@�@�@�@�@�@�@�@�@�@�@�@�5�5�5�5�5�5�5�5�6�6�6�6�6�6� � � � � � �)�)�)�)�)�)�)�)�3�3�3�3�3�3�>�>�>�>�>�>�*�*�*�*�*�*�,�,�,�,�,�,�����,�)�+�
�%�g�7�7�7�����.�����4�5�5�s?�s?�6�5�s?�l"�"�"���3�4�4�RA�RA�5�4�RA�j�����5�6�6�R+�R+�7�6�R+�j�����4�5�5�S�S�6�5�S�l�����0�1�1�Y�Y�2�1�Y�x
�	�-�-�-���1�2�2�'&�'&�3�2�'&�T-�-�-���+�,�,�7$�7$�-�,�7$�t���&�&�&�&���0�1�1�4�4�4�2�1�4�n&�&�&�&���*�+�+�J7�J7�J7�,�+�J7�Z&�&�&���-�.�.�B2�B2�/�.�B2�J��-�.�.�-.�-.�/�.�-.�`��-�.�.�).�).�/�.�).�X
�
�
�
�
�
������)�*�*�nD�nD�+�*�nD�b�����)�*�*�X �X �+�*�X �X �X rA