+
    ,i?                     j    R t ^ RIt^RIHt ^RIHtHt ]]P                  3t
R t ! R R4      tR tR# )z0Indexing mixin for sparse array/matrix classes.
N)	isintlike)sparrayissparsec                    \         P                  ! W4      w  r#V P                  P                  VP                  n        VP                  P                  VP                  n        W#3# )a  
Same as np.broadcast_arrays(a, b) but old writeability rules.

NumPy >= 1.17.0 transitions broadcast_arrays to return
read-only arrays. Set writeability explicitly to avoid warnings.
Retain the old writeability rules, as our Cython code assumes
the old behavior.
)npbroadcast_arraysflags	writeable)abxys   &&  5/usr/lib/python3/dist-packages/scipy/sparse/_index.py_broadcast_arraysr   
   sI     q$DA))AGG))AGG4K    c                      a  ] tR t^t o RtR tR tR tR tR t	R t
R tR	 tR
 tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tRtV tR# )
IndexMixinzK
This class provides common dispatching and validation logic for indexing.
c                
   V P                  V4      w  r#\        V4      ^8X  EdJ   V^ ,          p\        V\        P                  4      '       d"   VP
                  R8X  d   VP                  4       p\        V\        4      '       d   V P                  V4      pM9\        V\        4      '       d   V P                  V4      pMV P                  V4      p\        V \        4      '       g   V# VP
                  R8X  de   VR8w  d^   \        V4      ^8X  d   V P                  V.W0P                  R7      # \        V4      ^8X  d    V P                  V..W0P                  R7      # VP                  V4      # Vw  rg\        V\        4      '       d   \        V\        4      '       d   V P!                  Wg4      pEM\        V\        4      '       d   V P#                  Wg4      pEMoVP$                  ^8X  d   V P'                  Wg4      pEMKVP$                  ^8X  d   V P'                  Wg4      pEM'\)        R4      h\        V\        4      '       d   \        V\        4      '       d   V P+                  Wg4      pEM\        V\        4      '       d<   V\        R4      8X  d   Wg8X  d   V P-                  4       pEMV P/                  Wg4      pEMVP$                  ^8X  d   V P1                  Wg4      pEMh\)        R4      h\        V\        4      '       d   V P3                  Wg4      pEM4\        V\        4      '       d   V P5                  Wg4      pEMVP$                  ^8X  dj   VP
                  ^,          ^8X  dR   VP$                  ^8X  g   VP
                  ^ ,          ^8X  d)   V P7                  VR	,          VP9                  4       4      pM\;        Wg4      w  rgVP
                  VP
                  8w  d   \)        R4      hVP<                  ^ 8X  d=   V P                  \        P>                  ! V4      P
                  V P                  R7      pMV PA                  Wg4      p\        V \        4      '       gg   VR8X  g"   \        V4      ^8X  d   VP$                  ^ 8w  d   V# \        V4      ^8X  d
   R
V,           pW5P
                  8X  d   V# VP                  V4      # VP
                  V8w  dw   V PB                  R8X  dU   \        V4      ^8w  dE   VP
                  R8X  d   V PE                  V.VR7      # VPG                  4       P                  V4      # VP                  V4      # V# )   )shapedtypezindex results in >2 dimensionsN'number of row and column indices differr   lilr    )NNN    )r   )$_validate_indiceslen
isinstancer   ndarrayr   item	INT_TYPES_get_intslice
_get_slice
_get_arrayr   	__class__r   reshape_get_intXint_get_intXslicendim_get_intXarray
IndexError_get_sliceXintcopy_get_sliceXslice_get_sliceXarray_get_arrayXint_get_arrayXslice_get_columnXarrayravelr   size
atleast_2d_get_arrayXarrayformat_coo_containertocoo)selfkeyindex	new_shapeidxresrowcols   &&      r   __getitem__IndexMixin.__getitem__   s   11#6 u:?(C#rzz**99?((*C#y))mmC(C''ooc*ooc* dG,,
yyB9?y>Q&>>3%y

>SSy>Q&>>C5'**>UU;;y))  c9%%#y))''1C''))#3Q))#3Q))#3 !ABBU###y))))#3C''%+%#*))+C//9CQ++C5 !ABB#y))))#3C''++C5((a-CIIaLA$5XX]ciila&7,,SY		D -S699		)$%NOO88q=..s);)A)A.TC//9C $((B3y>Q#6388q=
9~" 9,	#yy03Lckk)6LL 99	!{{e#I!(;99?..ui.HHyy{**955;;y))
r   c                   V P                  V4      w  r4\        V4      ^8X  Ed   V^ ,          p\        V4      '       d   VP                  4       pM!\        P
                  ! W P                  R7      p\        V\        4      '       dA   VP                  ^8w  d   \        R4      hV P                  WRP                  ^ ,          4       R# \        V\        4      '       d   \        VP                  V P                   ^ ,          4      !  p\        V4      pV^8X  d>   VP                  ^8X  d-   V P                  V^ ,          VP                  ^ ,          4       R# \        P"                  ! VP                  V P                   ^ ,          4      !  pVP                   pMVP%                  4       P                   pVP%                  4       P                   V8w  d!   \        P&                  ! W%P                   4      pVP                  ^ 8w  d   V P)                  WR4       R# Vw  r\        V	\        4      '       dy   \        V
\        4      '       dc   \        P
                  ! W P                  R7      pVP                  ^8w  d   \        R4      hV P+                  WVP                  ^ ,          4       R# \        V	\        4      '       d=   \        P"                  ! V	P                  V P                   ^ ,          4      !  R	,          p	M\        P,                  ! V	4      p	\        V
\        4      '       dW   \        P"                  ! V
P                  V P                   ^,          4      !  R
,          p
V	P.                  ^8X  d
   V	R	,          p	M\        P,                  ! V
4      p
\1        W4      w  rVP                   VP                   8w  d   \3        R4      h\        V4      '       Ed]   ^ VP                   9   d   R# VP.                  ^8X  d   VR,          pVR,          pVP5                  RR7      P7                  VP8                  RR7      pVP                   ^ ,          ^8H  ;'       d    VP                   ^ ,          ^8g  pVP                   ^,          ^8H  ;'       d    VP                   ^,          ^8g  pV'       g*   VP                   ^ ,          VP                   ^ ,          8X  d2   V'       g5   VP                   ^,          VP                   ^,          8X  g   \        R4      hVP;                  4        V P=                  WV4       R# \        P
                  ! W P                  R7      pVP%                  4       P                   VP%                  4       P                   8w  d!   \        P&                  ! W+P                   4      pVP                  ^ 8X  d   R# VP7                  VP                   4      pV P?                  WV4       R# )r   r   z&Trying to assign a sequence to an itemNr   F)r0   Tzshape mismatch in assignment)r   N)Nr   ) r   r   r   toarrayr   asarrayr   r    r#   r7   
ValueError_set_intflatr%   rangeindicesr   arangesqueezebroadcast_to
_set_array_set_intXint
atleast_1dr,   r   r.   r<   r)   _shape_as_2dsum_duplicates_set_arrayXarray_sparse_set_arrayXarray)r=   r>   r   r?   _rA   	idx_rangeN	idx_shaperC   rD   ijbroadcast_rowbroadcast_cols   &&&            r   __setitem__IndexMixin.__setitem__|   s   ))#. u:?(C{{IIKJJq

3#y))66Q;$%MNNc66!9-#u%% "3;;tzz!}#=>		N6affkMM)A,q	:iiTZZ]!;<II	KKM//	yy{  I-OOAyy1vv{' c9%%*S)*D*D

1JJ/Avv{ !IJJcq	2c5!!))S[[A78AC--$Cc5!!))S[[A78ACxx1}'l--$C *77aggFGGA;;AGG|vv{dGdGU#++ANN+FAGGAJ!O??
aMGGAJ!O??
aM"aggajAGGAJ&>"aggajAGGAJ&> !?@@((q1 

1JJ/Ayy{  AIIK$5$55OOAww/vv{		!''"A!!!*r   c           	     
  aa V\         J d*   \        R4      3V P                  ,          V P                  3# \	        V\
        4      '       g   V.pRp. p^ p\        V4       EF  w  rVV\         J d   Ve   \        R4      hTpK#  Vf   VP                  V4       K:  \	        V\        4      '       g   \        V4      '       d   VP                  V4       V^,          pK}  \        W`P                  4      ;pe&   VP                  V4       WGP                  ,          pK  \        V4      '       d   \        R4      hVP                  \        P                  ! V4      4       V^,          pEK  	  V P                  V,
          \        R4      .,          pV'       d,   Vf   VP                  V4       MVRV V,           W2R ,           p. p	^ p
. o. p\        V4       EF	  w  rVVf   V	P                  ^4       K  \	        V\        4      '       db   SP                  V4       V P                  V
,          p\!        \#        VP%                  V4      !  4      pV	P                  V4       V
^,          p
K  \        V4      '       dl   V P                  V
,          pV) Tu;8:  d   V8  g   M \        RV R24      h\'        V^ 8  d	   Wn,           MT4      pSP                  V4       V
^,          p
EK  VP(                  P*                  R8X  d   TpWP                  ,           pV P                  W pVP                  V8w  d   \        RV RV R	VP                   24      hSP                  VP-                  4       4       VP                  \#        W4      4       Tp
EK  V P                  V
,          pV P/                  Wn4      pSP                  V4       VP                  V
4       V
^,          p
EK  	  WP                  8  d   \        R
V P                   RV
 R24      h\!        V4      ^8  d   \1        V3R lV 4       !  o\2        ;QJ d&    V3R lSR,           4       F  '       g   K   RM	  RM! V3R lSR,           4       4      '       d)   RP5                  R S 4       4      pRV 2p\        V4      h\7        S^ ,          P                  4      V	,           p	MK\!        V4      ^8X  d<   V^ ,          p\7        SV,          P                  4      pV	RV V,           V	VR ,           p	\!        V	4      ;p^8  d   \        RV R24      h\        S4      \        V	4      3# )z8Returns two tuples: (index tuple, requested shape tuple)Nz(an index can only have a single ellipsiszoIndexing with sparse matrices is not supported except boolean indexing where matrix and index are equal shapes.index () out of ranger   zbool index z has shape z instead of zinvalid index ndim. Array is zD. Index needs Dc              3   6   <"   T F  pSV,          x  K  	  R # 5iNr   ).0r]   r?   s   & r   	<genexpr>/IndexMixin._validate_indices.<locals>.<genexpr>)  s     ,M}!U1XX}s   c              3   d   <"   T F%  pS^ ,          P                   VP                   8g  x  K'  	  R# 5i)r   Nr   )ri   ix
idx_arrayss   & r   rj   rk   *  s$     L^r:a=&&"((2^s   -0:r   NNTF c              3   L   "   T F  p\        VP                  4      x  K  	  R # 5irh   )strr   )ri   rm   s   & r   rj   rk   +  s     !E*B#bhh--*s   "$zLshape mismatch: indexing arrays could not be broadcast together with shapes z*Only 1D or 2D arrays allowed. Index makes )Ellipsisr%   r,   r   r    tuple	enumerater.   appendr   _compatible_boolean_indexr   r   rI   extend_shaper   rM   rN   intr   kindnonzero
_asindicesr   anyjoinlist)r=   r>   	ellps_pos	index_1stprelim_ndimr]   rA   rm   ellip_slicesr\   
index_ndimarray_indicesMs	len_slicer[   tmp_ndim	mid_shapeshapesmsg	arr_index	arr_shaper,   rn   r?   s   &&                    @@r   r   IndexMixin._validate_indices   su    (?$K>DII-tzz99#u%%%C		nFAh($%OPP	  %C''9S>>  %q 1#yyAA"N  $ww&# () )
   C1q + %, 		K/E$K=@   .%jy1L@9ZCXX	 	
	*FA{  #C''S![[,s{{2 78	  +a
3KK
+cA$wse>%BCCS1W#'#6S!a
3&%/ KK
<	88y($%aSI;l288*U  RZZ\*$$U:%@A%
KK
+ooc-S!$$Z0a
C +D 		!/		{/*UVW  }!*,M},MNJsLZ^LsssLZ^LLL!E*!EE//5h8 o%Z]001I=I1$%a(IU9-334I!*9-	9Iij<QQI	N"Da'I$qQRRU|U9---r   c                    \         P                  ! V4      pTP                  R9  d   \        R4      hTP                  ^ 8X  d   T# TP                  4       pYR8  d   \        RT R24      hTP                  4       pT^ 8  d_   Yb) 8  d   \        RT R24      hY1J g   TP                  P                  '       g   TP                  4       pY3^ 8  ;;,          T,          uu&   T#   \        \        \        3 d   p\        R4      ThRp?ii ; i)zConvert `idx` to a valid index for an axis with a given length.

Subclasses that need special validation can override this method.
zinvalid indexNzIndex dimension must be 1 or 2rd   re   )r      )r   rI   rJ   	TypeErrorMemoryErrorr.   r,   r7   maxminr   owndatar0   )r=   rA   lengthr   emax_indxmin_indxs   &&&    r   r|   IndexMixin._asindices9  s    
	5

3A 66=>>66Q;H 557wxj?@@557a<'! 78*N!CDDxqwwFFH!eHH+ I{3 	5_-14	5s   C# #D
9DD
c                    V P                   w  r#\        V4      pW) 8  g   W8  d   \        RV R24      hV^ 8  d	   W,          pV P                  V\	        R4      4      # )zGReturn a copy of row i of the matrix, as a (1 x n) row vector.
        rd   re   N)r   ry   r.   r+   r%   r=   r]   Mr[   s   &&  r   _getrowIndexMixin._getrowW  s\     zzFr6QVwqc899q5FA""1eDk22r   c                    V P                   w  r#\        V4      pW) 8  g   W8  d   \        RV R24      hV^ 8  d	   W,          pV P                  \	        R4      V4      # )zMReturn a copy of column i of the matrix, as a (m x 1) column vector.
        rd   re   N)r   ry   r.   r/   r%   r   s   &&  r   _getcolIndexMixin._getcolb  s\     zzFr6QVwqc899q5FA""5;22r   c                    \        4       hrh   NotImplementedErrorr=   rA   s   &&r   r$   IndexMixin._get_intm      !##r   c                    \        4       hrh   r   r   s   &&r   r&   IndexMixin._get_slicep  r   r   c                    \        4       hrh   r   r   s   &&r   r'   IndexMixin._get_arrays  r   r   c                    \        4       hrh   r   r=   rC   rD   s   &&&r   r*   IndexMixin._get_intXintv  r   r   c                    \        4       hrh   r   r   s   &&&r   r-   IndexMixin._get_intXarrayy  r   r   c                    \        4       hrh   r   r   s   &&&r   r+   IndexMixin._get_intXslice|  r   r   c                    \        4       hrh   r   r   s   &&&r   r/   IndexMixin._get_sliceXint  r   r   c                    \        4       hrh   r   r   s   &&&r   r1   IndexMixin._get_sliceXslice  r   r   c                    \        4       hrh   r   r   s   &&&r   r2   IndexMixin._get_sliceXarray  r   r   c                    \        4       hrh   r   r   s   &&&r   r3   IndexMixin._get_arrayXint  r   r   c                    \        4       hrh   r   r   s   &&&r   r4   IndexMixin._get_arrayXslice  r   r   c                    \        4       hrh   r   r   s   &&&r   r5   IndexMixin._get_columnXarray  r   r   c                    \        4       hrh   r   r   s   &&&r   r9   IndexMixin._get_arrayXarray  r   r   c                    \        4       hrh   r   r=   rA   r   s   &&&r   rK   IndexMixin._set_int  r   r   c                    \        4       hrh   r   r   s   &&&r   rR   IndexMixin._set_array  r   r   c                    \        4       hrh   r   r=   rC   rD   r   s   &&&&r   rS   IndexMixin._set_intXint  r   r   c                    \        4       hrh   r   r   s   &&&&r   rX   IndexMixin._set_arrayXarray  r   r   c                    \         P                  ! VP                  4       V P                  R 7      p\	        W14      w  r4V P                  WV4       R# )r   N)r   rI   rH   r   r   rX   )r=   rC   rD   r   rY   s   &&&& r   rW   "IndexMixin._set_arrayXarray_sparse  s8    JJqyy{$**5 (c*r   r   N)__name__
__module____qualname____firstlineno____doc__rE   ra   r   r|   r   r   r$   r&   r'   r*   r-   r+   r/   r1   r2   r3   r4   r5   r9   rK   rR   rS   rX   rW   __static_attributes____classdictcell__)__classdict__s   @r   r   r      s     ]~V+pc.J<	3	3$$$$$$$$$$$$$$$$$+ +r   r   c                b   \        V R4      '       gn    \        \        V 4      R4      p\        V4       F0  p\	        V\
        4      '       d    M\        \        V4      R4      pK2  	  R# \        P                  ! V 4      p V P                  P                  R8X  d   V # R#   \         d     R# i ; i)zICheck for boolean array or array-like. peek before asarray for array-liker,   Nr   )hasattrnextiterrM   r    boolr   r   
asanyarrayr   rz   )rA   desired_ndimrm   rY   s   &&  r   rv   rv     s     3		d3i&B<(b$''$r(D) )
  mmC 
yy~~
  		s   :B B B.-B.)r   numpyr   _sputilsr   _baser   r   ry   integerr#   r   r   rv   r   r   r   <module>r      s8      $"**	K+ K+\r   