zmc
2023-12-22 9fdbf60165db0400c2e8e6be2dc6e88138ac719a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
U
P±d :ã@sddlZddlZddlZddlZddlZddlZddlmZddl    m
Z
m Z ddl m Z ddlmZddlmZddlmZmZGd    d
„d
ejƒZGd d „d ejƒZGd d„dejƒZe ¡ZGdd„dejƒZGdd„dƒZGdd„de ƒZ e Z!Gdd„de ƒZ"Gdd„dej#j$ƒZ%dS)éN)Údoctests)Ú
ErrorClassÚErrorClassPlugin)ÚPlugin)Úsrcé)Úget_package_name)ÚKnownFailureExceptionÚKnownFailureTestc@seZdZdd„Zdd„ZdS)ÚNumpyDocTestFindercCs´|dkr dSt |¡r"|j|jkSt |¡r8|j|jkSt |¡rN|j|jkSt |¡rh|j|j    j
jkSt  |¡dk    r„|t  |¡kSt |dƒrš|j|jkSt |tƒr¨dStdƒ‚dS)zY
        Return true if the given object is defined in the given
        module.
        NTÚ
__module__z"object must be a class or function)ÚinspectÚ
isfunctionÚ__dict__Ú __globals__Ú    isbuiltinÚ__name__r ÚisclassÚismethodÚ__self__Ú    __class__Ú    getmoduleÚhasattrÚ
isinstanceÚpropertyÚ
ValueError)ÚselfÚmoduleÚobject©rúYd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\numpy/testing/_private/noseclasses.pyÚ _from_modules"
 
 
 
 
 
zNumpyDocTestFinder._from_modulec
CsDtj ||||||||¡ddlm}m}    m}
m} m} |
|ƒr˜|j    r˜|j
  ¡D]H\} }|›d| ›}||ƒst|    |ƒrN|  ||¡rN| |||||||¡qN|    |ƒr@|j    r@|j
  ¡D]Š\} }t |tƒrÐt|| ƒ}t |tƒræt|| ƒj}| |ƒs|    |ƒs| |ƒst |tƒr´|  ||¡r´|›d| ›} | ||| ||||¡q´dS)zm
        Find tests for the given object and any contained objects, and
        add them to `tests`.
        r)Ú    isroutinerÚismodulerrÚ.N)ÚdoctestÚ DocTestFinderÚ_findr r"rr#rrZ_recurserÚitemsr!rÚ staticmethodÚgetattrÚ classmethodÚ__func__r)rÚtestsÚobjÚnamerZ source_linesÚglobsÚseenr"rr#rrZvalnameÚvalZvalname1rrr r':sDÿ
ÿÿ
 
 
 ÿÿ
þÿzNumpyDocTestFinder._findN)rr Ú __qualname__r!r'rrrr r sr c@seZdZdd„ZdS)ÚNumpyOutputCheckercCsztj ||||¡}|svd|kr"dS| dd¡}| dd¡}dD]$}| d|d¡}| d|d¡}q>tj ||||¡}|S)Nz#randomTz'>z'<)ééz'<i%d'Úint)r%Ú OutputCheckerÚ check_outputÚreplace)rZwantÚgotÚ optionflagsÚretÚszrrr r9ls  ÿ  
ÿzNumpyOutputChecker.check_outputN)rr r3r9rrrr r4ksr4c@seZdZddd„ZdS)ÚNumpyDocTestCaserNÚ_cCs(||_||_tjj||||||ddS)N)r<ÚsetUpÚtearDownÚchecker)Z _result_varZ    _nose_objr%Ú DocTestCaseÚ__init__)rÚtestr<rArBrCr.Ú
result_varrrr rE‰s
ýzNumpyDocTestCase.__init__)rNNNNr@)rr r3rErrrr r?ˆs
ÿr?c@sjeZdZdZdZejejBZddgZ    e
Z e Z eZejfdd„Zdd„Zd    d
„Zd d „Zd d„Zdd„ZdS)Ú NumpyDoctestZ numpydoctestièzgenerate_numpy_api.pyzsetup.pycCst |||¡d|_d|_dS)NT)rÚoptionsZ doctest_testsÚdoctest_result_var©rÚparserÚenvrrr rI¦szNumpyDoctest.optionscCsBt |||¡| ¡|_t ¡|_|jr>dd„|jjDƒ|j_dS)NcSsg|]}|jdkr|‘qS)r%)r/©Ú.0Úprrr Ú
<listcomp>¹s
ÿz*NumpyDoctest.configure.<locals>.<listcomp>)    rÚ    configureÚtest_finder_classÚfinderr%Z DocTestParserrLÚenabledÚplugins©rrIÚconfigrrr rR¯s
 
 
zNumpyDoctest.configurecCsXttj |j¡ƒ}tddtdœ|_d|krT| d¡}|d}t    ||ji|gƒ|j|<dS)a` Configure `test` object to set test context
 
        We set the numpy / scipy standard doctest namespace
 
        Parameters
        ----------
        test : test object
            with ``globs`` dictionary defining namespace
 
        Returns
        -------
        None
 
        Notes
        -----
        `test` object modified in place
        Ú__main__)Ú __builtins__Ú__file__rÚnpZscipyr$éÿÿÿÿN)
rÚosÚpathÚdirnameÚfilenamerZÚnumpyr0ÚsplitÚ
__import__)rrFÚpkg_namerPÚp2rrr Úset_test_context¼s
ý
zNumpyDoctest.set_test_contextccs¨| |j¡stj d|¡dSz|j |¡}Wntk
rDYdSX|sNdS| ¡t    |j
ƒ}|D]>}|j spqd|j s|||_ |  |¡|j||j| ¡|jdVqddS)NzDoctest doesn't want module %s)r<rCrG)ÚmatchesrÚnpdÚlogÚdebugrTÚfindÚAttributeErrorÚsortrr[ZexamplesrargÚdoctest_case_classÚdoctest_optflagsÚout_check_classrJ)rrr-Z module_filerFrrr ÚloadTestsFromModuleæs, 
 
ýz NumpyDoctest.loadTestsFromModulecCstjftŽdS©N)rbZset_printoptionsÚ print_state©rrrr Ú afterContextszNumpyDoctest.afterContextcCs(tj |¡}||jkrdStj ||¡S)NF)r^r_ÚbasenameÚdoctest_ignoreriÚDoctestÚwantFile)rÚfileZbnrrr rzs 
zNumpyDoctest.wantFileN)rr r3r/Úscorer%ZNORMALIZE_WHITESPACEÚELLIPSISrprxr?ror4rqr rSr^ÚenvironrIrRrgrrrvrzrrrr rH•s ÿ     *rHc@s6eZdZdZdZdZdZd dd„Zdd    „Zd
d „Z    d S)Ú    Unpluggerzi Nose plugin to remove named plugin late in loading
 
    By default it removes the "doctest" plugin.
    Z    unpluggerTi r%cCs
||_dSrs)Ú    to_unplug)rr€rrr rEszUnplugger.__init__cCsdSrsrrKrrr rIszUnplugger.optionscs‡fdd„|jjDƒ|j_dS)Ncsg|]}|jˆjkr|‘qSr)r/r€rNrurr rQs ÿz'Unplugger.configure.<locals>.<listcomp>)rVrWrrur rRszUnplugger.configureN)r%)
rr r3Ú__doc__r/rUr|rErIrRrrrr r s
rc@s8eZdZdZdZeedddZej    fdd„Z
dd    „Z d
S) ÚKnownFailurePlugina1Plugin that installs a KNOWNFAIL error class for the
    KnownFailureClass exception.  When KnownFailure is raised,
    the exception will be logged in the knownfail attribute of the
    result, 'K' or 'KNOWNFAIL' (verbose) will be output, and the
    exception will not be counted as an error or failure.TZ    KNOWNFAILF)ÚlabelZ    isfailurecCs$d}|jddd| |d¡dddS)NZNOSE_WITHOUT_KNOWNFAILz--no-knownfailÚ
store_trueÚ noKnownFailFz3Disable special handling of KnownFailure exceptions)ÚactionÚdestÚdefaultÚhelp)Ú
add_optionÚget)rrLrMZenv_optrrr rI-s 
þzKnownFailurePlugin.optionscCs*|js
dS||_t|ddƒ}|r&d|_dS)Nr…F)Z can_configureÚconfr*rU)rrIrŒÚdisablerrr rR4s  zKnownFailurePlugin.configureN) rr r3rrUrr    Z    knownfailr^r~rIrRrrrr r‚"sþr‚c@seZdZdZdd„ZdS)ÚFPUModeCheckPluginzx
    Plugin that checks the FPU mode before and after each test,
    raising failures if the test changed the mode.
    csddlm‰‡‡fdd„}|S)Nr)Ú get_fpu_modecs\ˆƒ}ˆ |¡ˆƒ}||krXztd ||¡ƒ‚Wn$tk
rV| ˆt ¡¡YnXdS)Nz6FPU mode changed from {0:#x} to {1:#x} during the test)rFÚAssertionErrorÚformatZ
addFailureÚsysÚexc_info)ÚresultZold_modeZnew_mode©rrFrr ÚrunHs
ÿÿz/FPUModeCheckPlugin.prepareTestCase.<locals>.run)Znumpy.core._multiarray_testsr)rrFr–rr•r ÚprepareTestCaseEs  z"FPUModeCheckPlugin.prepareTestCaseN)rr r3rr—rrrr rŽ?srŽc@seZdZdd„ZdS)ÚNumpyTestProgramcCsh|jdkr(tjj|jj|jj|jd|_|jj |j¡}|dk    rF||_|j     |j
¡|_ |j   ¡|_ |j S)aRun Tests. Returns true on success, false on failure, and
        sets self.success to the same value.
 
        Because nose currently discards the test result object, but we need
        to return it to the user, override TestProgram.runTests to retain
        the result
        N)ÚstreamÚ    verbosityrX)Z
testRunnerÚnoseÚcoreZTextTestRunnerrXr™ršrVZprepareTestRunnerr–rFr”Z wasSuccessfulÚsuccess)rZ plug_runnerrrr ÚrunTests[s
 þ zNumpyTestProgram.runTestsN)rr r3ržrrrr r˜Zsr˜)&r^r’r%r rbr›Z nose.pluginsrriZnose.plugins.errorclassrrZnose.plugins.baserZ    nose.utilrZ
nosetesterrÚutilsr    r
r&r r8r4rDr?Zget_printoptionsrtryrHrr‚Z KnownFailurerŽrœZ TestProgramr˜rrrr Ú<module>s*        O x