§ <ˆjrz ã ó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)Ú ScalarTypeÚarray)Ú issubdtypeé )Údiff)Úravel_multi_indexÚ unravel_index)Ú overridesÚlinspace)Ú as_stridedÚnumpy)Úmodule)r r ÚmgridÚogridÚr_Úc_Ús_Ú index_expÚix_ÚndenumerateÚndindexÚ fill_diagonalÚdiag_indicesÚdiag_indices_fromc ó — | S ©N© )Úargss úM/opt/cloudlinux/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Ú_nxÚndarrayÚnpÚasarrayÚsizeÚastypeÚintpÚndimÚ ValueErrorr ÚdtypeÚbool_ÚnonzeroÚreshapeÚappendÚtuple)r ÚoutÚndÚkÚnews r! r r " sø € ðt €CÝ ˆT‰Œ€BݘD‘/”/ð 𠉈ˆ3ݘ#�sœ{Ñ+Ô+ð +Ý”*˜S‘/”/ˆCØŒx˜1Š}ˆ}à—j’j¥¤Ñ*Ô*�ØŒ8�qŠ=ˆ=ÝÐ@ÑAÔAÐAÝ�c”i¥¤Ñ+Ô+ð !Ø—;’;‘=”=‰DˆCØ�kŠk˜$˜q™& C¤H ;Ñ.°°r¸!±t¸A±v±Ñ>Ñ?Ô?ˆØ� Š �3‰ŒˆˆÝ�‰:Œ:Ðr# c ó — e Zd ZdZdd„Zd„ 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 | |<