+
    LV-jgR  ã                   óð  € R t ^ RIt^ RIHtHtHt ^ RIt^ RIt^ RI	H
t
 ^ RIHt ^ RIHtHt . R.Ot]P$                  ]P&                  ]P(                  ]P*                  ]P,                  ]P.                  ]P0                  ]]]P2                  ]P4                  ]P6                  ]P8                  ]P:                  ]P<                  ]P>                  ]P@                  .t!/ t"R t#R t$R t%R t&R	 t'R/R
 lt(R0R R llt)]PT                  R3R lt+R1R lt,R R lt-R R lt.R R lt/R2RR3/R R lllt0R R lt1R R lt2R R lt3R^/R  R! llt4R4RR3/R" R# lllt5R$ t6R% t7R& R' lt8R/R( R) llt9R* t:R4R+ lt;R, R- lt<R# )5z+Utility functions for sparse matrix module
N©ÚAnyÚLiteralÚUnion)Úprod)Únp_longÚnp_ulongc                 ó  € \         P                  \        V 4      4      pVe   V# \        P                  ! V !  p\
         F5  p\        P                  ! W!4      '       g   K!  V\         \        V 4      &   Vu # 	  \        RV : 24      h)a–  Returns the nearest supported sparse dtype for the
combination of one or more types.

upcast(t0, t1, ..., tn) -> T  where T is a supported dtype

Examples
--------
>>> from scipy.sparse._sputils import upcast
>>> upcast('int32')
<class 'numpy.int32'>
>>> upcast('bool')
<class 'numpy.bool'>
>>> upcast('int32','float32')
<class 'numpy.float64'>
>>> upcast('bool',complex,float)
<class 'numpy.complex128'>

z#no supported conversion for types: )Ú_upcast_memoÚgetÚhashÚnpÚresult_typeÚsupported_dtypesÚcan_castÚ	TypeError)ÚargsÚtÚupcasts   *  Úf/Volumes/fast/ai/experiments/ui-tars-smoke/.venv/lib/python3.14/site-packages/scipy/sparse/_sputils.pyr   r      sq   € ô( 	×Ñœ˜d›Ó$€AØ‚}Øˆä�^Š^˜TÑ"€FçˆÜ�;Š;�v×!Ô!Ø'(ŒLœ˜d›Ñ$ØŠHñ ô
 Ð9¸$¹ÐBÓ
CÐCó    c                 ó�   € \         P                  V 4      pVe   V# \        \        \        P
                  V 4      !  pV\         V &   V# )z9Same as `upcast` but taking dtype.char as input (faster).)r
   r   r   Úmapr   Údtype)r   r   s   * r   Úupcast_charr   ;   s@   € ä×Ñ˜Ó€AØ‚}ØˆÜ””B—H‘H˜dÓ#Ñ$€AØ„L�ÑØ€Hr   c                óV   € \         P                  ! ^ .V R7      V,          P                  # )zXDetermine data type for binary operation between an array of
type `dtype` and a scalar.
©r   )r   Úarrayr   )r   Úscalars   &&r   Úupcast_scalarr   E   s"   € ô �HŠH�a�S Ô&¨Õ/×6Ñ6Ð6r   c                óT  € V P                   P                  \        P                   ! \        P                  4      P                  8”  dá   V P                  ^ 8X  d    V P                  \        P                  4      # V P                  4       pV P                  4       pV\        P                  ! \        P                  4      P                  8”  g4   V\        P                  ! \        P                  4      P                  8  d   \        R4      hV P                  \        P                  4      # V # )zŽ
Down-cast index array to np.intp dtype if it is of a larger dtype.

Raise an error if the array contains a value that is too large for
intp.
zzCannot deal with arrays with indices larger than the machine maximum address size (e.g. 64-bit indices on 32-bit machine).)
r   Úitemsizer   ÚintpÚsizeÚastypeÚmaxÚminÚiinfoÚ
ValueError)ÚarrÚmaxvalÚminvals   &  r   Údowncast_intp_indexr,   L   sÁ   € ð ‡y�y×ÑœBŸHšH¤R§W¡WÓ-×6Ñ6Ô6Ø�8‰8�qŒ=Ø—:‘:œbŸg™gÓ&Ð&Ø—‘“ˆØ—‘“ˆØ”B—H’HœRŸW™WÓ%×)Ñ)Ô)¨V´b·h²h¼r¿w¹wÓ6G×6KÑ6KÔ-KÜð Hó Ið Ið �z‰zœ"Ÿ'™'Ó"Ð"Ø€Jr   c                óŽ   € V P                   pVP                  '       d   V # \        P                  ! WP	                  R4      R7      # )zî
Ensure that the data type of the NumPy array `A` has native byte order.

`A` must be a NumPy array.  If the data type of `A` does not have native
byte order, a copy of `A` with a native byte order is returned. Otherwise
`A` is returned.
Únativer   )r   Úisnativer   ÚasarrayÚnewbyteorder)ÚAÚdts   & r   Ú	to_nativer4   `   s5   € ð 
�‰€BØ	‡{‡{€{ð ˆÜ�:Š:�aŸ™¨xÓ8Ô9Ð9r   c                óD  € V f    VP                   pM\        P                   ! V 4      pV\        9  d/   RP                  R \         4       4      p\        RV RV R24      hV#   \         d1   pTe   \        P                   ! T4      p Rp?Le\        R4      ThRp?ii ; i)a¸  Form a supported numpy dtype based on input arguments.

Returns a valid ``numpy.dtype`` from `dtype` if not None,
or else ``a.dtype`` if possible, or else the given `default`
if not None, or else raise a ``TypeError``.

The resulting ``dtype`` must be in ``supported_dtypes``:
    bool_, int8, uint8, int16, uint16, int32, uint32,
    int64, uint64, longlong, ulonglong, float32, float64,
    longdouble, complex64, complex128, clongdouble
Nzcould not interpret data typeú, c              3   ó8   "  € T F  qP                   x € K  	  R # 5i©N)Ú__name__)Ú.0r   s   & r   Ú	<genexpr>Úgetdtype.<locals>.<genexpr>ˆ   s   é € Ð(NÑ=M¸¯®Ó=Mùs   ‚z$scipy.sparse does not support dtype z . The only supported types are: Ú.)r   ÚAttributeErrorr   r   r   Újoinr(   )r   ÚaÚdefaultÚnewdtypeÚeÚsupported_dtypes_fmts   &&&   r   ÚgetdtyperE   p   s«   € ð ‚}ð	HØ—w‘w‰Hô —8’8˜E“?ˆàÔ'Ô'Ø#Ÿy™yÑ(NÕ=MÓ(NÓNÐÜÐ?À¸zð J:Ø:NÐ9OÈqðRó Sð 	Sà€Oøô ô 	HØÒ"ÜŸ8š8 GÓ,•äÐ ?Ó@ÀaÐGûð		Hús   †A$ Á$BÁ/BÂBÂBc                ó8   € V ^8„  d   QhR\         P                  /# ©é   Úreturn©r   Úndarray)Úformats   "r   Ú__annotate__rM   Ž   s   € ÷ 	ñ 	¬B¯J©Jñ 	r   c                ó`   € \         P                  ! WVR7      p\        VP                  4       V# )z}
This is a wrapper of `np.array(obj, dtype=dtype, copy=copy)`
that will generate a warning if the result is an object array.
)r   Úcopy)r   r   rE   r   )Úobjr   rO   Údatas   &&& r   ÚgetdatarR   Ž   s'   € ô
 �8Š8�C¨4Ô0€Dô ˆT�Z‰ZÔØ€Kr   Ú c                óL  aa€ V'       g   RS 2p\         P                  ! S4      P                  oV P                  R9   d­   V P                  R,          S8”  d   \        RV 24      h\        V P                  !  S8”  d2   V P                  S8„  P                  4       '       d   \        RV 24      hV P                  P                  SRR7      pV P                  P                  SRR7      pW43# V P                  R8X  dÁ   \        V P                  !  S8”  dc   \        ;QJ d)    V3R lV P                   4       F  '       g   K   RM	  RM! V3R lV P                   4       4      '       d   \        R	V 24      h\        ;QJ d!    . V3R
 lV P                   4       F  NK  	  5# ! V3R
 lV P                   4       4      # V P                  R8X  di   \        V P                  !  S8”  d2   V P                  S8„  P                  4       '       d   \        RV 24      hV P                  P                  SRR7      pV# V P                  R8X  dÆ   V P                  w  rgV P                  R,          V,          S8”  d   \        R4      h\        V P                  !  S8”  d9   V P                  V,          S8„  P                  4       '       d   \        RV 24      hV P                  P                  SRR7      pV P                  P                  SRR7      pW43# \        RV P                   R24      h)af  Safely cast sparse array indices to `idx_dtype`.

Check the shape of `A` to determine if it is safe to cast its index
arrays to dtype `idx_dtype`. If any dimension in shape is larger than
fits in the dtype, casting is unsafe so raise ``ValueError``.
If safe, cast the index arrays to `idx_dtype` and return the result
without changing the input `A`. The caller can assign results to `A`
attributes if desired or use the recast index arrays directly.

Unless downcasting is needed, the original index arrays are returned.
You can test e.g. ``A.indptr is new_indptr`` to see if downcasting occurred.

.. versionadded:: 1.15.0

Parameters
----------
A : sparse array or matrix
    The array for which index arrays should be downcast.
idx_dtype : dtype
    Desired dtype. Should be an integer dtype (default: ``np.int32``).
    Most of scipy.sparse uses either int64 or int32.
msg : string, optional
    A string to be added to the end of the ValueError message
    if the array shape is too big to fit in `idx_dtype`.
    The error message is ``f"<index> values too large for {msg}"``
    It should indicate why the downcasting is needed, e.g. "SuperLU",
    and defaults to f"dtype {idx_dtype}".

Returns
-------
idx_arrays : ndarray or tuple of ndarrays
    Based on ``A.format``, index arrays are returned after casting to `idx_dtype`.
    For CSC/CSR, returns ``(indices, indptr)``.
    For COO, returns ``coords``.
    For DIA, returns ``offsets``.
    For BSR, returns ``(indices, indptr)``.

Raises
------
ValueError
    If the array has shape that would not fit in the new dtype, or if
    the sparse format does not use index arrays.

Examples
--------
>>> import numpy as np
>>> from scipy import sparse
>>> data = [3]
>>> coords = (np.array([3]), np.array([1]))  # Note: int64 arrays
>>> A = sparse.coo_array((data, coords))
>>> A.coords[0].dtype
dtype('int64')

>>> # rescast after construction, raising exception if shape too big
>>> coords = sparse.safely_cast_index_arrays(A, np.int32)
>>> A.coords[0] is coords[0]  # False if casting is needed
False
>>> A.coords = coords  # set the index dtype of A
>>> A.coords[0].dtype
dtype('int32')
zdtype zindptr values too large for zindices values too large for F©rO   Úcooc              3   óH   <"  € T F  qS8„  P                  4       x € K  	  R # 5ir8   )Úany)r:   ÚcoÚ	max_values   & €r   r;   Ú+safely_cast_index_arrays.<locals>.<genexpr>í   s   øé € Ð=±H¨b˜‘N×'Ñ'×)Ð)³Hùó   ƒ"Tzcoords values too large for c              3   óH   <"  € T F  qP                  SR R7      x € K  	  R# 5i)FrU   N)r$   )r:   rY   Ú	idx_dtypes   & €r   r;   r[   ï   s   øé € ÐIÁ¸"—Y‘Y˜y¨u�Y×5Ð5Ãùr\   Údiazoffsets values too large for Úbsrz!indptr values too large for {msg}zFormat zP is not associated with index arrays. DOK and LIL have dict and list, not array.©ÚcscÚcsréÿÿÿÿ)r   r'   r%   rL   Úindptrr(   ÚshapeÚindicesrX   r$   ÚcoordsÚtupleÚoffsetsÚ	blocksizer   )	r2   r^   Úmsgrg   re   rj   ÚRÚCrZ   s	   &f&     @r   Úsafely_cast_index_arraysro   š   sˆ  ù€ ÷| Ø�y�kÐ"ˆä—’˜Ó#×'Ñ'€Ià‡x�x�>Ô!à�8‰8�B�<˜)Ô#ÜÐ;¸C¸5ÐAÓBÐBô �—‘‰=˜9Ô$Ø—	‘	˜IÑ%×*Ñ*×,Ò,Ü Ð#@ÀÀÐ!FÓGÐGà—)‘)×"Ñ" 9°5Ð"Ó9ˆØ—‘—‘ °�Ó7ˆØˆÐà	
�‰�UÔ	Ü�—‘‰=˜9Ô$ß‹sÔ=°A·H²HÓ=�s�sŠsÔ=°A·H²HÓ=×=Ò=Ü Ð#?À¸uÐ!EÓFÐFßŒuÔIÀÇÂÓI�uÐIˆuÔIÀÇÂÓIÓIÐIà	
�‰�UÔ	Ü�—‘‰=˜9Ô$Ø—	‘	˜IÑ%×*Ñ*×,Ò,Ü Ð#@ÀÀÐ!FÓGÐGØ—)‘)×"Ñ" 9°5Ð"Ó9ˆØˆà	
�‰�UÔ	Ø�{‰{‰ˆØ�8‰8�B�<˜!Õ˜iÔ'ÜÐ@ÓAÐAÜ�—‘‰=˜9Ô$Ø—	‘	˜A• 	Ñ)×.Ñ.×0Ò0Ü Ð#@ÀÀÐ!FÓGÐGØ—)‘)×"Ñ" 9°5Ð"Ó9ˆØ—‘—‘ °�Ó7ˆØˆÐô ˜' !§(¡( ð ,Eð Eó Fð 	Fr   c                ó   € \         P                  ! 4       P                  ^8w  d   \         P                  # \         P                  ! \         P
                  ! \         P                  4      P                  4      p\         P                  ! \         P
                  ! \         P                  4      P                  4      pVe-   \         P                  ! V4      pW8”  d   \         P                  # \        V \         P                  4      '       d   V 3p V  FÞ  p\         P                  ! V4      p\         P                  ! VP                  \         P                  4      '       d   KP  V'       dw   VP                  ^ 8X  d   Kk  \         P                  ! VP                  \         P                  4      '       d/   VP                  4       pVP                  4       pWc8¼  d	   W8:  d   KÎ  \         P                  u # 	  \         P                  # )a;  
Based on input (integer) arrays `a`, determine a suitable index data
type that can hold the data in the arrays.

Parameters
----------
arrays : tuple of array_like
    Input arrays whose types/contents to check
maxval : float, optional
    Maximum value needed
check_contents : bool, optional
    Whether to check the values in the arrays and not just their types.
    Default: False (check only the types)

Returns
-------
dtype : dtype
    Suitable index data type (int32 or int64)

Examples
--------
>>> import numpy as np
>>> from scipy import sparse
>>> # select index dtype based on shape
>>> shape = (3, 3)
>>> idx_dtype = sparse.get_index_dtype(maxval=max(shape))
>>> data = [1.1, 3.0, 1.5]
>>> indices = np.array([0, 1, 0], dtype=idx_dtype)
>>> indptr = np.array([0, 2, 3, 3], dtype=idx_dtype)
>>> A = sparse.csr_array((data, indices, indptr), shape=shape)
>>> A.indptr.dtype
dtype('int32')

>>> # select based on larger of existing arrays and shape
>>> shape = (3, 3)
>>> idx_dtype = sparse.get_index_dtype(A.indptr, maxval=max(shape))
>>> idx_dtype
<class 'numpy.int32'>
)r   Úintcr!   Úint64Úint32r'   r&   r%   Ú
isinstancerK   r0   r   r   r#   Ú
issubdtypeÚinteger)Úarraysr*   Úcheck_contentsÚint32minÚint32maxr)   r+   s   &&&    r   Úget_index_dtyper{     s1  € ôR 
‡w‚wƒy×Ñ˜QÔÜ�x‰xˆä�xŠxœŸš¤§¡Ó*×.Ñ.Ó/€HÜ�xŠxœŸš¤§¡Ó*×.Ñ.Ó/€HàÒÜ—’˜&Ó!ˆØÔÜ—8‘8ˆOä�&œ"Ÿ*™*×%Ò%Ø�ˆãˆÜ�jŠj˜‹oˆÜ�{Š{˜3Ÿ9™9¤b§h¡h×/Ô/ßØ—8‘8˜q”=áÜ—]’] 3§9¡9¬b¯j©j×9Ò9Ø ŸW™W›Y�FØ ŸW™W›Y�FØÔ)¨fÔ.@á Ü—8‘8ŠOñ ô �8‰8€Or   c                óX   € V ^8„  d   QhR\         P                  R\         P                  /# )rH   r   rI   )r   r   )rL   s   "r   rM   rM   P  s"   € ÷ ñ œŸ™ð ¤b§h¡hñ r   c                ó  € V P                   R8X  d<   \        P                  ! V \        P                  4      '       d   \        P                  # \        P                  ! V \        P                  4      '       d   \        P                  # V # )z Mimic numpy's casting for np.sumÚu)Úkindr   r   ÚuintÚint_r   s   &r   Úget_sum_dtyper‚   P  sN   € à‡z�z�SÔœRŸ[š[¨´·±×8Ò8Ü�w‰wˆÜ	‡{‚{�5œ"Ÿ'™'×"Ò"Ü�w‰wˆØ€Lr   c                ó$   € V ^8„  d   QhR\         /# rG   ©Úbool)rL   s   "r   rM   rM   Y  s   € ÷ :ñ :”tñ :r   c                ó‚   € \         P                  ! V 4      ;'       g#    \        V 4      ;'       d    V P                  ^ 8H  # )z8Is x either a scalar, an array scalar, or a 0-dim array?)r   ÚisscalarÚisdenseÚndim©Úxs   &r   ÚisscalarlikerŒ   Y  s,   € ä�;Š;�q‹>×9Ð9œg a›j×8Ð8¨Q¯V©V°q©[Ð9r   c                ó$   € V ^8„  d   QhR\         /# rG   r„   )rL   s   "r   rM   rM   ^  s   € ÷ ñ ”Dñ r   c                ó.  € \         P                  ! V 4      ^ 8w  d   R#  \        P                  ! V 4       R#   \        \
        3 dM     \        \        T 4      T 8H  4      pM  \        \
        3 d      R# i ; iT'       d   Rp\        T4      hTu # i ; i)zkIs x appropriate as an index into a sparse matrix? Returns True
if it can be cast safely to a machine int.
Fz4Inexact indices into sparse matrices are not allowedT)r   r‰   ÚoperatorÚindexr   r(   r…   Úint)r‹   Ú	loose_intrl   s   &  r   Ú	isintliker“   ^  sˆ   € ô 
‡w‚wˆqƒz�Q„Ùð
Ü�Š�qÔñ øô ”zÐ"ô ð	ÜœS ›V q™[Ó)‰IøÜœ:Ð&ô 	Ûð	úçØHˆCÜ˜S“/Ð!ØÒðús9   Ÿ7 ·BÁ	A!Á BÁ!A7Á2BÁ6A7Á7
BÂBÂBÚallow_ndc                ó$   € V ^8„  d   QhR\         /# rG   r„   )rL   s   "r   rM   rM   t  s   € ÷ ñ ´$ñ r   c               óŽ   € \        V 4      pW29  d   R# V  F+  p\        V4      '       g    R# V'       g   K!  V^ 8  g   K*   R# 	  R# )z”Is x a valid tuple of dimensions?

If nonneg, also checks that the dimensions are non-negative.
Shapes of length in the tuple allow_nd are allowed.
FT)Úlenr“   )r‹   Únonnegr”   r‰   Úds   &&$  r   Úisshaperš   t  s?   € ô ˆq‹6€DØÔÙãˆÜ˜�|Š|Úß‰6�a˜!–eÚñ	 ñ
 r   c                ó$   € V ^8„  d   QhR\         /# rG   r„   )rL   s   "r   rM   rM   †  s   € ÷ ;ñ ;”Tñ ;r   c                 ó   € \        V \        \        ,          4      ;'       d<    \        V 4      ^ 8H  ;'       gW    \        P
                  ! V ^ ,          4      ;'       g2    \        V \        P                  4      ;'       d    V P                  ^8H  # ©é    )rt   Úlistri   r—   r   r‡   rK   r‰   ©r   s   &r   Ú
issequencer¡   †  si   € Ü˜œ4¤%�<Ó(÷ /ð /Ü�‹V�q‰[÷:Ø-œBŸKšK¨¨!­Ó-÷:ð :ä˜œ2Ÿ:™:Ó&×8Ð8¨A¯F©F°a©Kð;r   c                ó$   € V ^8„  d   QhR\         /# rG   r„   )rL   s   "r   rM   rM   Œ  s   € ÷ 9ñ 9”4ñ 9r   c                 ó
  € \        V \        \        ,          4      ;'       d1    \        V 4      ^ 8„  ;'       d    \	        V ^ ,          4      ;'       g2    \        V \
        P                  4      ;'       d    V P                  ^8H  # r�   )rt   rŸ   ri   r—   r¡   r   rK   r‰   r    s   &r   Úismatrixr¤   Œ  sh   € Ü˜œ4¤%�<Ó(÷ -ð -Ü�‹V�a‰Z÷-ð -Ü& q¨¥tÓ,÷8ð 8ä˜œ2Ÿ:™:Ó&×6Ð6¨1¯6©6°Q©;ð9r   c                ó$   € V ^8„  d   QhR\         /# rG   r„   )rL   s   "r   rM   rM   ’  s   € ÷ %ñ %”$ñ %r   c                 ó6   € \        V \        P                  4      # r8   )rt   r   rK   rŠ   s   &r   rˆ   rˆ   ’  s   € Ü�aœŸ™Ó$Ð$r   r‰   c                óL   € V ^8„  d   QhR\         \        R3,          R,          /# )rH   rI   .N©ri   r‘   )rL   s   "r   rM   rM   –  s    € ÷ #!ñ #!¤U¬3°¨8¥_°tÕ%;ñ #!r   c                óŽ  € V f   R # V R8X  d   \        R4      h\        V \        4      '       gc   \        P                  ! \        P
                  ! \        V 4      4      \        P                  4      '       g   \        R\        V 4       24      hV 3p . pV  F[  p\        V4      '       g   \        RV R24      hV^ 8  d	   W1,          pV^ 8  g   W18¼  d   \        R4      hVP                  V4       K]  	  \        V4      pV\        \        V4      4      8w  d   \        R4      hWA8”  d   \        R4      hWA8X  d   R # \        V4      # )	NzWsparse does not accept 0D axis (). Either use toarray (for dense) or copy (for sparse).z+axis must be an integer/tuple of ints, not z axis must be an integer. (given Ú)zaxis out of range for ndimzduplicate value in axisz axis tuple has too many elements© )r(   rt   ri   r   ru   r   Útyperv   r   r“   Úappendr—   Úset)Úaxisr‰   Ú
canon_axisÚaxÚlen_axiss   &$   r   Úvalidateaxisr³   –  s!  € Ø‚|Ùàˆr„zÜð$ó
ð 	
ô
 �dœE×"Ò"ô �}Š}œRŸXšX¤d¨4£jÓ1´2·:±:×>Ò>ÜÐIÌ$ÈtË*ÈÐVÓWÐWØˆwˆà€JÛˆÜ˜�}Š}ÜÐ>¸r¸dÀ!ÐDÓEÐEØ�Œ6Ø�JˆBØ�Œ6�R”ZÜÐ9Ó:Ð:Ø×Ñ˜"Öñ ô �:‹€HØ”3”s˜:“Ó'Ô'ÜÐ2Ó3Ð3Ø	ŒÜÐ;Ó<Ð<Ø	Ô	Ùä�ZÓ Ð r   c                ó>   € V ^8„  d   QhR\         \        R3,          /# )rH   rI   .r¨   )rL   s   "r   rM   rM   ¼  s   € ÷ =ñ =¼uÄSÈ#ÀX½ñ =r   c               óÚ  € \        V 4      ^ 8X  d   \        R4      h\        V 4      ^8X  dA    \        V ^ ,          4      p\        ;QJ d    . R V 4       F  NK  	  5M! R V 4       4      pM,\        ;QJ d    . R V  4       F  NK  	  5M! R V  4       4      pVfj   \        V4      V9  d   \        RV RV: 24      h\        ;QJ d    R V 4       F  '       g   K   RM	  R	M! R V 4       4      '       d   \        R
4      hEM\        V4      p\        V4       UUu. uF  w  rgV^ 8  g   K  VNK  	  pppV'       g$   \        V4      p	W•8w  d   \        RV RV 24      hM±\        V4      ^8X  d—   V^ ,          p
\        VRV
 WJ^,           R ,           4      p\        W[4      w  rÍV^ 8w  d>   \        ;QJ d    . R V 4       F  NK  	  5M! R V 4       4      p\        RV RV 24      hVRV
 V3,           WJ^,           R ,           pM\        R4      h\        V4      V9  d   \        RV RV: 24      hV#   \         d#    \        P
                  ! T ^ ,          4      3p ELËi ; iu uppi )a  Imitate numpy.matrix handling of shape arguments

Parameters
----------
args : array_like
    Data structures providing information about the shape of the sparse array.
current_shape : tuple, optional
    The current shape of the sparse array or matrix.
    If None (default), the current shape will be inferred from args.
allow_nd : tuple of ints, optional default: (2,)
    If shape does not have a length in the tuple allow_nd an error is raised.

Returns
-------
new_shape: tuple
    The new shape after validation.
z8function missing 1 required positional argument: 'shape'c              3   óN   "  € T F  p\         P                  ! V4      x € K  	  R # 5ir8   ©r�   r�   ©r:   Úargs   & r   r;   Úcheck_shape.<locals>.<genexpr>Ö  s   é € ÐH¹Z°cœhŸnšn¨S×1Ð1»Zùó   ‚#%c              3   óN   "  € T F  p\         P                  ! V4      x € K  	  R # 5ir8   r·   r¸   s   & r   r;   rº   Ø  s   é € Ð>¹°#œ(Ÿ.š.¨×-Ð-»ùr»   Nzshape must have length in z. Got new_shape=c              3   ó*   "  € T F	  q^ 8  x € K  	  R# 5i)rž   Nr«   )r:   r™   s   & r   r;   rº   Ý  s   é € Ð(™i˜�1Žu›iùs   ‚TFz#'shape' elements cannot be negativezcannot reshape array of size z into shape c              3   ó6   "  € T F  q^ 8  d   RMTx € K  	  R# 5i)rž   ÚnewshapeNr«   )r:   r‹   s   & r   r;   rº   ï  s   é € Ð!PÁiÀ°A´¡*¸1Ô"<Ãiùs   ‚z&can only specify one unknown dimension)r—   r   Úiterri   r�   r�   r(   rX   r   Ú	enumerateÚdivmod)r   Úcurrent_shaper”   Ú
shape_iterÚ	new_shapeÚcurrent_sizeÚir‹   Únegative_indexesÚnew_sizeÚskipÚ	specifiedÚunspecifiedÚ	remainderÚ	err_shapes   &&$            r   Úcheck_shaperÏ   ¼  sP  € ô$ ˆ4ƒy�A„~ÜÐRÓSÐSÜ
ˆ4ƒy�A„~ð	IÜ˜d 1�g›ˆJ÷ œÑH¹ZÓHŸ™ÑH¹ZÓHÓH‰Iç”EÑ>¹Ó>—E‘EÑ>¹Ó>Ó>ˆ	àÒÜˆy‹> Ô)ÜÐ9¸(¸ÐCTÈ)ÉÐVÓWÐWß‹3Ñ(™iÓ(�3�3Š3Ñ(™iÓ(×(Ò(ÜÐBÓCÐCñ )ô ˜MÓ*ˆô +4°IÔ*>ÔHÑ*>¡$ !À!ÀaÁ%ŸA˜AÑ*>ÐÑHßÜ˜I“ˆHØÔ'Ü Ð#@ÀÀØ#/°	¨{ð"<ó =ð =ð (ô Ð!Ó" aÔ'Ø# AÕ&ˆDÜ˜Y u¨Ð-°	¸q½&¸'Ð0BÕBÓCˆIÜ%+¨LÓ%DÑ"ˆKØ˜AŒ~ß!œEÑ!PÁiÓ!PŸE™EÑ!PÁiÓ!PÓP�	Ü Ð#@ÀÀØ#/°	¨{ð"<ó =ð =à! % 4Ð(¨K¨>Õ9¸IÈ1ÅfÀgÐ<NÕN‰IäÐEÓFÐFä
ˆ9ƒ~˜XÔ%ÜÐ5°h°ZÐ?PÀiÁ\ÐRÓSÐSàÐøôM ô 	4Ü!Ÿš¨¨Q­Ó0Ð3‹Ið	4üó" Is   ­H7 ÄI'Ä.I'È7)I$É#I$c                 ó”  € V '       g   R# V  Uu. uF)  p\        V\        \        ,          4      '       d   TMV3NK+  	  p p\        V \        R7      p\        V4      pV  F^  pWJ d   K
  \        V\	        V4      ) R7       F9  w  rEV^8w  g   K  WSV,          8w  g   K  W4,          ^8w  d   \        R4      hWSV&   K;  	  K`  	  . VO5# u upi )aÓ  Check if shapes can be broadcast and return resulting shape

This is similar to the NumPy ``broadcast_shapes`` function but
does not check memory consequences of the resulting dense matrix.

Parameters
----------
*shapes : tuple of shape tuples
    The tuple of shapes to be considered for broadcasting.
    Shapes should be tuples of non-negative integers.

Returns
-------
new_shape : tuple of integers
    The shape that results from broadcasting th input shapes.
)Úkey)Ústartz-shapes cannot be broadcast to a single shape.r«   )rt   ri   rŸ   r%   r—   rÁ   r(   )ÚshapesÚshpÚbig_shpÚoutrÇ   r‹   s   *     r   Úbroadcast_shapesr×   ü  s³   € ÷" Øˆ	ÙJPÓQÉ&À3”Z ¤U¬T¥\×2Ò2‰c¸¸Ò>É&€FÐQÜ�&œcÔ"€GÜ
ˆw‹-€CÛˆØ‹>ÙÜ˜c¬#¨c«(¨×3‰DˆAØ�AŽv˜! 1�vž+Ø•6˜Q”;Ü$Ð%TÓUÐUØ�A“ó	 4ñ ð ˆS‰7€Nùò Rs   �/Cc                ó¶   € V P                  RR4      pV P                  RR4      pV '       d,   \        RRP                  V P                  4       4       24      hW3# )a+  Unpack keyword arguments for reshape function.

This is useful because keyword arguments after star arguments are not
allowed in Python 2, but star keyword arguments are. This function unpacks
'order' and 'copy' from the star keyword arguments (with defaults) and
throws an error for any remaining.
Úorderrn   rO   Fz-reshape() got unexpected keywords arguments: r6   )Úpopr   r?   Úkeys)ÚkwargsrÙ   rO   s   &  r   Úcheck_reshape_kwargsrÝ     sY   € ð �J‰J�w Ó$€EØ�:‰:�f˜eÓ$€DßÜÐGØŸ9™9 V§[¡[£]Ó3Ð4ð6ó 7ð 	7àˆ;Ðr   c                ó$   € V ^8„  d   QhR\         /# rG   r„   )rL   s   "r   rM   rM   .  s   € ÷ <ñ <œTñ <r   c                ó„   € \        \        P                  P                  R4      RR4      pVRJ;'       d    \	        W4      # )zN
Check whether object is pydata/sparse matrix, avoiding importing the module.
ÚsparseÚSparseArrayN)ÚgetattrÚsysÚmodulesr   rt   )ÚmÚbase_clss   & r   Úis_pydata_spmatrixrç   .  s7   € ô ”s—{‘{—‘ xÓ0°-ÀÓF€HØ˜4Ð×;Ð;¤J¨qÓ$;Ð;r   c          
      ó~   € V ^8„  d   QhR\         RR\        R,          ,          R\         R\        \         R3,          /# )rH   r¹   Útarget_formatNÚ	accept_fvrI   zsp.spmatrixra   r   )rL   s   "r   rM   rM   6  sD   € ÷ ñ Ü	ðàœ' ,Õ/Õ/ðô ðô Œ3�ÐÕñ	r   c                ó   € \        V 4      '       dL    V P                  VR7      p Ve   V P                  V4      p V # V P                  R9  d   V P                  4       p V #   \         d    T P                  4       p  LWi ; i)zS
Convert a pydata/sparse array to scipy sparse matrix,
pass through anything else.
)rê   ra   )rç   Úto_scipy_sparser   ÚasformatrL   Útocsc)r¹   ré   rê   s   &&&r   Úconvert_pydata_sparse_to_scipyrï   6  s�   € ô ˜#×Òð	(Ø×%Ñ%°	Ð%Ó:ˆCð Ò$Ø—,‘,˜}Ó-ˆCð €Jð �Z‰Z˜~Ô-Ø—)‘)“+ˆCØ€Jøô ô 	(Ø×%Ñ%Ó'ŠCð	(ús   “A ÁA=Á<A=c                  óh   € \         P                  ! V / VB P                  \         P                  4      # r8   )r   r   ÚviewÚmatrix)r   rÜ   s   *,r   rò   rò   S  s%   € Ü�8Š8�TÐ$˜VÑ$×)Ñ)¬"¯)©)Ó4Ð4r   c                 óØ   € \        V \        P                  4      '       d   Ve   V P                  V8X  d   V # \        P                  ! WR7      P                  \        P                  4      # )Nr   )rt   r   rò   r   r0   rñ   )rQ   r   s   &&r   Úasmatrixrô   W  sE   € Ü�$œŸ	™	×"Ò"¨ª¸¿¹ÀuÔ9LØˆÜ�:Š:�dÔ(×-Ñ-¬b¯i©iÓ8Ð8r   c                ó8   € V ^8„  d   QhR\         P                  /# rG   rJ   )rL   s   "r   rM   rM   _  s   € ÷ %ñ %”"—*‘*ñ %r   c                óX  € \        V \        P                  P                  4      '       d   V P	                  4       # \        V \        P
                  4      '       d<   \        P                  ! V P                  4       V P                  V P                  R7      # \        V \        P                  4      '       dY   \        P                  ! V P                  V P                  R7      p\        P                  P                  V P                  V4       V# V P!                  4       P	                  4       # )zÍAccess nonzero values, possibly after summing duplicates.

Parameters
----------
s : sparse array
    Input sparse array.

Returns
-------
data: ndarray
  Nonzero values of the array, with shape (s.nnz,)

)r   Úcountr   )rt   ÚspÚ_dataÚ_data_matrixÚ_deduped_dataÚ	dok_arrayr   ÚfromiterÚvaluesr   ÚnnzÚ	lil_arrayÚemptyÚ_csparsetoolsÚlil_flatten_to_arrayrQ   Útocoo)ÚsrQ   s   & r   Ú_todatar  _  s·   € ô �!”R—X‘X×*Ñ*×+Ò+Ø�‰Ó Ð ä�!”R—\‘\×"Ò"Ü�{Š{˜1Ÿ8™8›:¨Q¯W©W¸A¿E¹EÔBÐBä�!”R—\‘\×"Ò"Ü�xŠx˜Ÿ™ Q§W¡WÔ-ˆÜ
×Ñ×-Ñ-¨a¯f©f°dÔ;Øˆà�7‰7‹9×"Ñ"Ó$Ð$r   )r   rE   rR   rŒ   r“   rš   r¡   rˆ   r¤   r‚   r×   )NN)NF)r«   NF)F)rH   r8   )=Ú__doc__rã   Útypingr   r   r   r�   Únumpyr   Úmathr   Úscipy.sparserà   rø   Úscipy._lib._utilr   r   Ú__all__Úbool_ÚbyteÚubyteÚshortÚushortrq   ÚuintcÚlonglongÚ	ulonglongÚfloat32Úfloat64Ú
longdoubleÚ	complex64Ú
complex128Úclongdoubler   r
   r   r   r   r,   r4   rE   rR   rs   ro   r{   r‚   rŒ   r“   rš   r¡   r¤   rˆ   r³   rÏ   r×   rÝ   rç   rï   rò   rô   r  r«   r   r   Ú<module>r     sP  ðñó ß &Ñ &Û Û Ý Ý ß .ò€ð —H‘H˜bŸg™g r§x¡x°·±¸2¿9¹9ÀbÇgÁgØ—H‘H˜g x°·±¸b¿l¹lØ—J‘J §
¡
¨B¯M©MØ—L‘L "§-¡-°·±ðAÐ ð
 €òDòDò7òò(:ô ÷<	ð +-¯(©(¸ô kFô\EõPõ:õ
ñ,¨÷ ð õ$;õ9õ%ð#!˜q÷ #!ñL=°d÷ =ð =ò@òBõ"<÷ò:5ô9÷%r   