Ë
    ÏÍ:jÜO  ã                   ó’  — d Z ddlZddlmZmZ ddlZddlZddlm	Z	 ddl
mZ g d¢Zej                  ej                  ej                   ej"                  ej$                  ej&                  ej(                  ej*                  ej,                  ej.                  ej0                  ej2                  ej4                  ej6                  ej8                  ej:                  ej<                  gZi Z d„ Z!d„ Z"d„ Z#d	„ Z$d
„ Z%d-d„Z&d.dejN                  fd„Z(ejR                  dfd„Z*d/d„Z+dejX                  dejX                  e-ej\                     z  fd„Z/de0fd„Z1de0fd„Z2d0dddœde0fd„Z3de0fd„Z4de0fd„Z5de0fd„Z6ddœde7e8df   dz  fd„Z9d1dd œde7e8df   fd!„Z:d"„ Z;de0fd#„Z<	 	 d-d$ed%ded&   z  d'edd(fd)„Z=d*„ Z>d1d+„Z?dejN                  fd,„Z@y)2z, Utility functions for sparse matrix module
é    N)ÚAnyÚLiteral)Úprod)ÚupcastÚgetdtypeÚgetdataÚisscalarlikeÚ	isintlikeÚisshapeÚ
issequenceÚisdenseÚismatrixÚget_sum_dtypeÚbroadcast_shapesc                  óô   — t         j                  t        | «      «      }|�|S t        j                  | Ž }t
        D ].  }t        j                  ||«      sŒ|t         t        | «      <   |c S  t        d| ›�«      ‚)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Útr   s      új/home/mcse/projects/srt_converter/srt-converter-venv/lib/python3.12/site-packages/scipy/sparse/_sputils.pyr   r      su   € ô( 	×Ñœ˜d›Ó$€AØ€}Øˆä�^‰^˜TÐ"€Fäò ˆÜ�;‰;�v˜qÕ!Ø'(ŒLœ˜d›Ñ$ØŠHðô
 Ð9¸$¸ÐBÓ
CÐCó    c                  óŠ   — t         j                  | «      }|�|S t        t        t        j
                  | «      Ž }|t         | <   |S )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                 óL   — t        j                  dg| ¬«      |z  j                  S )z`Determine data type for binary operation between an array of
    type `dtype` and a scalar.
    r   ©r    )r   Úarrayr    )r    Úscalars     r   Úupcast_scalarr&   D   s"   € ô �H‰H�a�S Ô&¨Ñ/×6Ñ6Ð6r   c                 ó>  — | j                   j                  t        j                   t        j                  «      j                  kD  rØ| j                  dk(  r| j                  t        j                  «      S | j                  «       }| j                  «       }|t        j                  t        j                  «      j                  kD  s0|t        j                  t        j                  «      j                  k  rt        d«      ‚| j                  t        j                  «      S | S )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.
    r   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_indexr3   K   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                 ó‚   — | j                   }|j                  r| S t        j                  | |j	                  d«      ¬«      S )a  
    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_nativer;   _   s5   € ð 
�‰€BØ	‡{‚{ð ˆÜ�:‰:�a˜rŸ™¨xÓ8Ô9Ð9r   c                 ó0  — | €	 |j                   }nt        j                   | «      }|t        vr.dj                  d„ t        D «       «      }t        d|› d|› d�«      ‚|S # t        $ r.}|�t        j                   |«      }nt        d«      |‚Y d}~Œjd}~ww xY w)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 typez, c              3   ó4   K  — | ]  }|j                   –— Œ y ­w©N)Ú__name__)Ú.0r   s     r   ú	<genexpr>zgetdtype.<locals>.<genexpr>‡   s   è ø€ Ò(N¸¨¯­Ñ(Nù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   r   r   o   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Úreturnc                 ó`   — t        j                  | ||¬«      }t        |j                  «       |S )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$   r   r    )Úobjr    rL   Údatas       r   r   r   �   s)   € ô
 �8‰8�C˜u¨4Ô0€Dô ˆT�Z‰ZÔØ€Kr   Ú c                 ó  ‡‡— |sd‰› �}t        j                  ‰«      j                  Š| j                  dv rž| j                  d   ‰kD  rt        d|› �«      ‚t        | j                  Ž ‰kD  r+| j                  ‰kD  j                  «       rt        d|› �«      ‚| j                  j                  ‰d¬«      }| j                  j                  ‰d¬«      }||fS | j                  dk(  r_t        | j                  Ž ‰kD  r,t        ˆfd	„| j                  D «       «      rt        d
|› �«      ‚t        ˆfd„| j                  D «       «      S | j                  dk(  r_t        | j                  Ž ‰kD  r+| j                  ‰kD  j                  «       rt        d|› �«      ‚| j                  j                  ‰d¬«      }|S | j                  dk(  r°| j                  \  }}| j                  d   |z  ‰kD  rt        d«      ‚t        | j                  Ž ‰kD  r.| j                  |z  ‰kD  j                  «       rt        d|› �«      ‚| j                  j                  ‰d¬«      }| j                  j                  ‰d¬«      }||fS t        d| j                  › d�«      ‚)a3	  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 : str, 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 ©ÚcscÚcsréÿÿÿÿzindptr values too large for zindices values too large for F©rL   Úcooc              3   óD   •K  — | ]  }|‰kD  j                  «       –— Œ y ­wr>   )Úany)r@   ÚcoÚ	max_values     €r   rA   z+safely_cast_index_arrays.<locals>.<genexpr>ì   s   øè ø€ Ò=¨b�B˜‘N×'Ñ'×)Ñ=ùó   ƒ zcoords values too large for c              3   óD   •K  — | ]  }|j                  ‰d ¬«      –— Œ y­w)FrU   N)r+   )r@   rY   Ú	idx_dtypes     €r   rA   z+safely_cast_index_arrays.<locals>.<genexpr>î   s   øè ø€ ÒI¸"�R—Y‘Y˜y¨u�Y×5ÑIù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.)r   r.   r,   ÚformatÚindptrr/   ÚshapeÚindicesrX   r+   ÚcoordsÚtupleÚoffsetsÚ	blocksizer   )	r9   r]   Úmsgrc   ra   rf   ÚRÚCrZ   s	    `      @r   Úsafely_cast_index_arraysrk   ™   sY  ù€ ñ| Ø�y�kÐ"ˆä—‘˜Ó#×'Ñ'€Ià‡x�x�>Ñ!à�8‰8�B‰<˜)Ò#ÜÐ;¸C¸5ÐAÓBÐBô �—‘ˆ=˜9Ò$Ø—	‘	˜IÑ%×*Ñ*Ô,Ü Ð#@ÀÀÐ!FÓGÐGà—)‘)×"Ñ" 9°5Ð"Ó9ˆØ—‘—‘ °�Ó7ˆØ˜ˆÐà	
�‰�UÒ	Ü�—‘ˆ=˜9Ò$ÜÓ=°A·H±HÔ=Ô=Ü Ð#?À¸uÐ!EÓFÐFÜÓIÀÇÁÔIÓIÐIà	
�‰�UÒ	Ü�—‘ˆ=˜9Ò$Ø—	‘	˜IÑ%×*Ñ*Ô,Ü Ð#@ÀÀÐ!FÓGÐGØ—)‘)×"Ñ" 9°5Ð"Ó9ˆØˆà	
�‰�UÒ	Ø�{‰{‰ˆˆ1Ø�8‰8�B‰<˜!Ñ˜iÒ'ÜÐ@ÓAÐAÜ�—‘ˆ=˜9Ò$Ø—	‘	˜A‘ 	Ñ)×.Ñ.Ô0Ü Ð#@ÀÀÐ!FÓGÐGØ—)‘)×"Ñ" 9°5Ð"Ó9ˆØ—‘—‘ °�Ó7ˆØ˜ˆÐô ˜' !§(¡( ð ,Eð Eó Fð 	Fr   c                 ó¤  — t        j                  «       j                  dk7  rt         j                  S t        j                  t        j
                  t         j                  «      j                  «      }t        j                  t        j
                  t         j                  «      j                  «      }|�*t        j                  |«      }||kD  rt         j                  S t        | t         j                  «      r| f} | D ]Â  }t        j                  |«      }t        j                  |j                  t         j                  «      rŒG|ri|j                  dk(  rŒYt        j                  |j                  t         j                  «      r+|j                  «       }|j                  «       }||k\  r||k  rŒ²t         j                  c S  t         j                  S )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   )r   Úintcr(   Úint64Úint32r.   r-   r,   Ú
isinstanceÚndarrayr7   r   r    r*   Ú
issubdtypeÚinteger)Úarraysr1   Úcheck_contentsÚint32minÚint32maxr0   r2   s          r   Úget_index_dtypery     s3  € ôR 
‡w�wƒy×Ñ˜QÒÜ�x‰xˆä�x‰xœŸ™¤§¡Ó*×.Ñ.Ó/€HÜ�x‰xœŸ™¤§¡Ó*×.Ñ.Ó/€HàÐÜ—‘˜&Ó!ˆØ�HÒÜ—8‘8ˆOä�&œ"Ÿ*™*Ô%Ø�ˆàò ˆÜ�j‰j˜‹oˆÜ�{‰{˜3Ÿ9™9¤b§h¡hÕ/ÙØ—8‘8˜q’=àÜ—]‘] 3§9¡9¬b¯j©jÔ9Ø ŸW™W›Y�FØ ŸW™W›Y�FØ Ò)¨f¸Ò.@à Ü—8‘8ŠOðô �8‰8€Or   r    c                 óô   — | j                   dk(  r4t        j                  | t        j                  «      rt        j                  S t        j                  | t        j                  «      rt        j                  S | S )z Mimic numpy's casting for np.sumÚu)Úkindr   r   ÚuintÚint_r#   s    r   r   r   O  sH   € à‡z�z�SÒœRŸ[™[¨´·±Ô8Ü�w‰wˆÜ	‡{�{�5œ"Ÿ'™'Ô"Ü�w‰wˆØ€Lr   c                 óh   — t        j                  | «      xs t        | «      xr | j                  dk(  S )z8Is x either a scalar, an array scalar, or a 0-dim array?r   )r   Úisscalarr   Úndim©Úxs    r   r	   r	   X  s&   € ä�;‰;�q‹>Ò9œg a›jÒ8¨Q¯V©V°q©[Ð9r   c                 ó  — t        j                  | «      dk7  ry	 t        j                  | «       y# t        t
        f$ rC 	 t        t        | «      | k(  «      }n# t        t
        f$ r Y Y yw xY w|rd}t        |«      ‚|cY S w xY w)zsIs x appropriate as an index into a sparse matrix? Returns True
    if it can be cast safely to a machine int.
    r   Fz4Inexact indices into sparse matrices are not allowedT)r   r�   ÚoperatorÚindexr   r/   ÚboolÚint)rƒ   Ú	loose_intrh   s      r   r
   r
   ]  sˆ   € ô 
‡w�wˆqƒz�Q‚Øð
Ü�‰�qÔð øô ”zÐ"ò ð	ÜœS ›V q™[Ó)‰IøÜœ:Ð&ò 	Úð	úáØHˆCÜ˜S“/Ð!ØÒðús3   ›1 ±BÁAÁBÁA,Á(BÁ+A,Á,BÂB)é   T)Úallow_ndÚcheck_ndc                ód   — t        | «      }|r||vry| D ]  }t        |«      s y|sŒ|dk  sŒ y y)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.
    Fr   T)Úlenr
   )rƒ   Únonnegr‹   rŒ   r�   Úds         r   r   r   s  sD   € ô ˆq‹6€DÙ�D Ñ(Øàò ˆÜ˜Œ|ÙÚ�a˜!“eÙð	ð
 r   c                 óÞ   — t        | t        t        z  «      xr( t        | «      dk(  xs t	        j
                  | d   «      xs+ t        | t        j                  «      xr | j                  dk(  S )Nr   é   )rq   Úlistre   rŽ   r   r€   rr   r�   ©r   s    r   r   r   …  sW   € Ü˜œ4¤%™<Ó(ò /Ü�‹V�q‰[Ò-œBŸK™K¨¨!©Ó-ò:ä˜œ2Ÿ:™:Ó&Ò8¨A¯F©F°a©Kð;r   c                 óÊ   — t        | t        t        z  «      xr t        | «      dkD  xr t	        | d   «      xs+ t        | t
        j                  «      xr | j                  dk(  S )Nr   rŠ   )rq   r“   re   rŽ   r   r   rr   r�   r”   s    r   r   r   ‹  sV   € Ü˜œ4¤%™<Ó(ò -Ü�‹V�a‰Zò-Ü& q¨¡tÓ,ò8ä˜œ2Ÿ:™:Ó&Ò6¨1¯6©6°Q©;ð9r   c                 ó6   — t        | t        j                  «      S r>   )rq   r   rr   r‚   s    r   r   r   ‘  s   € Ü�aœŸ™Ó$Ð$r   rŠ   )r�   .c                ó>  — | €y | dk(  rt        d«      ‚t        | t        «      sZt        j                  t        j
                  t        | «      «      t        j                  «      st        dt        | «      › �«      ‚| f} g }| D ]L  }t        |«      st        d|› d�«      ‚|dk  r||z  }|dk  s||k\  rt        d«      ‚|j                  |«       ŒN t        |«      }|t        t        |«      «      k7  rt        d«      ‚||kD  rt        d	«      ‚||k(  ry t        |«      S )
N© zWsparse 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 ú)r   zaxis out of range for ndimzduplicate value in axisz axis tuple has too many elements)r/   rq   re   r   rs   r    Útypert   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˜4’ZÜÐ9Ó:Ð:Ø×Ñ˜"Õðô �:‹€HØ”3”s˜:“Ó'Ò'ÜÐ2Ó3Ð3Ø	�DŠÜÐ;Ó<Ð<Ø	�TÒ	Øä�ZÓ Ð r   )r‹   c                óp  — t        | «      dk(  rt        d«      ‚t        | «      dk(  r"	 t        | d   «      }t        d„ |D «       «      }nt        d„ | D «       «      }|€;t        |«      |vrt        d|› d|›�«      ‚t        d	„ |D «       «      rÛt        d
«      ‚t        |«      }t        |«      D ��cg c]  \  }}|dk  sŒ|‘Œ }}}|s!t        |«      }	|	|k7  r�t        d|› d|› �«      ‚t        |«      dk(  rf|d   }
t        |d|
 ||
dz   d z   «      }t        ||«      \  }}|dk7  r#t        d„ |D «       «      }t        d|› d|› �«      ‚|d|
 |fz   ||
dz   d z   }nt        d«      ‚t        |«      |vrt        d|› d|›�«      ‚|S # t        $ r t	        j
                  | d   «      f}Y �ŒRw xY wc c}}w )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.
    r   z8function missing 1 required positional argument: 'shape'r’   c              3   óF   K  — | ]  }t        j                  |«      –— Œ y ­wr>   ©r…   r†   ©r@   Úargs     r   rA   zcheck_shape.<locals>.<genexpr>Õ  s   è ø€ ÒH°cœhŸn™n¨S×1ÑHùó   ‚!c              3   óF   K  — | ]  }t        j                  |«      –— Œ y ­wr>   r¤   r¥   s     r   rA   zcheck_shape.<locals>.<genexpr>×  s   è ø€ Ò>°#œ(Ÿ.™.¨×-Ñ>ùr§   Nzshape must have length in z. Got new_shape=c              3   ó&   K  — | ]	  }|d k  –— Œ y­w)r   Nr˜   )r@   r�   s     r   rA   zcheck_shape.<locals>.<genexpr>Ü  s   è ø€ Ò(˜ˆq�1�uÑ(ùs   ‚z#'shape' elements cannot be negativezcannot reshape array of size z into shape c              3   ó.   K  — | ]  }|d k  rdn|–— Œ y­w)r   ÚnewshapeNr˜   )r@   rƒ   s     r   rA   zcheck_shape.<locals>.<genexpr>î  s   è ø€ Ò!PÀ°°A²¡*¸1Ó"<Ñ!Pùs   ‚z&can only specify one unknown dimension)rŽ   r   Úiterre   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»   »  s  € ô$ ˆ4ƒy�A‚~ÜÐRÓSÐSÜ
ˆ4ƒy�A‚~ð	IÜ˜d 1™g›ˆJô ÑH¸ZÔHÓH‰IäÑ>¸Ô>Ó>ˆ	àÐÜˆy‹> Ñ)ÜÐ9¸(¸ÐCTÈ)ÈÐVÓWÐWÜÑ(˜iÔ(Ô(ÜÐBÓCÐCô ˜MÓ*ˆô +4°IÓ*>×H¡$ ! QÀ!ÀaÃ%šAÐHÐÑHÙÜ˜I“ˆHØ˜<Ò'Ü Ð#@ÀÀØ#/°	¨{ð"<ó =ð =äÐ!Ó" aÒ'Ø# AÑ&ˆDÜ˜Y u¨Ð-°	¸$¸q¹&¸'Ð0BÑBÓCˆIÜ%+¨L¸)Ó%DÑ"ˆK˜Ø˜AŠ~Ü!Ñ!PÀiÔ!PÓP�	Ü Ð#@ÀÀØ#/°	¨{ð"<ó =ð =à! % 4Ð(¨K¨>Ñ9¸IÀdÈ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   ©F	 Â2F2Ã F2Æ	"F/Æ.F/c                  óJ  — | sy| D �cg c]  }t        |t        t        z  «      r|n|f‘Œ  } }t        | t        ¬«      }t        |«      }| D ]M  }||u rŒt        |t	        |«       ¬«      D ],  \  }}|dk7  sŒ|||   k7  sŒ||   dk7  rt        d«      ‚|||<   Œ. ŒO g |¢­S c c}w )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.
    r˜   )Úkey)Ústartr’   z-shapes cannot be broadcast to a single shape.)rq   re   r“   r,   rŽ   r­   r/   )ÚshapesÚshpÚbig_shpÚoutr³   rƒ   s         r   r   r   û  sÁ   € ñ" ØØJPÖQÀ3”Z ¤U¬T¡\Ô2‰c¸¸Ñ>ÐQ€FÐQÜ�&œcÔ"€GÜ
ˆw‹-€CØò ˆØ�'‰>ØÜ˜c¬#¨c«(¨Ô3ò 	‰DˆAˆqØ�A‹v˜!˜s 1™v›+Ø�q‘6˜Q’;Ü$Ð%TÓUÐUØ��A’ñ		ðð ˆS‰7€Nùò Rs   ˆ#B c                 óz   — t        t        j                  j                  d«      dd«      }|duxr t	        | |«      S )zV
    Check whether object is pydata/sparse matrix, avoiding importing the module.
    ÚsparseÚSparseArrayN)ÚgetattrÚsysÚmodulesr   rq   )ÚmÚbase_clss     r   Úis_pydata_spmatrixrË     s6   € ô ”s—{‘{—‘ xÓ0°-ÀÓF€HØ˜4ÐÒ;¤J¨q°(Ó$;Ð;r   r¦   Útarget_formatrQ   Ú	accept_fvzsp.spmatrix | Anyc                 óæ   — t        | «      rF	 | j                  |¬«      } |�| j                  |«      } | S | j                  dvr| j                  «       } | S # t        $ r | j                  «       } Y ŒPw xY w)z_
    Convert a pydata/sparse array to scipy sparse matrix,
    pass through anything else.
    )rÍ   rQ   )rË   Úto_scipy_sparser   Úasformatr`   Útocsc)r¦   rÌ   rÍ   s      r   Úconvert_pydata_sparse_to_scipyrÒ   $  s~   € ô ˜#Ôð	(Ø×%Ñ%°	Ð%Ó:ˆCð Ð$Ø—,‘,˜}Ó-ˆCð €Jð �Z‰Z˜~Ñ-Ø—)‘)“+ˆCØ€Jøô ò 	(Ø×%Ñ%Ó'ŠCð	(ús   �A ÁA0Á/A0c                  óf   — t        j                  | i |¤Žj                  t         j                  «      S r>   )r   r$   ÚviewÚmatrix)r   Úkwargss     r   rÕ   rÕ   A  s%   € Ü�8‰8�TÐ$˜VÑ$×)Ñ)¬"¯)©)Ó4Ð4r   c                 óÄ   — t        | t        j                  «      r|�| j                  |k(  r| S t        j                  | |¬«      j                  t        j                  «      S )Nr#   )rq   r   rÕ   r    r7   rÔ   )rN   r    s     r   ÚasmatrixrØ   E  sD   € Ü�$œŸ	™	Ô"¨¨¸¿¹ÀuÒ9LØˆÜ�:‰:�d %Ô(×-Ñ-¬b¯i©iÓ8Ð8r   c                 ó0  — t        | t        j                  j                  «      r| j	                  «       S t        | t        j
                  «      r:t        j                  | j                  «       | j                  | j                  ¬«      S t        | t        j                  «      rWt        j                  | j                  | j                  ¬«      }t        j                  j                  | j                  |«       |S | j!                  «       j	                  «       S )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#   )rq   ÚspÚ_dataÚ_data_matrixÚ_deduped_dataÚ	dok_arrayr   ÚfromiterÚvaluesr    ÚnnzÚ	lil_arrayÚemptyÚ_csparsetoolsÚlil_flatten_to_arrayrN   Útocoo)ÚsrN   s     r   Ú_todataré   M  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   )NN)NF)r˜   NF)Fr>   )AÚ__doc__rÇ   Útypingr   r   r…   Únumpyr   Úmathr   Úscipy.sparserÄ   rÛ   Ú__all__Úbool_ÚbyteÚubyteÚshortÚushortrn   ÚuintcÚlongÚulongÚlonglongÚ	ulonglongÚfloat32Úfloat64Ú
longdoubleÚ	complex64Ú
complex128Úclongdoubler   r   r   r!   r&   r3   r;   r   rr   r   rp   rk   ry   r    rš   Úgenericr   r‡   r	   r
   r   r   r   r   re   rˆ   r¡   r»   r   rË   rÒ   rÕ   rØ   ré   r˜   r   r   ú<module>r     s  ðñó ß Û Û Ý Ý ò€ð —H‘H˜bŸg™g r§x¡x°·±¸2¿9¹9ÀbÇgÁgØ—H‘H˜bŸg™g r§x¡x°·±¸b¿l¹lØ—J‘J §
¡
¨B¯M©MØ—L‘L "§-¡-°·±ðAÐ ð
 €òDòDò7òò(:ó ñ<	¨B¯J©Jó 	ð +-¯(©(¸ó kFó\EðP˜Ÿ™ð  b§h¡h°°b·j±jÑ1AÑ&Aó ð:�tó :ð
�Dó ð,¨¸ò Àó ð$;�Tó ;ð9�4ó 9ð%�$ó %ð  !ò #! U¨3°¨8¡_°tÑ%;ó #!ðL=°dò =¸uÀSÈ#ÀX¹ó =ò@ðB<˜Tó <ð 37ØñØ	ðà˜' ,Ñ/Ñ/ðð ðð ó	ò:5ó9ð%�"—*‘*ô %r   