'T}. P d dl Z d dlZd dlZd dlZd dlZddlmZ d dlm c m Z d dlmZm Z d dlmZ d dlmZ ddlmZ d dlmZmZ d d lmZmZ d d lmZ e j ej d Zg d Zd Z ee d Z G d d Z! G d de! Z" e" Z# G d de! Z$ e$ Z% G d d Z& G d de& Z' e' Z( G d de& Z) e) Z* ed G d d Z+ ed G d d Z, G d d! Z- e-d"# Z. e-d$# Z/d*d%Z0 ee0 d+d& Z1 ed d,d' Z2d( Z3 ee3 d) Z4dS )- N ) set_module) ScalarTypearray) issubdtype )diff)ravel_multi_index unravel_index) overrideslinspace) as_stridednumpy)module)r r mgridogridr_c_s_ index_expix_ndenumeratendindex fill_diagonaldiag_indicesdiag_indices_fromc | S N )argss j/builddir/build/BUILD/cloudlinux-venv-1.0.10/venv/lib64/python3.11/site-packages/numpy/lib/index_tricks.py_ix__dispatcherr" s K c > g }t | }t | D ]\ }}t |t j s>t j | }|j dk r| t j }|j dk rt d t |j t j r| \ }| d|z |j fz d||z dz z z }| | t% | S )a5 Construct an open mesh from multiple sequences. This function takes N 1-D sequences and returns N outputs with N dimensions each, such that the shape is 1 in all but one dimension and the dimension with the non-unit shape value cycles through all N dimensions. Using `ix_` one can quickly construct index arrays that will index the cross product. ``a[np.ix_([1,3],[2,5])]`` returns the array ``[[a[1,2] a[1,5]], [a[3,2] a[3,5]]]``. Parameters ---------- args : 1-D sequences Each sequence should be of integer or boolean type. Boolean sequences will be interpreted as boolean masks for the corresponding dimension (equivalent to passing in ``np.nonzero(boolean_sequence)``). Returns ------- out : tuple of ndarrays N arrays with N dimensions each, with N the number of input sequences. Together these arrays form an open mesh. See Also -------- ogrid, mgrid, meshgrid Examples -------- >>> a = np.arange(10).reshape(2, 5) >>> a array([[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]]) >>> ixgrid = np.ix_([0, 1], [2, 4]) >>> ixgrid (array([[0], [1]]), array([[2, 4]])) >>> ixgrid[0].shape, ixgrid[1].shape ((2, 1), (1, 2)) >>> a[ixgrid] array([[2, 4], [7, 9]]) >>> ixgrid = np.ix_([True, True], [2, 4]) >>> a[ixgrid] array([[2, 4], [7, 9]]) >>> ixgrid = np.ix_([True, True], [False, False, True, False, True]) >>> a[ixgrid] array([[2, 4], [7, 9]]) r r z!Cross index must be 1 dimensional)r )len enumerate isinstance_nxndarraynpasarraysizeastypeintpndim ValueErrorr dtypebool_nonzeroreshapeappendtuple)r outndknews r! r r " s t C TBD// 3#s{++ +*S//Cx1}}jj**8q==@AAAci++ !;;==DCkk$q&CH;.r!tAv>?? 3::r# c e Zd ZdZddZd ZdS )nd_grida Construct a multi-dimensional "meshgrid". ``grid = nd_grid()`` creates an instance which will return a mesh-grid when indexed. The dimension and number of the output arrays are equal to the number of indexing dimensions. If the step length is not a complex number, then the stop is not inclusive. However, if the step length is a **complex number** (e.g. 5j), then the integer part of its magnitude is interpreted as specifying the number of points to create between the start and stop values, where the stop value **is inclusive**. If instantiated with an argument of ``sparse=True``, the mesh-grid is open (or not fleshed out) so that only one-dimension of each returned argument is greater than 1. Parameters ---------- sparse : bool, optional Whether the grid is sparse or not. Default is False. Notes ----- Two instances of `nd_grid` are made available in the NumPy namespace, `mgrid` and `ogrid`, approximately defined as:: mgrid = nd_grid(sparse=False) ogrid = nd_grid(sparse=True) Users should use these pre-defined instances instead of using `nd_grid` directly. Fc || _ d S r sparse)selfr? s r! __init__znd_grid.__init__ s r# c g }dg}t t | D ]}|| j }|| j }|| j }|d}|d}t |t j t f r2t | }| t | n=| t t j ||z |dz z ||||gz }t j | }| j r,d t! ||ft | z D } nt j || } t% | D ]\ }} | j }| j }|d}|d}t |t j t f r?t t | }|dk r| j |z t' |dz z }| | |z |z | |<