o
    hl                     @   s"  d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	Z
d dl	Z	d dlmZ d dlZzd dlZW n eyG   dZY nw d@ddZdd Zejjeddejd	d
gdd Zdd Zdd Zdd Zejjedu dddd Zdd dD Zejdk redd dD 7 Zg dZdd dD Zejdk redd d D 7 Zd!d" Zejdk rd#gZng Zej d$d%d& Z!g d'Z"ejdk re"g d(7 Z"d)d* Z#d+d, Z$ejj%e&d-d.vd/dd0d1 Z'd2d3 Z(ej d4d5d6 Z)d7d8 Z*d9d: Z+d;e,fd<d=Z-d>d? Z.dS )A    N)IS_WASMc                 C   sj   |du r| j }i }t| D ]%}|dkrqt| |}t|dr2t|dr2|j|kr2|jd |j  ||< q|S )zEReturns a mapping of all objects with the wrong __module__ attribute.Ncore
__module____name__.)r   dirgetattrhasattrr   )modulemodule_nameresultsnameitem r   o/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/numpy/tests/test_public_api.py	check_dir   s   

r   c                  C   s    ddi} t t}|| ksJ d S )Nrecarrayznumpy.rec.recarray)r   np)	allowlistbad_resultsr   r   r   test_numpy_namespace&   s   r   zcan't start subprocess)reasonr   testingc                 C   s6   t jdd|  f}t|}|rJ | ttv sJ dS )a  Make sure we can actually use the modules we lazy load.

    While not exported as part of the public API, it was accessible.  With the
    use of __getattr__ and __dir__, this isn't always true It can happen that
    an infinite recursion may happen.

    This is the only way I found that would force the failure to appear on the
    badly implemented code.

    We also test for the presence of the lazily imported modules in dir

    z-czimport numpy; numpy.N)sys
executable
subprocesscheck_outputr   r   )r   exeresultr   r   r   test_import_lazy_import1   s   
r   c                   C   s$   t ttt tttksJ dS )zWAssert that output of dir has only one "testing/tester"
    attribute without duplicateN)lenr   r   setr   r   r   r   test_dir_testingH   s   $r"   c                  C      t tj} | i ksJ d S N)r   r   linalgr   r   r   r   test_numpy_linalgN      
r'   c                  C   r#   r$   )r   r   fftr&   r   r   r   test_numpy_fftS   r(   r*   z#ctypes not available in this pythonc                  C   s0   t tjjj} t| dd }|d u sJ dd S )Ntest_not_exportedzG'test_not_exported' is mistakenly exported, NPY_NO_EXPORT does not work)ctypesCDLLr   _core_multiarray_tests__file__r   )cdllfr   r   r   test_NPY_NO_EXPORTX   s   r3   c                 C      g | ]}d | qS numpy.r   .0sr   r   r   
<listcomp>n       r:   ) 	ctypeslibdtypes
exceptionsf2pyr)   libzlib.array_utilsz
lib.formatzlib.introspectz
lib.mixinsz	lib.npyiozlib.recfunctionszlib.scimathzlib.stride_tricksr%   maz	ma.extraszma.mrecords
polynomialzpolynomial.chebyshevzpolynomial.hermitezpolynomial.hermite_ezpolynomial.laguerrezpolynomial.legendrezpolynomial.polynomialrandomstringsr   ztesting.overridestypingztyping.mypy_pluginversion)      c                 C   r4   r5   r   r7   r   r   r   r:          )	distutilszdistutils.cpuinfozdistutils.exec_commandzdistutils.misc_utilzdistutils.logzdistutils.system_info)
numpy.charznumpy.emath	numpy.recc                 C   r4   r5   r   r7   r   r   r   r:      r;   ),compatzcompat.py3kconftestr   zcore.multiarrayzcore.numericz
core.umathzcore.arrayprintzcore.defchararrayzcore.einsumfunczcore.fromnumericzcore.function_basezcore.getlimitszcore.numerictypeszcore.overrideszcore.recordszcore.shape_basezf2py.auxfuncszf2py.capi_mapszf2py.cb_ruleszf2py.cfuncszf2py.common_ruleszf2py.crackfortranzf2py.diagnosezf2py.f2py2ezf2py.f90mod_ruleszf2py.func2subrz
f2py.ruleszf2py.symboliczf2py.use_rulesz
fft.helperzlib.user_arrayzlinalg.lapack_litezlinalg.linalgzma.corezma.testutilszma.timer_comparisonmatlib	matrixlibzmatrixlib.defmatrixzpolynomial.polyutilszrandom.mtrandzrandom.bit_generatorztesting.print_coercion_tablesc                 C   r4   r5   r   r7   r   r   r   r:      rI   )7zdistutils.armccompilerzdistutils.fujitsuccompilerzdistutils.ccompilerzdistutils.ccompiler_optzdistutils.commandzdistutils.command.autodistzdistutils.command.bdist_rpmzdistutils.command.buildzdistutils.command.build_clibzdistutils.command.build_extzdistutils.command.build_pyzdistutils.command.build_scriptszdistutils.command.build_srczdistutils.command.configz!distutils.command.config_compilerzdistutils.command.developzdistutils.command.egg_infozdistutils.command.installzdistutils.command.install_clibzdistutils.command.install_dataz!distutils.command.install_headerszdistutils.command.sdistzdistutils.conv_templatezdistutils.corezdistutils.extensionzdistutils.fcompilerzdistutils.fcompiler.absoftzdistutils.fcompiler.armzdistutils.fcompiler.compaqzdistutils.fcompiler.environmentzdistutils.fcompiler.g95zdistutils.fcompiler.gnuzdistutils.fcompiler.hpuxzdistutils.fcompiler.ibmzdistutils.fcompiler.intelzdistutils.fcompiler.laheyzdistutils.fcompiler.mipszdistutils.fcompiler.nagzdistutils.fcompiler.nonezdistutils.fcompiler.pathf95zdistutils.fcompiler.pgzdistutils.fcompiler.nvzdistutils.fcompiler.sunzdistutils.fcompiler.vastzdistutils.fcompiler.fujitsuzdistutils.from_templatezdistutils.intelccompilerzdistutils.lib2defzdistutils.line_endingszdistutils.mingw32ccompilerzdistutils.msvccompilerzdistutils.npy_pkg_configzdistutils.numpy_distributionzdistutils.pathccompilerzdistutils.unixccompilerc                 C   sD   d| v sd| v sd| v rdS | t v rdS | tv rdS | tv r dS dS )z%Check if this needs to be considered.z._z.testsz.setupFT)PUBLIC_MODULESPUBLIC_ALIASED_MODULESPRIVATE_BUT_PRESENT_MODULESr   r   r   r   is_unexpected  s   rU   znumpy.distutils.msvc9compilerz'ignore:.*np.compat.*:DeprecationWarningc                  C   sX   g } t jtjtjd ddD ]\}}}t|r |tvr | | q| r*td|  dS )z|
    Test that we don't add anything that looks like a new public module by
    accident.  Check is based on filenames.
    r   N)pathprefixonerrorzFound unexpected modules: )	pkgutilwalk_packagesr   __path__r   rU   	SKIP_LISTappendAssertionError)modnames_modnameispkgr   r   r   test_all_modules_are_expected)  s   
rc   )znumpy.lib.mathznumpy.matlib.charznumpy.matlib.recznumpy.matlib.emathznumpy.matlib.exceptionsznumpy.matlib.mathznumpy.matlib.linalgznumpy.matlib.fftznumpy.matlib.randomznumpy.matlib.ctypeslibznumpy.matlib.ma)znumpy.distutils.log.sysznumpy.distutils.log.loggingznumpy.distutils.log.warningsc                  C   s>   dd } | d}t D ]	}|| | q
|rtd|dS )a  
    Method checking all objects. The pkgutil-based method in
    `test_all_modules_are_expected` does not catch imports into a namespace,
    only filenames.  So this test is more thorough, and checks this like:

        import .lib.scimath as emath

    To check if something in a module is (effectively) public, one can check if
    there's anything in that namespace that's a public function/object but is
    not exposed in a higher-level namespace.  For example for a `numpy.lib`
    submodule::

        mod = np.lib.mixins
        for obj in mod.__all__:
            if obj in np.__all__:
                continue
            elif obj in np.lib.__all__:
                continue

            else:
                print(obj)

    c                 S   sx   g }t | }t|dr|j}nt|}|D ]#}|ds9| d | }tt||tj	r9t
|r9|tvr9|| q|S )N__all__r`   r   )	importlibimport_moduler	   rd   r   
startswith
isinstancer   types
ModuleTyperU   SKIP_LIST_2r]   )mod_namemembersr
   objnamesobjnamefullobjnamer   r   r   find_unexpected_membersn  s   



z@test_all_modules_are_expected_2.<locals>.find_unexpected_membersnumpyz5Found unexpected object(s) that look like modules: {}N)rQ   extendr^   format)rq   unexpected_membersra   r   r   r   test_all_modules_are_expected_2U  s   rv   c               	   C   s   dd } g }t D ]}| |s|| q|rtd|tD ]}zt| W q ty5   || Y qw |r?td|tjdd$}tj	dt
d tj	dtd tD ]}| |sa|| qVW d	   n1 slw   Y  |rztd
|d	S )a	  
    Check that all submodules listed higher up in this file can be imported

    Note that if a PRIVATE_BUT_PRESENT_MODULES entry goes missing, it may
    simply need to be removed from the list (deprecation may or may not be
    needed - apply common sense).
    c              	   S   s*   zt |  W dS  ttfy   Y dS w )NFT)re   rf   ImportErrorAttributeError)r   r   r   r   check_importable  s   z-test_api_importable.<locals>.check_importablez5Modules in the public API that cannot be imported: {}z1Modules in the public API that were not found: {}T)recordalways)categoryNzPModules that are not really public but looked public and can not be imported: {})rQ   r]   r^   rt   rR   evalrx   warningscatch_warningsfilterwarningsDeprecationWarningImportWarningrS   )ry   module_namesr   wr   r   r   test_api_importable  sD   

r   Py_DEBUG)Nr   0zNumPy possibly built with `USE_DEBUG=True ./tools/travis-test.sh`, which does not expose the `array_api` entry point. See https://github.com/numpy/numpy/pull/19800c                  C   s   t dtjv } tj }z|jdd}W n ty$   |	dg }Y nw t
|dkr6| r4d}t|ddS ztdd |D }W n tyT   | rQd	}t|dY dS w |jd
kr\dS | }d|j d}|tu soJ |dS )zx
    Entry point for Array API implementation can be found with importlib and
    returns the main numpy namespace.
    platlib	array_api)groupr   z%No entry points for 'array_api' foundNc                 s   s    | ]
}|j d kr|V  qdS )rr   NrT   )r8   epr   r   r   	<genexpr>  s    z-test_array_api_entry_point.<locals>.<genexpr>z%'numpy' not in array_api entry pointsznumpy.array_apiznumpy entry point value 'z0' does not point to our Array API implementation)	sysconfigget_pathr   r0   re   metadataentry_pointsselectrx   getr    r^   nextStopIterationvalueloadrr   )numpy_in_sitepackagesepsxp_epsmsgr   xpr   r   r   test_array_api_entry_point  s4   



r   c                  C   sV   dd } dd }| t j}||}| t  }||}||ks)J d|| dS )z
    Checks if `dir(np)` and `np.__all__` are consistent and return
    the same content, excluding exceptions and private members.
    c                 S   s   dd | D S )Nc                 S   s   h | ]	}| d s|qS )r`   )rg   )r8   mr   r   r   	<setcomp>  s    zYtest_main_namespace_all_dir_coherence.<locals>._remove_private_members.<locals>.<setcomp>r   
member_setr   r   r   _remove_private_members  s   zFtest_main_namespace_all_dir_coherence.<locals>._remove_private_membersc                 S   s   |  dhS )Nbool)
differencer   r   r   r   _remove_exceptions  s   zAtest_main_namespace_all_dir_coherence.<locals>._remove_exceptionszMembers that break symmetry: N)r   rd   __dir__symmetric_difference)r   r   all_membersdir_membersr   r   r   %test_main_namespace_all_dir_coherence  s   

r   z:ignore:numpy.core(\.\w+)? is deprecated:DeprecationWarningc                  C   s   ddl m}  ttjD ]Q}|ds|dv sd| tv rqttj|}t	|rS|}|}t|D ] }|dr9q1t||}t
d| |gd}|t||u sQJ q1q|t| |u s\J qdS )	zp
    Check that all "semi-public" members of `numpy._core` are also accessible
    from `numpy.core` shims.
    r   Nr`   )testsrD   r6   __znumpy.core.)fromlist)
numpy.corer   r   r   r.   rg   rR   r   inspectismodule
__import__)r   member_namemember	submodulesubmodule_namesubmodule_member_namesubmodule_membercore_submoduler   r   r   test_core_shims_coherence  s2   


r   c                  C   s  ddl m} m}m}m}m}m} ddlm} t	h}t
 }t }	g }
t	g}t|dkr| }t|D ]~}t||}t|r`d|jv r`|ds`d|jvr`|dvr`||vr`|| || q2t|smt||t	jfr||v r|jdv r||jdkr|q2|jd	kr|jd
rq2|jdv r|jdkrq2|jdkrq2|
|j|j|	| f q2|| |j|	|< q2t|dks*~~~	t|
dksJ |
dS )z
    Check that each public function is available from one location only.

    Test performs BFS search traversing NumPy's public API. It flags
    any function-like object that is accessible from more that one place.
    r   )AnyCallableDictListSetTuple)_ArrayFunctionDispatcherrr   r`   numpy._core)r?   rA   r   r   )absolutearccosarccosharcsinarcsinharctanarctan2arctanh
left_shiftright_shift	conjugateinvert	remainderdivideconcatenatepower	transposetrimcoefznumpy.polynomialaddequal	not_equalgreatergreater_equalless
less_equalnumpy.stringsrK   N)rE   r   r   r   r   r   r   numpy._core._multiarray_umathr   r   r!   dictr    popr   r   r   r   r   rg   r]   r   
isfunctionrh   ufunc)r   r   r   r   r   r   dispatched_functionvisited_modulesvisited_functionsfunctions_original_pathsduplicated_functionsmodules_queuer
   r   r   r   r   r   test_functions_single_location:  sd    












Vr   c                  C   s`  t g} t h}t }g }t| dkr|  }t|D ]}t||}t|rGd|jv rG|	dsGd|jvrG|dvrG||vrG| 
| || qt|st|dr|j	ds|j|jkr||vr|jdv rl|jdkrlq|jd	krv|jdks|jd
kr|jdkrq|jdv rq|
t|j|j|jd || qt| dks|rt|dksJ |d S d S )Nr   rr   r`   r   )charr   r<   r?   rA   lapack_litemrecordsr   r   rB   rE   mtrandbit_generatorr   r   r   r   rz   rL   )	BitGenerator	GeneratorMT19937PCG64	PCG64DXSMPhiloxRandomStateSFC64SeedSequence)Funcactualexpected)r   r!   r    r   r   r   r   r   r   rg   r]   r   r	   r   r   r   r   r   incorrect_entriesr
   r   r   r   r   r   test___module___attribute  s`   








9r   returnc                 C   sb   | j }| j}| j}||dd ksJ tj| }tt|d|}|| u p0|	do0|j |kS )Nr   znumpy.random)
__qualname__r   r   splitr   modules	functoolsreducer   rg   )objqualnamer   r   r
   
actual_objr   r   r   _check___qualname__  s   

r  c                  C   s  t g} t h}t }g }t| dkr{|  }t|D ][}t||}t|rGd|jv rG|	dsG|dvrGd|jvrG||vrG| 
| || qt|stt|drt|j	dst|	dstt|st||vrt|
t|j|jd || qt| dks|rt|dksJ |d S d S )Nr   rr   r`   )r?   rA   r   r   rE   r   r<   r   r   r   )r   r   )r   r!   r    r   r   r   r   r   r   rg   r]   r   r	   r  r   r   r   r   r   r   test___qualname___attribute  sR   





!r  r$   )/r  r   r   r   rY   ri   re   r   r~   rr   r   numpy.testingr   pytestr,   rw   r   r   markskipifparametrizer   r"   r'   r*   r3   rQ   version_inforR   rS   rU   r\   r   rc   rk   rv   r   xfailget_config_varr   r   r   r   r   r   r  r  r   r   r   r   <module>   s    


"
.=



40
1
,sC