Ë
    àÌPhÌ  ã                   ó‚   — U d Z ddlmZmZ ddlmZmZmZ	 g Z
ee   ed<   ddœd„Zdd	œd
„Zdd	œd„Zdd	œd„Zdd„Zdd„Zy)aÜ  
Extra testing functions that forbid 0d-input, see #21044

While the xp_assert_* functions generally aim to follow the conventions of the
underlying `xp` library, NumPy in particular is inconsistent in its handling
of scalars vs. 0d-arrays, see https://github.com/numpy/numpy/issues/24897.

For example, this means that the following operations (as of v2.0.1) currently
return scalars, even though a 0d-array would often be more appropriate:

    import numpy as np
    np.array(0) * 2     # scalar, not 0d array
    - np.array(0)       # scalar, not 0d-array
    np.sin(np.array(0)) # scalar, not 0d array
    np.mean([1, 2, 3])  # scalar, not 0d array

Libraries like CuPy tend to return a 0d-array in scenarios like those above,
and even `xp.asarray(0)[()]` remains a 0d-array there. To deal with the reality
of the inconsistencies present in NumPy, as well as 20+ years of code on top,
the `xp_assert_*` functions here enforce consistency in the only way that
doesn't go against the tide, i.e. by forbidding 0d-arrays as the return type.

However, when scalars are not generally the expected NumPy return type,
it remains preferable to use the assert functions from
the `scipy._lib._array_api` module, which have less surprising behaviour.
é    )Úarray_namespaceÚis_numpy)Úxp_assert_closeÚxp_assert_equalÚxp_assert_lessÚ__all__N)Úxpc                ó®   — d}|€t        | «      }|j                  |«      }t        |«      r|j                  dk(  sy d}|j	                  | «      sJ |«       ‚y )NT© aÂ  Result is a NumPy 0d-array. Many SciPy functions intend to follow the convention of many NumPy functions, returning a scalar when a 0d-array would be correct. The specialized `xp_assert_*` functions in the `scipy._lib._array_api_no_0d` module err on the side of caution and do not accept 0d-arrays by default. If the correct result may legitimately be a 0d-array, pass `check_0d=True`, or use the `xp_assert_*` functions from `scipy._lib._array_api`.)r   Úasarrayr   ÚshapeÚisscalar)ÚactualÚdesiredr	   ÚkwargsÚ__tracebackhide__Ú_msgs         úfC:\Users\daisl\Desktop\realtime-object-detection\venv\Lib\site-packages\scipy/_lib/_array_api_no_0d.pyÚ_check_scalarr   #   s_   € ØÐà	€zÜ˜VÓ$ˆð j‰j˜Ó!€Gô RŒL˜WŸ]™]¨bÒ0ØðO€Dð ;‰;vÔÐ$ Ó$Ñó    F)Úcheck_0dc                óB   — d}|st        | |fi |¤Ž t        | |fd|i|¤ŽS ©NTr   )r   Úxp_assert_equal_base©r   r   r   r   r   s        r   r   r   ;   s5   € ð Ðñ Üf˜gÑ0¨Ò0Ü ¨ÑM¸(ÐMÀfÑMÐMr   c                óB   — d}|st        | |fi |¤Ž t        | |fd|i|¤ŽS r   )r   Úxp_assert_close_baser   s        r   r   r   F   s1   € àÐáÜf˜gÑ0¨Ò0Ü ¨ÑM¸(ÐMÀfÑMÐMr   c                óB   — d}|st        | |fi |¤Ž t        | |fd|i|¤ŽS r   )r   Úxp_assert_less_baser   s        r   r   r   O   s1   € àÐáÜf˜gÑ0¨Ò0Ü˜v wÑL¸ÐLÀVÑLÐLr   c                 óB   — ddd| z  z  }}t        | |g|¢­||dddœ|¤ŽS ©zPBackwards compatible replacement. In new code, use xp_assert_close instead.
    r   g      ø?é
   F)ÚatolÚrtolÚcheck_dtypeÚcheck_shape©r   ©r   r   ÚdecimalÚargsÚkwdsr$   r#   s          r   Úassert_array_almost_equalr,   X   óH   € ð C˜˜g˜X™Ñ&ˆ$€DÜ˜6 7ð *à ñ*Ø $¨4¸UÐPUñ*à$(ñ*ð *r   c                 óB   — ddd| z  z  }}t        | |g|¢­||dddœ|¤ŽS r!   r'   r(   s          r   Úassert_almost_equalr/   a   r-   r   )é   )é   )Ú__doc__Úscipy._lib._array_apir   r   r   r   r   r   r   r   r   ÚlistÚstrÚ__annotations__r   r,   r/   r   r   r   Ú<module>r7      s`   ðò÷4 <÷Jñ Jð €ˆˆc‰Ó ð *.ô %ð0 27ô Nð 27ô Nð 16ô Mó*ô*r   