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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
U
P±d Nã@srdZddlZddlZddlZddlZddlmZmZdddddd    d
gZ    d d„Z
dd d„Z Gd d„dƒZ dd„Z dS)ze
Nose test running.
 
This module implements ``test()`` and ``bench()`` functions for NumPy modules.
 
éNé)Ú import_noseÚsuppress_warningsÚget_package_nameÚrun_module_suiteÚ
NoseTesterÚ _numpy_testerrrcCs„|dd…}g}d|ks d|krFtj |¡\}}|dkr:qF| |¡q|sZd|krVdSdS| ¡|d d¡rz| d¡d     |¡S)
a&
    Given a path where a package is installed, determine its name.
 
    Parameters
    ----------
    filepath : str
        Path to a file. If the determination fails, "numpy" is returned.
 
    Examples
    --------
    >>> np.testing.nosetester.get_package_name('nonsense')
    'numpy'
 
    Nú site-packagesú dist-packages)r    r
ÚscipyÚnumpyrz.eggÚ.)ÚosÚpathÚsplitÚappendÚreverseÚendswithÚpopÚjoin)ÚfilepathÚfullpathÚpkg_nameÚp2©rúXd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\numpy/testing/_private/nosetester.pyrs  
cCst|dkr,t d¡}|j dd¡}|dkr,t‚|dkrBtj|g}n
||g}tƒ}ddlm}|j    ||ƒgddS)aæ
    Run a test module.
 
    Equivalent to calling ``$ nosetests <argv> <file_to_run>`` from
    the command line
 
    Parameters
    ----------
    file_to_run : str, optional
        Path to test module, or None.
        By default, run the module from which this function is called.
    argv : list of strings
        Arguments to be passed to the nose test runner. ``argv[0]`` is
        ignored. All command line arguments accepted by ``nosetests``
        will work. If it is the default value None, sys.argv is used.
 
        .. versionadded:: 1.9.0
 
    Examples
    --------
    Adding the following::
 
        if __name__ == "__main__" :
            run_module_suite(argv=sys.argv)
 
    at the end of a test module will run the tests when that module is
    called in the python interpreter.
 
    Alternatively, calling::
 
    >>> run_module_suite(file_to_run="numpy/tests/test_matlib.py")  # doctest: +SKIP
 
    from an interpreter will run all the test routine in 'test_matlib.py'.
    NrÚ__file__)ÚKnownFailurePlugin©ÚargvZ
addplugins)
ÚsysÚ    _getframeÚf_localsÚgetÚAssertionErrorrrÚ noseclassesrÚrun)Z file_to_runrÚfÚnoserrrrr=s#
 
 c@sPeZdZdZddd„Zdd    „Zd
d „Zd d „Zddd„Zddd„Z    ddd„Z
dS)raï
    Nose test runner.
 
    This class is made available as numpy.testing.Tester, and a test function
    is typically added to a package's __init__.py like so::
 
      from numpy.testing import Tester
      test = Tester().test
 
    Calling this test function finds and runs all tests associated with the
    package and all its sub-packages.
 
    Attributes
    ----------
    package_path : str
        Full path to the package to test.
    package_name : str
        Name of the package to test.
 
    Parameters
    ----------
    package : module, str or None, optional
        The package to test. If a string, this should be the full path to
        the package. If None (default), `package` is set to the module from
        which `NoseTester` is initialized.
    raise_warnings : None, str or sequence of warnings, optional
        This specifies which warnings to configure as 'raise' instead
        of being shown once during the test execution.  Valid strings are:
 
          - "develop" : equals ``(Warning,)``
          - "release" : equals ``()``, don't raise on any warnings.
 
        Default is "release".
    depth : int, optional
        If `package` is None, then this can be used to initialize from the
        module of the caller of (the caller of (...)) the code that
        initializes `NoseTester`. Default of 0 means the module of the
        immediate caller; higher values are useful for utility routines that
        want to initialize `NoseTester` objects on behalf of other code.
 
    NÚreleaserFcCsº|dkr d}d}|dkr\t d|¡}|j dd¡}|dkr@t‚tj |¡}|j dd¡}n2t|t    tƒƒr†tj |j
¡}t |ddƒ}nt |ƒ}||_ |dkr¤t|ƒ}||_||_||_dS)Nr)rrÚ__name__)r r!r"r#r$rrÚdirnameÚ
isinstanceÚtyperÚgetattrÚstrÚ package_pathrÚ package_nameÚraise_warningsÚcheck_fpu_mode)ÚselfÚpackager2Údepthr3r1r'r0rrrÚ__init__šs(
 zNoseTester.__init__cCslt|jdg}|rB|dkrBt|tƒs*tdƒ‚|dkr6d}|d|g7}|dt|ƒg7}|dg7}|rh||7}|S)    a Generate argv for nosetest command
 
        Parameters
        ----------
        label : {'fast', 'full', '', attribute identifier}, optional
            see ``test`` docstring
        verbose : int, optional
            Verbosity value for test outputs, in the range 1-10. Default is 1.
        extra_argv : list, optional
            List with any extra arguments to pass to nosetests.
 
        Returns
        -------
        argv : list
            command line arguments that will be passed to nose
        z-sÚfullz"Selection label should be a stringÚfastznot slowz-Az --verbosityz--exe)rr0r,r/Ú    TypeError)r4ÚlabelÚverboseÚ
extra_argvrrrrÚ
_test_argvÃs  
 
zNoseTester._test_argvcCsÂtƒ}ddl}td|j›ƒ|jdddjj}td|ƒtj     |j
¡}td|›ƒd|j kr”ddl }td    |j›ƒtj     |j
¡}td
|›ƒt j d d ¡}td |›ƒtd|jƒdS)NrzNumPy version )é
rÚC)Úorderz&NumPy relaxed strides checking option:zNumPy is installed in r zSciPy version zSciPy is installed in Ú
ÚzPython version znose version %d.%d.%d)rr ÚprintÚ __version__ZonesÚflagsÚ f_contiguousrrr+rr1r r ÚversionÚreplaceZ__versioninfo__)r4r(r Zrelaxed_stridesZnpdirr ZspdirZ    pyversionrrrÚ_show_system_infoès
 
zNoseTester._show_system_infocCsddlm}|ƒS)z» Return instantiated plugin for doctests
 
        Allows subclassing of this class to override doctester
 
        A return value of None means use the nose builtin doctest plugin
        r)Ú NumpyDoctest)r%rK)r4rKrrrÚ_get_custom_doctesterüs z NoseTester._get_custom_doctesterr9rcCsŠtƒ| |||¡}|r0|d|j›dddg7}|rd|dkrH|dg7}nt|tƒrd|ddt|ƒg7}dd    l}dd
lm}    d d l    m
}
m } m } |
ƒg} | d d„|j jj Dƒ7} |jrÈ| | ƒg7} |dg7}z&|    ƒ}| ¡| dd„|j Dƒ7} Wntk
rYnXd|k}|dkr"|r"d}| ¡}|d    krL|r‚|s‚|dg7}n6|r\| d¡| | dƒ|g7} |r‚|d|jg7}|| fS)zç
        Run tests for module using nose.
 
        This method does the heavy lifting for the `test` method. It takes all
        the same arguments, for details see `test`.
 
        See Also
        --------
        test
 
        z--cover-package=z--with-coveragez --cover-testsz --cover-eraseTz --with-timerz --timer-top-nrN)ÚEntryPointPluginManagerr)rÚ    UnpluggerÚFPUModeCheckPlugincSsg|]
}|ƒ‘qSrr©Ú.0ÚprrrÚ
<listcomp>(sz0NoseTester.prepare_test_args.<locals>.<listcomp>z--with-fpumodecheckplugincSsg|]}|‘qSrrrPrrrrS0sz--with-doctestFÚdoctestz--with-)rr>r1r,Úintr/Znose.plugins.builtinZ nose.pluginsrMr%rrNrOÚpluginsÚbuiltinr3Z loadPluginsÚ ImportErrorrLÚremoveÚname)r4r;r<r=ÚdoctestsÚcoverageÚtimerrr(rMrrNrOrVZentrypoint_managerZ doctest_argvZplugrrrÚprepare_test_argssNÿ 
 
 
 
zNoseTester.prepare_test_argsc
Cst|dƒ}ddlm}||_| ||||||¡\}    }
|rJtd|j›ƒntd|j›ƒ| ¡ddl} d| _    |dkr~|j
}t t fdd    } t |tƒrž| |}td
ƒÞ} t ¡t d ¡|D]}tjd |d q¾| jdd| jdd| jdd| jtjd | jdd| jddt ¡t d ¡ddlm}W5QRX| jt|dtjddtddddlm}||    d|
d}W5QRX|jS)aè    
        Run tests for module using nose.
 
        Parameters
        ----------
        label : {'fast', 'full', '', attribute identifier}, optional
            Identifies the tests to run. This can be a string to pass to
            the nosetests executable with the '-A' option, or one of several
            special values.  Special values are:
 
            * 'fast' - the default - which corresponds to the ``nosetests -A``
              option of 'not slow'.
            * 'full' - fast (as above) and slow tests as in the
              'no -A' option to nosetests - this is the same as ''.
            * None or '' - run all tests.
            * attribute_identifier - string passed directly to nosetests as '-A'.
 
        verbose : int, optional
            Verbosity value for test outputs, in the range 1-10. Default is 1.
        extra_argv : list, optional
            List with any extra arguments to pass to nosetests.
        doctests : bool, optional
            If True, run doctests in module. Default is False.
        coverage : bool, optional
            If True, report coverage of NumPy code. Default is False.
            (This requires the
            `coverage module <https://pypi.org/project/coverage/>`_).
        raise_warnings : None, str or sequence of warnings, optional
            This specifies which warnings to configure as 'raise' instead
            of being shown once during the test execution. Valid strings are:
 
            * "develop" : equals ``(Warning,)``
            * "release" : equals ``()``, do not raise on any warnings.
        timer : bool or int, optional
            Timing of individual tests with ``nose-timer`` (which needs to be
            installed).  If True, time tests and report on all of them.
            If an integer (say ``N``), report timing results for ``N`` slowest
            tests.
 
        Returns
        -------
        result : object
            Returns the result of running the tests as a
            ``nose.result.TextTestResult`` object.
 
        Notes
        -----
        Each NumPy module exposes `test` in its namespace to run all tests for it.
        For example, to run all tests for numpy.lib:
 
        >>> np.lib.test() #doctest: +SKIP
 
        Examples
        --------
        >>> result = np.lib.test() #doctest: +SKIP
        Running unit tests for numpy.lib
        ...
        Ran 976 tests in 3.933s
 
        OK
 
        >>> result.errors #doctest: +SKIP
        []
        >>> result.knownfail #doctest: +SKIP
        []
        ér)Úutilsz$Running unit tests and doctests for zRunning unit tests for rNr)Údevelopr)ÚlocationÚalwaysÚerror)ÚcategoryzNot importing directory)Úmessageznumpy.dtype size changedznumpy.ufunc size changedz.*boolean negative.*z.*boolean subtract.*)Úcpuinfo)reÚmoduleÚignorez.*getargspec.*znose\.)rfrerh)ÚNumpyTestProgramF)rÚexitrV)ÚminrCr`r<r^rDr1rJrTZmasterr2ÚdictÚWarningr,r/rÚwarningsÚ resetwarningsÚfilterwarningsÚfilterÚnpZModuleDeprecationWarningÚcatch_warningsÚ simplefilterÚ    distutilsrgÚ UserWarningÚDeprecationWarningr%rjÚresult)r4r;r<r=r[r\r2r]r`rrVrTZ
_warn_optsÚsupZ warningtypergrjÚtrrrÚtestFs\G
 ÿÿ
 
 
 
 
þ zNoseTester.testcCsbtd|j›ƒ| ¡| |||¡}|ddtjg7}tƒ}ddlm}|dƒg}|j    ||dS)aì
        Run benchmarks for module using nose.
 
        Parameters
        ----------
        label : {'fast', 'full', '', attribute identifier}, optional
            Identifies the benchmarks to run. This can be a string to pass to
            the nosetests executable with the '-A' option, or one of several
            special values.  Special values are:
 
            * 'fast' - the default - which corresponds to the ``nosetests -A``
              option of 'not slow'.
            * 'full' - fast (as above) and slow benchmarks as in the
              'no -A' option to nosetests - this is the same as ''.
            * None or '' - run all tests.
            * attribute_identifier - string passed directly to nosetests as '-A'.
 
        verbose : int, optional
            Verbosity value for benchmark outputs, in the range 1-10. Default is 1.
        extra_argv : list, optional
            List with any extra arguments to pass to nosetests.
 
        Returns
        -------
        success : bool
            Returns True if running the benchmarks works, False if an error
            occurred.
 
        Notes
        -----
        Benchmarks are like tests, but have names starting with "bench" instead
        of "test", and can be found under the "benchmarks" sub-directory of the
        module.
 
        Each NumPy module exposes `bench` in its namespace to run all benchmarks
        for it.
 
        Examples
        --------
        >>> success = np.lib.bench() #doctest: +SKIP
        Running benchmarks for numpy.lib
        ...
        using 562341 items:
        unique:
        0.11
        unique1d:
        0.11
        ratio: 1.0
        nUnique: 56230 == 56230
        ...
        OK
 
        >>> success #doctest: +SKIP
        True
 
        zRunning benchmarks for z--matchz(?:^|[\\b_\\.%s-])[Bb]enchr)rNrTr)
rDr1rJr>rÚseprr%rNr&)r4r;r<r=rr(rNZ add_pluginsrrrÚbenchÑs: 
zNoseTester.bench)Nr)rF)r9rNFFF)r9rNFFNF)r9rN) r*Ú
__module__Ú __qualname__Ú__doc__r7r>rJrLr^r|r~rrrrrps()ÿ
)%
ÿ
@þ
 cCs,ttdƒrdtjkrd}nd}t|dddS)NrEz.dev0rar)rT)r2r6r3)ÚhasattrrsrEr)Úmoderrrrs ÿ)NN)rrr ror rsr`rrÚ__all__rrrrrrrrÚ<module>s$þ)
3.