Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- venv/lib/python3.10/site-packages/numpy/compat/__init__.py +19 -0
- venv/lib/python3.10/site-packages/numpy/compat/__pycache__/__init__.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/numpy/compat/__pycache__/py3k.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/numpy/compat/__pycache__/setup.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/numpy/compat/py3k.py +145 -0
- venv/lib/python3.10/site-packages/numpy/compat/setup.py +10 -0
- venv/lib/python3.10/site-packages/numpy/compat/tests/__init__.py +0 -0
- venv/lib/python3.10/site-packages/numpy/compat/tests/__pycache__/__init__.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/numpy/compat/tests/__pycache__/test_compat.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/numpy/compat/tests/test_compat.py +22 -0
- venv/lib/python3.10/site-packages/numpy/distutils/__init__.py +64 -0
- venv/lib/python3.10/site-packages/numpy/distutils/ccompiler_opt.py +0 -0
- venv/lib/python3.10/site-packages/numpy/distutils/from_template.py +261 -0
- venv/lib/python3.10/site-packages/numpy/distutils/fujitsuccompiler.py +28 -0
- venv/lib/python3.10/site-packages/numpy/distutils/intelccompiler.py +111 -0
- venv/lib/python3.10/site-packages/numpy/distutils/lib2def.py +116 -0
- venv/lib/python3.10/site-packages/numpy/distutils/line_endings.py +77 -0
- venv/lib/python3.10/site-packages/numpy/distutils/npy_pkg_config.py +437 -0
- venv/lib/python3.10/site-packages/numpy/distutils/pathccompiler.py +21 -0
- venv/lib/python3.10/site-packages/numpy/doc/__init__.py +26 -0
- venv/lib/python3.10/site-packages/numpy/doc/__pycache__/__init__.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/numpy/doc/__pycache__/constants.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/numpy/doc/__pycache__/ufuncs.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/numpy/doc/constants.py +412 -0
- venv/lib/python3.10/site-packages/numpy/doc/ufuncs.py +137 -0
- venv/lib/python3.10/site-packages/numpy/f2py/__pycache__/__init__.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/numpy/f2py/__pycache__/__main__.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/numpy/f2py/__pycache__/__version__.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/numpy/f2py/__pycache__/_isocbind.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/numpy/f2py/__pycache__/_src_pyf.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/numpy/f2py/__pycache__/auxfuncs.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/numpy/f2py/__pycache__/capi_maps.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/numpy/f2py/__pycache__/cb_rules.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/numpy/f2py/__pycache__/cfuncs.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/numpy/f2py/__pycache__/common_rules.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/numpy/f2py/__pycache__/crackfortran.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/numpy/f2py/__pycache__/diagnose.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/numpy/f2py/__pycache__/f2py2e.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/numpy/f2py/__pycache__/f90mod_rules.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/numpy/f2py/__pycache__/func2subr.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/numpy/f2py/__pycache__/rules.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/numpy/f2py/__pycache__/setup.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/numpy/f2py/__pycache__/symbolic.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/numpy/f2py/__pycache__/use_rules.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/numpy/f2py/tests/__pycache__/__init__.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/numpy/f2py/tests/__pycache__/test_abstract_interface.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/numpy/f2py/tests/__pycache__/test_array_from_pyobj.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/numpy/f2py/tests/__pycache__/test_assumed_shape.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/numpy/f2py/tests/__pycache__/test_block_docstring.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/numpy/f2py/tests/__pycache__/test_callback.cpython-310.pyc +0 -0
venv/lib/python3.10/site-packages/numpy/compat/__init__.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
Compatibility module.
|
3 |
+
|
4 |
+
This module contains duplicated code from Python itself or 3rd party
|
5 |
+
extensions, which may be included for the following reasons:
|
6 |
+
|
7 |
+
* compatibility
|
8 |
+
* we may only need a small subset of the copied library/module
|
9 |
+
|
10 |
+
"""
|
11 |
+
|
12 |
+
from .._utils import _inspect
|
13 |
+
from .._utils._inspect import getargspec, formatargspec
|
14 |
+
from . import py3k
|
15 |
+
from .py3k import *
|
16 |
+
|
17 |
+
__all__ = []
|
18 |
+
__all__.extend(_inspect.__all__)
|
19 |
+
__all__.extend(py3k.__all__)
|
venv/lib/python3.10/site-packages/numpy/compat/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (649 Bytes). View file
|
|
venv/lib/python3.10/site-packages/numpy/compat/__pycache__/py3k.cpython-310.pyc
ADDED
Binary file (4.74 kB). View file
|
|
venv/lib/python3.10/site-packages/numpy/compat/__pycache__/setup.cpython-310.pyc
ADDED
Binary file (560 Bytes). View file
|
|
venv/lib/python3.10/site-packages/numpy/compat/py3k.py
ADDED
@@ -0,0 +1,145 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
Python 3.X compatibility tools.
|
3 |
+
|
4 |
+
While this file was originally intended for Python 2 -> 3 transition,
|
5 |
+
it is now used to create a compatibility layer between different
|
6 |
+
minor versions of Python 3.
|
7 |
+
|
8 |
+
While the active version of numpy may not support a given version of python, we
|
9 |
+
allow downstream libraries to continue to use these shims for forward
|
10 |
+
compatibility with numpy while they transition their code to newer versions of
|
11 |
+
Python.
|
12 |
+
"""
|
13 |
+
__all__ = ['bytes', 'asbytes', 'isfileobj', 'getexception', 'strchar',
|
14 |
+
'unicode', 'asunicode', 'asbytes_nested', 'asunicode_nested',
|
15 |
+
'asstr', 'open_latin1', 'long', 'basestring', 'sixu',
|
16 |
+
'integer_types', 'is_pathlib_path', 'npy_load_module', 'Path',
|
17 |
+
'pickle', 'contextlib_nullcontext', 'os_fspath', 'os_PathLike']
|
18 |
+
|
19 |
+
import sys
|
20 |
+
import os
|
21 |
+
from pathlib import Path
|
22 |
+
import io
|
23 |
+
try:
|
24 |
+
import pickle5 as pickle
|
25 |
+
except ImportError:
|
26 |
+
import pickle
|
27 |
+
|
28 |
+
long = int
|
29 |
+
integer_types = (int,)
|
30 |
+
basestring = str
|
31 |
+
unicode = str
|
32 |
+
bytes = bytes
|
33 |
+
|
34 |
+
def asunicode(s):
|
35 |
+
if isinstance(s, bytes):
|
36 |
+
return s.decode('latin1')
|
37 |
+
return str(s)
|
38 |
+
|
39 |
+
def asbytes(s):
|
40 |
+
if isinstance(s, bytes):
|
41 |
+
return s
|
42 |
+
return str(s).encode('latin1')
|
43 |
+
|
44 |
+
def asstr(s):
|
45 |
+
if isinstance(s, bytes):
|
46 |
+
return s.decode('latin1')
|
47 |
+
return str(s)
|
48 |
+
|
49 |
+
def isfileobj(f):
|
50 |
+
if not isinstance(f, (io.FileIO, io.BufferedReader, io.BufferedWriter)):
|
51 |
+
return False
|
52 |
+
try:
|
53 |
+
# BufferedReader/Writer may raise OSError when
|
54 |
+
# fetching `fileno()` (e.g. when wrapping BytesIO).
|
55 |
+
f.fileno()
|
56 |
+
return True
|
57 |
+
except OSError:
|
58 |
+
return False
|
59 |
+
|
60 |
+
def open_latin1(filename, mode='r'):
|
61 |
+
return open(filename, mode=mode, encoding='iso-8859-1')
|
62 |
+
|
63 |
+
def sixu(s):
|
64 |
+
return s
|
65 |
+
|
66 |
+
strchar = 'U'
|
67 |
+
|
68 |
+
def getexception():
|
69 |
+
return sys.exc_info()[1]
|
70 |
+
|
71 |
+
def asbytes_nested(x):
|
72 |
+
if hasattr(x, '__iter__') and not isinstance(x, (bytes, unicode)):
|
73 |
+
return [asbytes_nested(y) for y in x]
|
74 |
+
else:
|
75 |
+
return asbytes(x)
|
76 |
+
|
77 |
+
def asunicode_nested(x):
|
78 |
+
if hasattr(x, '__iter__') and not isinstance(x, (bytes, unicode)):
|
79 |
+
return [asunicode_nested(y) for y in x]
|
80 |
+
else:
|
81 |
+
return asunicode(x)
|
82 |
+
|
83 |
+
def is_pathlib_path(obj):
|
84 |
+
"""
|
85 |
+
Check whether obj is a `pathlib.Path` object.
|
86 |
+
|
87 |
+
Prefer using ``isinstance(obj, os.PathLike)`` instead of this function.
|
88 |
+
"""
|
89 |
+
return isinstance(obj, Path)
|
90 |
+
|
91 |
+
# from Python 3.7
|
92 |
+
class contextlib_nullcontext:
|
93 |
+
"""Context manager that does no additional processing.
|
94 |
+
|
95 |
+
Used as a stand-in for a normal context manager, when a particular
|
96 |
+
block of code is only sometimes used with a normal context manager:
|
97 |
+
|
98 |
+
cm = optional_cm if condition else nullcontext()
|
99 |
+
with cm:
|
100 |
+
# Perform operation, using optional_cm if condition is True
|
101 |
+
|
102 |
+
.. note::
|
103 |
+
Prefer using `contextlib.nullcontext` instead of this context manager.
|
104 |
+
"""
|
105 |
+
|
106 |
+
def __init__(self, enter_result=None):
|
107 |
+
self.enter_result = enter_result
|
108 |
+
|
109 |
+
def __enter__(self):
|
110 |
+
return self.enter_result
|
111 |
+
|
112 |
+
def __exit__(self, *excinfo):
|
113 |
+
pass
|
114 |
+
|
115 |
+
|
116 |
+
def npy_load_module(name, fn, info=None):
|
117 |
+
"""
|
118 |
+
Load a module. Uses ``load_module`` which will be deprecated in python
|
119 |
+
3.12. An alternative that uses ``exec_module`` is in
|
120 |
+
numpy.distutils.misc_util.exec_mod_from_location
|
121 |
+
|
122 |
+
.. versionadded:: 1.11.2
|
123 |
+
|
124 |
+
Parameters
|
125 |
+
----------
|
126 |
+
name : str
|
127 |
+
Full module name.
|
128 |
+
fn : str
|
129 |
+
Path to module file.
|
130 |
+
info : tuple, optional
|
131 |
+
Only here for backward compatibility with Python 2.*.
|
132 |
+
|
133 |
+
Returns
|
134 |
+
-------
|
135 |
+
mod : module
|
136 |
+
|
137 |
+
"""
|
138 |
+
# Explicitly lazy import this to avoid paying the cost
|
139 |
+
# of importing importlib at startup
|
140 |
+
from importlib.machinery import SourceFileLoader
|
141 |
+
return SourceFileLoader(name, fn).load_module()
|
142 |
+
|
143 |
+
|
144 |
+
os_fspath = os.fspath
|
145 |
+
os_PathLike = os.PathLike
|
venv/lib/python3.10/site-packages/numpy/compat/setup.py
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
def configuration(parent_package='',top_path=None):
|
2 |
+
from numpy.distutils.misc_util import Configuration
|
3 |
+
|
4 |
+
config = Configuration('compat', parent_package, top_path)
|
5 |
+
config.add_subpackage('tests')
|
6 |
+
return config
|
7 |
+
|
8 |
+
if __name__ == '__main__':
|
9 |
+
from numpy.distutils.core import setup
|
10 |
+
setup(configuration=configuration)
|
venv/lib/python3.10/site-packages/numpy/compat/tests/__init__.py
ADDED
File without changes
|
venv/lib/python3.10/site-packages/numpy/compat/tests/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (186 Bytes). View file
|
|
venv/lib/python3.10/site-packages/numpy/compat/tests/__pycache__/test_compat.cpython-310.pyc
ADDED
Binary file (877 Bytes). View file
|
|
venv/lib/python3.10/site-packages/numpy/compat/tests/test_compat.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from os.path import join
|
2 |
+
from io import BufferedReader, BytesIO
|
3 |
+
|
4 |
+
from numpy.compat import isfileobj
|
5 |
+
from numpy.testing import assert_
|
6 |
+
from numpy.testing import tempdir
|
7 |
+
|
8 |
+
|
9 |
+
def test_isfileobj():
|
10 |
+
with tempdir(prefix="numpy_test_compat_") as folder:
|
11 |
+
filename = join(folder, 'a.bin')
|
12 |
+
|
13 |
+
with open(filename, 'wb') as f:
|
14 |
+
assert_(isfileobj(f))
|
15 |
+
|
16 |
+
with open(filename, 'ab') as f:
|
17 |
+
assert_(isfileobj(f))
|
18 |
+
|
19 |
+
with open(filename, 'rb') as f:
|
20 |
+
assert_(isfileobj(f))
|
21 |
+
|
22 |
+
assert_(isfileobj(BufferedReader(BytesIO())) is False)
|
venv/lib/python3.10/site-packages/numpy/distutils/__init__.py
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
An enhanced distutils, providing support for Fortran compilers, for BLAS,
|
3 |
+
LAPACK and other common libraries for numerical computing, and more.
|
4 |
+
|
5 |
+
Public submodules are::
|
6 |
+
|
7 |
+
misc_util
|
8 |
+
system_info
|
9 |
+
cpu_info
|
10 |
+
log
|
11 |
+
exec_command
|
12 |
+
|
13 |
+
For details, please see the *Packaging* and *NumPy Distutils User Guide*
|
14 |
+
sections of the NumPy Reference Guide.
|
15 |
+
|
16 |
+
For configuring the preference for and location of libraries like BLAS and
|
17 |
+
LAPACK, and for setting include paths and similar build options, please see
|
18 |
+
``site.cfg.example`` in the root of the NumPy repository or sdist.
|
19 |
+
|
20 |
+
"""
|
21 |
+
|
22 |
+
import warnings
|
23 |
+
|
24 |
+
# Must import local ccompiler ASAP in order to get
|
25 |
+
# customized CCompiler.spawn effective.
|
26 |
+
from . import ccompiler
|
27 |
+
from . import unixccompiler
|
28 |
+
|
29 |
+
from .npy_pkg_config import *
|
30 |
+
|
31 |
+
warnings.warn("\n\n"
|
32 |
+
" `numpy.distutils` is deprecated since NumPy 1.23.0, as a result\n"
|
33 |
+
" of the deprecation of `distutils` itself. It will be removed for\n"
|
34 |
+
" Python >= 3.12. For older Python versions it will remain present.\n"
|
35 |
+
" It is recommended to use `setuptools < 60.0` for those Python versions.\n"
|
36 |
+
" For more details, see:\n"
|
37 |
+
" https://numpy.org/devdocs/reference/distutils_status_migration.html \n\n",
|
38 |
+
DeprecationWarning, stacklevel=2
|
39 |
+
)
|
40 |
+
del warnings
|
41 |
+
|
42 |
+
# If numpy is installed, add distutils.test()
|
43 |
+
try:
|
44 |
+
from . import __config__
|
45 |
+
# Normally numpy is installed if the above import works, but an interrupted
|
46 |
+
# in-place build could also have left a __config__.py. In that case the
|
47 |
+
# next import may still fail, so keep it inside the try block.
|
48 |
+
from numpy._pytesttester import PytestTester
|
49 |
+
test = PytestTester(__name__)
|
50 |
+
del PytestTester
|
51 |
+
except ImportError:
|
52 |
+
pass
|
53 |
+
|
54 |
+
|
55 |
+
def customized_fcompiler(plat=None, compiler=None):
|
56 |
+
from numpy.distutils.fcompiler import new_fcompiler
|
57 |
+
c = new_fcompiler(plat=plat, compiler=compiler)
|
58 |
+
c.customize()
|
59 |
+
return c
|
60 |
+
|
61 |
+
def customized_ccompiler(plat=None, compiler=None, verbose=1):
|
62 |
+
c = ccompiler.new_compiler(plat=plat, compiler=compiler, verbose=verbose)
|
63 |
+
c.customize('')
|
64 |
+
return c
|
venv/lib/python3.10/site-packages/numpy/distutils/ccompiler_opt.py
ADDED
The diff for this file is too large to render.
See raw diff
|
|
venv/lib/python3.10/site-packages/numpy/distutils/from_template.py
ADDED
@@ -0,0 +1,261 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env python3
|
2 |
+
"""
|
3 |
+
|
4 |
+
process_file(filename)
|
5 |
+
|
6 |
+
takes templated file .xxx.src and produces .xxx file where .xxx
|
7 |
+
is .pyf .f90 or .f using the following template rules:
|
8 |
+
|
9 |
+
'<..>' denotes a template.
|
10 |
+
|
11 |
+
All function and subroutine blocks in a source file with names that
|
12 |
+
contain '<..>' will be replicated according to the rules in '<..>'.
|
13 |
+
|
14 |
+
The number of comma-separated words in '<..>' will determine the number of
|
15 |
+
replicates.
|
16 |
+
|
17 |
+
'<..>' may have two different forms, named and short. For example,
|
18 |
+
|
19 |
+
named:
|
20 |
+
<p=d,s,z,c> where anywhere inside a block '<p>' will be replaced with
|
21 |
+
'd', 's', 'z', and 'c' for each replicate of the block.
|
22 |
+
|
23 |
+
<_c> is already defined: <_c=s,d,c,z>
|
24 |
+
<_t> is already defined: <_t=real,double precision,complex,double complex>
|
25 |
+
|
26 |
+
short:
|
27 |
+
<s,d,c,z>, a short form of the named, useful when no <p> appears inside
|
28 |
+
a block.
|
29 |
+
|
30 |
+
In general, '<..>' contains a comma separated list of arbitrary
|
31 |
+
expressions. If these expression must contain a comma|leftarrow|rightarrow,
|
32 |
+
then prepend the comma|leftarrow|rightarrow with a backslash.
|
33 |
+
|
34 |
+
If an expression matches '\\<index>' then it will be replaced
|
35 |
+
by <index>-th expression.
|
36 |
+
|
37 |
+
Note that all '<..>' forms in a block must have the same number of
|
38 |
+
comma-separated entries.
|
39 |
+
|
40 |
+
Predefined named template rules:
|
41 |
+
<prefix=s,d,c,z>
|
42 |
+
<ftype=real,double precision,complex,double complex>
|
43 |
+
<ftypereal=real,double precision,\\0,\\1>
|
44 |
+
<ctype=float,double,complex_float,complex_double>
|
45 |
+
<ctypereal=float,double,\\0,\\1>
|
46 |
+
|
47 |
+
"""
|
48 |
+
__all__ = ['process_str', 'process_file']
|
49 |
+
|
50 |
+
import os
|
51 |
+
import sys
|
52 |
+
import re
|
53 |
+
|
54 |
+
routine_start_re = re.compile(r'(\n|\A)(( (\$|\*))|)\s*(subroutine|function)\b', re.I)
|
55 |
+
routine_end_re = re.compile(r'\n\s*end\s*(subroutine|function)\b.*(\n|\Z)', re.I)
|
56 |
+
function_start_re = re.compile(r'\n (\$|\*)\s*function\b', re.I)
|
57 |
+
|
58 |
+
def parse_structure(astr):
|
59 |
+
""" Return a list of tuples for each function or subroutine each
|
60 |
+
tuple is the start and end of a subroutine or function to be
|
61 |
+
expanded.
|
62 |
+
"""
|
63 |
+
|
64 |
+
spanlist = []
|
65 |
+
ind = 0
|
66 |
+
while True:
|
67 |
+
m = routine_start_re.search(astr, ind)
|
68 |
+
if m is None:
|
69 |
+
break
|
70 |
+
start = m.start()
|
71 |
+
if function_start_re.match(astr, start, m.end()):
|
72 |
+
while True:
|
73 |
+
i = astr.rfind('\n', ind, start)
|
74 |
+
if i==-1:
|
75 |
+
break
|
76 |
+
start = i
|
77 |
+
if astr[i:i+7]!='\n $':
|
78 |
+
break
|
79 |
+
start += 1
|
80 |
+
m = routine_end_re.search(astr, m.end())
|
81 |
+
ind = end = m and m.end()-1 or len(astr)
|
82 |
+
spanlist.append((start, end))
|
83 |
+
return spanlist
|
84 |
+
|
85 |
+
template_re = re.compile(r"<\s*(\w[\w\d]*)\s*>")
|
86 |
+
named_re = re.compile(r"<\s*(\w[\w\d]*)\s*=\s*(.*?)\s*>")
|
87 |
+
list_re = re.compile(r"<\s*((.*?))\s*>")
|
88 |
+
|
89 |
+
def find_repl_patterns(astr):
|
90 |
+
reps = named_re.findall(astr)
|
91 |
+
names = {}
|
92 |
+
for rep in reps:
|
93 |
+
name = rep[0].strip() or unique_key(names)
|
94 |
+
repl = rep[1].replace(r'\,', '@comma@')
|
95 |
+
thelist = conv(repl)
|
96 |
+
names[name] = thelist
|
97 |
+
return names
|
98 |
+
|
99 |
+
def find_and_remove_repl_patterns(astr):
|
100 |
+
names = find_repl_patterns(astr)
|
101 |
+
astr = re.subn(named_re, '', astr)[0]
|
102 |
+
return astr, names
|
103 |
+
|
104 |
+
item_re = re.compile(r"\A\\(?P<index>\d+)\Z")
|
105 |
+
def conv(astr):
|
106 |
+
b = astr.split(',')
|
107 |
+
l = [x.strip() for x in b]
|
108 |
+
for i in range(len(l)):
|
109 |
+
m = item_re.match(l[i])
|
110 |
+
if m:
|
111 |
+
j = int(m.group('index'))
|
112 |
+
l[i] = l[j]
|
113 |
+
return ','.join(l)
|
114 |
+
|
115 |
+
def unique_key(adict):
|
116 |
+
""" Obtain a unique key given a dictionary."""
|
117 |
+
allkeys = list(adict.keys())
|
118 |
+
done = False
|
119 |
+
n = 1
|
120 |
+
while not done:
|
121 |
+
newkey = '__l%s' % (n)
|
122 |
+
if newkey in allkeys:
|
123 |
+
n += 1
|
124 |
+
else:
|
125 |
+
done = True
|
126 |
+
return newkey
|
127 |
+
|
128 |
+
|
129 |
+
template_name_re = re.compile(r'\A\s*(\w[\w\d]*)\s*\Z')
|
130 |
+
def expand_sub(substr, names):
|
131 |
+
substr = substr.replace(r'\>', '@rightarrow@')
|
132 |
+
substr = substr.replace(r'\<', '@leftarrow@')
|
133 |
+
lnames = find_repl_patterns(substr)
|
134 |
+
substr = named_re.sub(r"<\1>", substr) # get rid of definition templates
|
135 |
+
|
136 |
+
def listrepl(mobj):
|
137 |
+
thelist = conv(mobj.group(1).replace(r'\,', '@comma@'))
|
138 |
+
if template_name_re.match(thelist):
|
139 |
+
return "<%s>" % (thelist)
|
140 |
+
name = None
|
141 |
+
for key in lnames.keys(): # see if list is already in dictionary
|
142 |
+
if lnames[key] == thelist:
|
143 |
+
name = key
|
144 |
+
if name is None: # this list is not in the dictionary yet
|
145 |
+
name = unique_key(lnames)
|
146 |
+
lnames[name] = thelist
|
147 |
+
return "<%s>" % name
|
148 |
+
|
149 |
+
substr = list_re.sub(listrepl, substr) # convert all lists to named templates
|
150 |
+
# newnames are constructed as needed
|
151 |
+
|
152 |
+
numsubs = None
|
153 |
+
base_rule = None
|
154 |
+
rules = {}
|
155 |
+
for r in template_re.findall(substr):
|
156 |
+
if r not in rules:
|
157 |
+
thelist = lnames.get(r, names.get(r, None))
|
158 |
+
if thelist is None:
|
159 |
+
raise ValueError('No replicates found for <%s>' % (r))
|
160 |
+
if r not in names and not thelist.startswith('_'):
|
161 |
+
names[r] = thelist
|
162 |
+
rule = [i.replace('@comma@', ',') for i in thelist.split(',')]
|
163 |
+
num = len(rule)
|
164 |
+
|
165 |
+
if numsubs is None:
|
166 |
+
numsubs = num
|
167 |
+
rules[r] = rule
|
168 |
+
base_rule = r
|
169 |
+
elif num == numsubs:
|
170 |
+
rules[r] = rule
|
171 |
+
else:
|
172 |
+
print("Mismatch in number of replacements (base <%s=%s>)"
|
173 |
+
" for <%s=%s>. Ignoring." %
|
174 |
+
(base_rule, ','.join(rules[base_rule]), r, thelist))
|
175 |
+
if not rules:
|
176 |
+
return substr
|
177 |
+
|
178 |
+
def namerepl(mobj):
|
179 |
+
name = mobj.group(1)
|
180 |
+
return rules.get(name, (k+1)*[name])[k]
|
181 |
+
|
182 |
+
newstr = ''
|
183 |
+
for k in range(numsubs):
|
184 |
+
newstr += template_re.sub(namerepl, substr) + '\n\n'
|
185 |
+
|
186 |
+
newstr = newstr.replace('@rightarrow@', '>')
|
187 |
+
newstr = newstr.replace('@leftarrow@', '<')
|
188 |
+
return newstr
|
189 |
+
|
190 |
+
def process_str(allstr):
|
191 |
+
newstr = allstr
|
192 |
+
writestr = ''
|
193 |
+
|
194 |
+
struct = parse_structure(newstr)
|
195 |
+
|
196 |
+
oldend = 0
|
197 |
+
names = {}
|
198 |
+
names.update(_special_names)
|
199 |
+
for sub in struct:
|
200 |
+
cleanedstr, defs = find_and_remove_repl_patterns(newstr[oldend:sub[0]])
|
201 |
+
writestr += cleanedstr
|
202 |
+
names.update(defs)
|
203 |
+
writestr += expand_sub(newstr[sub[0]:sub[1]], names)
|
204 |
+
oldend = sub[1]
|
205 |
+
writestr += newstr[oldend:]
|
206 |
+
|
207 |
+
return writestr
|
208 |
+
|
209 |
+
include_src_re = re.compile(r"(\n|\A)\s*include\s*['\"](?P<name>[\w\d./\\]+\.src)['\"]", re.I)
|
210 |
+
|
211 |
+
def resolve_includes(source):
|
212 |
+
d = os.path.dirname(source)
|
213 |
+
with open(source) as fid:
|
214 |
+
lines = []
|
215 |
+
for line in fid:
|
216 |
+
m = include_src_re.match(line)
|
217 |
+
if m:
|
218 |
+
fn = m.group('name')
|
219 |
+
if not os.path.isabs(fn):
|
220 |
+
fn = os.path.join(d, fn)
|
221 |
+
if os.path.isfile(fn):
|
222 |
+
lines.extend(resolve_includes(fn))
|
223 |
+
else:
|
224 |
+
lines.append(line)
|
225 |
+
else:
|
226 |
+
lines.append(line)
|
227 |
+
return lines
|
228 |
+
|
229 |
+
def process_file(source):
|
230 |
+
lines = resolve_includes(source)
|
231 |
+
return process_str(''.join(lines))
|
232 |
+
|
233 |
+
_special_names = find_repl_patterns('''
|
234 |
+
<_c=s,d,c,z>
|
235 |
+
<_t=real,double precision,complex,double complex>
|
236 |
+
<prefix=s,d,c,z>
|
237 |
+
<ftype=real,double precision,complex,double complex>
|
238 |
+
<ctype=float,double,complex_float,complex_double>
|
239 |
+
<ftypereal=real,double precision,\\0,\\1>
|
240 |
+
<ctypereal=float,double,\\0,\\1>
|
241 |
+
''')
|
242 |
+
|
243 |
+
def main():
|
244 |
+
try:
|
245 |
+
file = sys.argv[1]
|
246 |
+
except IndexError:
|
247 |
+
fid = sys.stdin
|
248 |
+
outfile = sys.stdout
|
249 |
+
else:
|
250 |
+
fid = open(file, 'r')
|
251 |
+
(base, ext) = os.path.splitext(file)
|
252 |
+
newname = base
|
253 |
+
outfile = open(newname, 'w')
|
254 |
+
|
255 |
+
allstr = fid.read()
|
256 |
+
writestr = process_str(allstr)
|
257 |
+
outfile.write(writestr)
|
258 |
+
|
259 |
+
|
260 |
+
if __name__ == "__main__":
|
261 |
+
main()
|
venv/lib/python3.10/site-packages/numpy/distutils/fujitsuccompiler.py
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from distutils.unixccompiler import UnixCCompiler
|
2 |
+
|
3 |
+
class FujitsuCCompiler(UnixCCompiler):
|
4 |
+
|
5 |
+
"""
|
6 |
+
Fujitsu compiler.
|
7 |
+
"""
|
8 |
+
|
9 |
+
compiler_type = 'fujitsu'
|
10 |
+
cc_exe = 'fcc'
|
11 |
+
cxx_exe = 'FCC'
|
12 |
+
|
13 |
+
def __init__(self, verbose=0, dry_run=0, force=0):
|
14 |
+
UnixCCompiler.__init__(self, verbose, dry_run, force)
|
15 |
+
cc_compiler = self.cc_exe
|
16 |
+
cxx_compiler = self.cxx_exe
|
17 |
+
self.set_executables(
|
18 |
+
compiler=cc_compiler +
|
19 |
+
' -O3 -Nclang -fPIC',
|
20 |
+
compiler_so=cc_compiler +
|
21 |
+
' -O3 -Nclang -fPIC',
|
22 |
+
compiler_cxx=cxx_compiler +
|
23 |
+
' -O3 -Nclang -fPIC',
|
24 |
+
linker_exe=cc_compiler +
|
25 |
+
' -lfj90i -lfj90f -lfjsrcinfo -lelf -shared',
|
26 |
+
linker_so=cc_compiler +
|
27 |
+
' -lfj90i -lfj90f -lfjsrcinfo -lelf -shared'
|
28 |
+
)
|
venv/lib/python3.10/site-packages/numpy/distutils/intelccompiler.py
ADDED
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import platform
|
2 |
+
|
3 |
+
from distutils.unixccompiler import UnixCCompiler
|
4 |
+
from numpy.distutils.exec_command import find_executable
|
5 |
+
from numpy.distutils.ccompiler import simple_version_match
|
6 |
+
if platform.system() == 'Windows':
|
7 |
+
from numpy.distutils.msvc9compiler import MSVCCompiler
|
8 |
+
|
9 |
+
|
10 |
+
class IntelCCompiler(UnixCCompiler):
|
11 |
+
"""A modified Intel compiler compatible with a GCC-built Python."""
|
12 |
+
compiler_type = 'intel'
|
13 |
+
cc_exe = 'icc'
|
14 |
+
cc_args = 'fPIC'
|
15 |
+
|
16 |
+
def __init__(self, verbose=0, dry_run=0, force=0):
|
17 |
+
UnixCCompiler.__init__(self, verbose, dry_run, force)
|
18 |
+
|
19 |
+
v = self.get_version()
|
20 |
+
mpopt = 'openmp' if v and v < '15' else 'qopenmp'
|
21 |
+
self.cc_exe = ('icc -fPIC -fp-model strict -O3 '
|
22 |
+
'-fomit-frame-pointer -{}').format(mpopt)
|
23 |
+
compiler = self.cc_exe
|
24 |
+
|
25 |
+
if platform.system() == 'Darwin':
|
26 |
+
shared_flag = '-Wl,-undefined,dynamic_lookup'
|
27 |
+
else:
|
28 |
+
shared_flag = '-shared'
|
29 |
+
self.set_executables(compiler=compiler,
|
30 |
+
compiler_so=compiler,
|
31 |
+
compiler_cxx=compiler,
|
32 |
+
archiver='xiar' + ' cru',
|
33 |
+
linker_exe=compiler + ' -shared-intel',
|
34 |
+
linker_so=compiler + ' ' + shared_flag +
|
35 |
+
' -shared-intel')
|
36 |
+
|
37 |
+
|
38 |
+
class IntelItaniumCCompiler(IntelCCompiler):
|
39 |
+
compiler_type = 'intele'
|
40 |
+
|
41 |
+
# On Itanium, the Intel Compiler used to be called ecc, let's search for
|
42 |
+
# it (now it's also icc, so ecc is last in the search).
|
43 |
+
for cc_exe in map(find_executable, ['icc', 'ecc']):
|
44 |
+
if cc_exe:
|
45 |
+
break
|
46 |
+
|
47 |
+
|
48 |
+
class IntelEM64TCCompiler(UnixCCompiler):
|
49 |
+
"""
|
50 |
+
A modified Intel x86_64 compiler compatible with a 64bit GCC-built Python.
|
51 |
+
"""
|
52 |
+
compiler_type = 'intelem'
|
53 |
+
cc_exe = 'icc -m64'
|
54 |
+
cc_args = '-fPIC'
|
55 |
+
|
56 |
+
def __init__(self, verbose=0, dry_run=0, force=0):
|
57 |
+
UnixCCompiler.__init__(self, verbose, dry_run, force)
|
58 |
+
|
59 |
+
v = self.get_version()
|
60 |
+
mpopt = 'openmp' if v and v < '15' else 'qopenmp'
|
61 |
+
self.cc_exe = ('icc -std=c99 -m64 -fPIC -fp-model strict -O3 '
|
62 |
+
'-fomit-frame-pointer -{}').format(mpopt)
|
63 |
+
compiler = self.cc_exe
|
64 |
+
|
65 |
+
if platform.system() == 'Darwin':
|
66 |
+
shared_flag = '-Wl,-undefined,dynamic_lookup'
|
67 |
+
else:
|
68 |
+
shared_flag = '-shared'
|
69 |
+
self.set_executables(compiler=compiler,
|
70 |
+
compiler_so=compiler,
|
71 |
+
compiler_cxx=compiler,
|
72 |
+
archiver='xiar' + ' cru',
|
73 |
+
linker_exe=compiler + ' -shared-intel',
|
74 |
+
linker_so=compiler + ' ' + shared_flag +
|
75 |
+
' -shared-intel')
|
76 |
+
|
77 |
+
|
78 |
+
if platform.system() == 'Windows':
|
79 |
+
class IntelCCompilerW(MSVCCompiler):
|
80 |
+
"""
|
81 |
+
A modified Intel compiler compatible with an MSVC-built Python.
|
82 |
+
"""
|
83 |
+
compiler_type = 'intelw'
|
84 |
+
compiler_cxx = 'icl'
|
85 |
+
|
86 |
+
def __init__(self, verbose=0, dry_run=0, force=0):
|
87 |
+
MSVCCompiler.__init__(self, verbose, dry_run, force)
|
88 |
+
version_match = simple_version_match(start=r'Intel\(R\).*?32,')
|
89 |
+
self.__version = version_match
|
90 |
+
|
91 |
+
def initialize(self, plat_name=None):
|
92 |
+
MSVCCompiler.initialize(self, plat_name)
|
93 |
+
self.cc = self.find_exe('icl.exe')
|
94 |
+
self.lib = self.find_exe('xilib')
|
95 |
+
self.linker = self.find_exe('xilink')
|
96 |
+
self.compile_options = ['/nologo', '/O3', '/MD', '/W3',
|
97 |
+
'/Qstd=c99']
|
98 |
+
self.compile_options_debug = ['/nologo', '/Od', '/MDd', '/W3',
|
99 |
+
'/Qstd=c99', '/Z7', '/D_DEBUG']
|
100 |
+
|
101 |
+
class IntelEM64TCCompilerW(IntelCCompilerW):
|
102 |
+
"""
|
103 |
+
A modified Intel x86_64 compiler compatible with
|
104 |
+
a 64bit MSVC-built Python.
|
105 |
+
"""
|
106 |
+
compiler_type = 'intelemw'
|
107 |
+
|
108 |
+
def __init__(self, verbose=0, dry_run=0, force=0):
|
109 |
+
MSVCCompiler.__init__(self, verbose, dry_run, force)
|
110 |
+
version_match = simple_version_match(start=r'Intel\(R\).*?64,')
|
111 |
+
self.__version = version_match
|
venv/lib/python3.10/site-packages/numpy/distutils/lib2def.py
ADDED
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import re
|
2 |
+
import sys
|
3 |
+
import subprocess
|
4 |
+
|
5 |
+
__doc__ = """This module generates a DEF file from the symbols in
|
6 |
+
an MSVC-compiled DLL import library. It correctly discriminates between
|
7 |
+
data and functions. The data is collected from the output of the program
|
8 |
+
nm(1).
|
9 |
+
|
10 |
+
Usage:
|
11 |
+
python lib2def.py [libname.lib] [output.def]
|
12 |
+
or
|
13 |
+
python lib2def.py [libname.lib] > output.def
|
14 |
+
|
15 |
+
libname.lib defaults to python<py_ver>.lib and output.def defaults to stdout
|
16 |
+
|
17 |
+
Author: Robert Kern <[email protected]>
|
18 |
+
Last Update: April 30, 1999
|
19 |
+
"""
|
20 |
+
|
21 |
+
__version__ = '0.1a'
|
22 |
+
|
23 |
+
py_ver = "%d%d" % tuple(sys.version_info[:2])
|
24 |
+
|
25 |
+
DEFAULT_NM = ['nm', '-Cs']
|
26 |
+
|
27 |
+
DEF_HEADER = """LIBRARY python%s.dll
|
28 |
+
;CODE PRELOAD MOVEABLE DISCARDABLE
|
29 |
+
;DATA PRELOAD SINGLE
|
30 |
+
|
31 |
+
EXPORTS
|
32 |
+
""" % py_ver
|
33 |
+
# the header of the DEF file
|
34 |
+
|
35 |
+
FUNC_RE = re.compile(r"^(.*) in python%s\.dll" % py_ver, re.MULTILINE)
|
36 |
+
DATA_RE = re.compile(r"^_imp__(.*) in python%s\.dll" % py_ver, re.MULTILINE)
|
37 |
+
|
38 |
+
def parse_cmd():
|
39 |
+
"""Parses the command-line arguments.
|
40 |
+
|
41 |
+
libfile, deffile = parse_cmd()"""
|
42 |
+
if len(sys.argv) == 3:
|
43 |
+
if sys.argv[1][-4:] == '.lib' and sys.argv[2][-4:] == '.def':
|
44 |
+
libfile, deffile = sys.argv[1:]
|
45 |
+
elif sys.argv[1][-4:] == '.def' and sys.argv[2][-4:] == '.lib':
|
46 |
+
deffile, libfile = sys.argv[1:]
|
47 |
+
else:
|
48 |
+
print("I'm assuming that your first argument is the library")
|
49 |
+
print("and the second is the DEF file.")
|
50 |
+
elif len(sys.argv) == 2:
|
51 |
+
if sys.argv[1][-4:] == '.def':
|
52 |
+
deffile = sys.argv[1]
|
53 |
+
libfile = 'python%s.lib' % py_ver
|
54 |
+
elif sys.argv[1][-4:] == '.lib':
|
55 |
+
deffile = None
|
56 |
+
libfile = sys.argv[1]
|
57 |
+
else:
|
58 |
+
libfile = 'python%s.lib' % py_ver
|
59 |
+
deffile = None
|
60 |
+
return libfile, deffile
|
61 |
+
|
62 |
+
def getnm(nm_cmd=['nm', '-Cs', 'python%s.lib' % py_ver], shell=True):
|
63 |
+
"""Returns the output of nm_cmd via a pipe.
|
64 |
+
|
65 |
+
nm_output = getnm(nm_cmd = 'nm -Cs py_lib')"""
|
66 |
+
p = subprocess.Popen(nm_cmd, shell=shell, stdout=subprocess.PIPE,
|
67 |
+
stderr=subprocess.PIPE, text=True)
|
68 |
+
nm_output, nm_err = p.communicate()
|
69 |
+
if p.returncode != 0:
|
70 |
+
raise RuntimeError('failed to run "%s": "%s"' % (
|
71 |
+
' '.join(nm_cmd), nm_err))
|
72 |
+
return nm_output
|
73 |
+
|
74 |
+
def parse_nm(nm_output):
|
75 |
+
"""Returns a tuple of lists: dlist for the list of data
|
76 |
+
symbols and flist for the list of function symbols.
|
77 |
+
|
78 |
+
dlist, flist = parse_nm(nm_output)"""
|
79 |
+
data = DATA_RE.findall(nm_output)
|
80 |
+
func = FUNC_RE.findall(nm_output)
|
81 |
+
|
82 |
+
flist = []
|
83 |
+
for sym in data:
|
84 |
+
if sym in func and (sym[:2] == 'Py' or sym[:3] == '_Py' or sym[:4] == 'init'):
|
85 |
+
flist.append(sym)
|
86 |
+
|
87 |
+
dlist = []
|
88 |
+
for sym in data:
|
89 |
+
if sym not in flist and (sym[:2] == 'Py' or sym[:3] == '_Py'):
|
90 |
+
dlist.append(sym)
|
91 |
+
|
92 |
+
dlist.sort()
|
93 |
+
flist.sort()
|
94 |
+
return dlist, flist
|
95 |
+
|
96 |
+
def output_def(dlist, flist, header, file = sys.stdout):
|
97 |
+
"""Outputs the final DEF file to a file defaulting to stdout.
|
98 |
+
|
99 |
+
output_def(dlist, flist, header, file = sys.stdout)"""
|
100 |
+
for data_sym in dlist:
|
101 |
+
header = header + '\t%s DATA\n' % data_sym
|
102 |
+
header = header + '\n' # blank line
|
103 |
+
for func_sym in flist:
|
104 |
+
header = header + '\t%s\n' % func_sym
|
105 |
+
file.write(header)
|
106 |
+
|
107 |
+
if __name__ == '__main__':
|
108 |
+
libfile, deffile = parse_cmd()
|
109 |
+
if deffile is None:
|
110 |
+
deffile = sys.stdout
|
111 |
+
else:
|
112 |
+
deffile = open(deffile, 'w')
|
113 |
+
nm_cmd = DEFAULT_NM + [str(libfile)]
|
114 |
+
nm_output = getnm(nm_cmd, shell=False)
|
115 |
+
dlist, flist = parse_nm(nm_output)
|
116 |
+
output_def(dlist, flist, DEF_HEADER, deffile)
|
venv/lib/python3.10/site-packages/numpy/distutils/line_endings.py
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
""" Functions for converting from DOS to UNIX line endings
|
2 |
+
|
3 |
+
"""
|
4 |
+
import os
|
5 |
+
import re
|
6 |
+
import sys
|
7 |
+
|
8 |
+
|
9 |
+
def dos2unix(file):
|
10 |
+
"Replace CRLF with LF in argument files. Print names of changed files."
|
11 |
+
if os.path.isdir(file):
|
12 |
+
print(file, "Directory!")
|
13 |
+
return
|
14 |
+
|
15 |
+
with open(file, "rb") as fp:
|
16 |
+
data = fp.read()
|
17 |
+
if '\0' in data:
|
18 |
+
print(file, "Binary!")
|
19 |
+
return
|
20 |
+
|
21 |
+
newdata = re.sub("\r\n", "\n", data)
|
22 |
+
if newdata != data:
|
23 |
+
print('dos2unix:', file)
|
24 |
+
with open(file, "wb") as f:
|
25 |
+
f.write(newdata)
|
26 |
+
return file
|
27 |
+
else:
|
28 |
+
print(file, 'ok')
|
29 |
+
|
30 |
+
def dos2unix_one_dir(modified_files, dir_name, file_names):
|
31 |
+
for file in file_names:
|
32 |
+
full_path = os.path.join(dir_name, file)
|
33 |
+
file = dos2unix(full_path)
|
34 |
+
if file is not None:
|
35 |
+
modified_files.append(file)
|
36 |
+
|
37 |
+
def dos2unix_dir(dir_name):
|
38 |
+
modified_files = []
|
39 |
+
os.path.walk(dir_name, dos2unix_one_dir, modified_files)
|
40 |
+
return modified_files
|
41 |
+
#----------------------------------
|
42 |
+
|
43 |
+
def unix2dos(file):
|
44 |
+
"Replace LF with CRLF in argument files. Print names of changed files."
|
45 |
+
if os.path.isdir(file):
|
46 |
+
print(file, "Directory!")
|
47 |
+
return
|
48 |
+
|
49 |
+
with open(file, "rb") as fp:
|
50 |
+
data = fp.read()
|
51 |
+
if '\0' in data:
|
52 |
+
print(file, "Binary!")
|
53 |
+
return
|
54 |
+
newdata = re.sub("\r\n", "\n", data)
|
55 |
+
newdata = re.sub("\n", "\r\n", newdata)
|
56 |
+
if newdata != data:
|
57 |
+
print('unix2dos:', file)
|
58 |
+
with open(file, "wb") as f:
|
59 |
+
f.write(newdata)
|
60 |
+
return file
|
61 |
+
else:
|
62 |
+
print(file, 'ok')
|
63 |
+
|
64 |
+
def unix2dos_one_dir(modified_files, dir_name, file_names):
|
65 |
+
for file in file_names:
|
66 |
+
full_path = os.path.join(dir_name, file)
|
67 |
+
unix2dos(full_path)
|
68 |
+
if file is not None:
|
69 |
+
modified_files.append(file)
|
70 |
+
|
71 |
+
def unix2dos_dir(dir_name):
|
72 |
+
modified_files = []
|
73 |
+
os.path.walk(dir_name, unix2dos_one_dir, modified_files)
|
74 |
+
return modified_files
|
75 |
+
|
76 |
+
if __name__ == "__main__":
|
77 |
+
dos2unix_dir(sys.argv[1])
|
venv/lib/python3.10/site-packages/numpy/distutils/npy_pkg_config.py
ADDED
@@ -0,0 +1,437 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import sys
|
2 |
+
import re
|
3 |
+
import os
|
4 |
+
|
5 |
+
from configparser import RawConfigParser
|
6 |
+
|
7 |
+
__all__ = ['FormatError', 'PkgNotFound', 'LibraryInfo', 'VariableSet',
|
8 |
+
'read_config', 'parse_flags']
|
9 |
+
|
10 |
+
_VAR = re.compile(r'\$\{([a-zA-Z0-9_-]+)\}')
|
11 |
+
|
12 |
+
class FormatError(OSError):
|
13 |
+
"""
|
14 |
+
Exception thrown when there is a problem parsing a configuration file.
|
15 |
+
|
16 |
+
"""
|
17 |
+
def __init__(self, msg):
|
18 |
+
self.msg = msg
|
19 |
+
|
20 |
+
def __str__(self):
|
21 |
+
return self.msg
|
22 |
+
|
23 |
+
class PkgNotFound(OSError):
|
24 |
+
"""Exception raised when a package can not be located."""
|
25 |
+
def __init__(self, msg):
|
26 |
+
self.msg = msg
|
27 |
+
|
28 |
+
def __str__(self):
|
29 |
+
return self.msg
|
30 |
+
|
31 |
+
def parse_flags(line):
|
32 |
+
"""
|
33 |
+
Parse a line from a config file containing compile flags.
|
34 |
+
|
35 |
+
Parameters
|
36 |
+
----------
|
37 |
+
line : str
|
38 |
+
A single line containing one or more compile flags.
|
39 |
+
|
40 |
+
Returns
|
41 |
+
-------
|
42 |
+
d : dict
|
43 |
+
Dictionary of parsed flags, split into relevant categories.
|
44 |
+
These categories are the keys of `d`:
|
45 |
+
|
46 |
+
* 'include_dirs'
|
47 |
+
* 'library_dirs'
|
48 |
+
* 'libraries'
|
49 |
+
* 'macros'
|
50 |
+
* 'ignored'
|
51 |
+
|
52 |
+
"""
|
53 |
+
d = {'include_dirs': [], 'library_dirs': [], 'libraries': [],
|
54 |
+
'macros': [], 'ignored': []}
|
55 |
+
|
56 |
+
flags = (' ' + line).split(' -')
|
57 |
+
for flag in flags:
|
58 |
+
flag = '-' + flag
|
59 |
+
if len(flag) > 0:
|
60 |
+
if flag.startswith('-I'):
|
61 |
+
d['include_dirs'].append(flag[2:].strip())
|
62 |
+
elif flag.startswith('-L'):
|
63 |
+
d['library_dirs'].append(flag[2:].strip())
|
64 |
+
elif flag.startswith('-l'):
|
65 |
+
d['libraries'].append(flag[2:].strip())
|
66 |
+
elif flag.startswith('-D'):
|
67 |
+
d['macros'].append(flag[2:].strip())
|
68 |
+
else:
|
69 |
+
d['ignored'].append(flag)
|
70 |
+
|
71 |
+
return d
|
72 |
+
|
73 |
+
def _escape_backslash(val):
|
74 |
+
return val.replace('\\', '\\\\')
|
75 |
+
|
76 |
+
class LibraryInfo:
|
77 |
+
"""
|
78 |
+
Object containing build information about a library.
|
79 |
+
|
80 |
+
Parameters
|
81 |
+
----------
|
82 |
+
name : str
|
83 |
+
The library name.
|
84 |
+
description : str
|
85 |
+
Description of the library.
|
86 |
+
version : str
|
87 |
+
Version string.
|
88 |
+
sections : dict
|
89 |
+
The sections of the configuration file for the library. The keys are
|
90 |
+
the section headers, the values the text under each header.
|
91 |
+
vars : class instance
|
92 |
+
A `VariableSet` instance, which contains ``(name, value)`` pairs for
|
93 |
+
variables defined in the configuration file for the library.
|
94 |
+
requires : sequence, optional
|
95 |
+
The required libraries for the library to be installed.
|
96 |
+
|
97 |
+
Notes
|
98 |
+
-----
|
99 |
+
All input parameters (except "sections" which is a method) are available as
|
100 |
+
attributes of the same name.
|
101 |
+
|
102 |
+
"""
|
103 |
+
def __init__(self, name, description, version, sections, vars, requires=None):
|
104 |
+
self.name = name
|
105 |
+
self.description = description
|
106 |
+
if requires:
|
107 |
+
self.requires = requires
|
108 |
+
else:
|
109 |
+
self.requires = []
|
110 |
+
self.version = version
|
111 |
+
self._sections = sections
|
112 |
+
self.vars = vars
|
113 |
+
|
114 |
+
def sections(self):
|
115 |
+
"""
|
116 |
+
Return the section headers of the config file.
|
117 |
+
|
118 |
+
Parameters
|
119 |
+
----------
|
120 |
+
None
|
121 |
+
|
122 |
+
Returns
|
123 |
+
-------
|
124 |
+
keys : list of str
|
125 |
+
The list of section headers.
|
126 |
+
|
127 |
+
"""
|
128 |
+
return list(self._sections.keys())
|
129 |
+
|
130 |
+
def cflags(self, section="default"):
|
131 |
+
val = self.vars.interpolate(self._sections[section]['cflags'])
|
132 |
+
return _escape_backslash(val)
|
133 |
+
|
134 |
+
def libs(self, section="default"):
|
135 |
+
val = self.vars.interpolate(self._sections[section]['libs'])
|
136 |
+
return _escape_backslash(val)
|
137 |
+
|
138 |
+
def __str__(self):
|
139 |
+
m = ['Name: %s' % self.name, 'Description: %s' % self.description]
|
140 |
+
if self.requires:
|
141 |
+
m.append('Requires:')
|
142 |
+
else:
|
143 |
+
m.append('Requires: %s' % ",".join(self.requires))
|
144 |
+
m.append('Version: %s' % self.version)
|
145 |
+
|
146 |
+
return "\n".join(m)
|
147 |
+
|
148 |
+
class VariableSet:
|
149 |
+
"""
|
150 |
+
Container object for the variables defined in a config file.
|
151 |
+
|
152 |
+
`VariableSet` can be used as a plain dictionary, with the variable names
|
153 |
+
as keys.
|
154 |
+
|
155 |
+
Parameters
|
156 |
+
----------
|
157 |
+
d : dict
|
158 |
+
Dict of items in the "variables" section of the configuration file.
|
159 |
+
|
160 |
+
"""
|
161 |
+
def __init__(self, d):
|
162 |
+
self._raw_data = dict([(k, v) for k, v in d.items()])
|
163 |
+
|
164 |
+
self._re = {}
|
165 |
+
self._re_sub = {}
|
166 |
+
|
167 |
+
self._init_parse()
|
168 |
+
|
169 |
+
def _init_parse(self):
|
170 |
+
for k, v in self._raw_data.items():
|
171 |
+
self._init_parse_var(k, v)
|
172 |
+
|
173 |
+
def _init_parse_var(self, name, value):
|
174 |
+
self._re[name] = re.compile(r'\$\{%s\}' % name)
|
175 |
+
self._re_sub[name] = value
|
176 |
+
|
177 |
+
def interpolate(self, value):
|
178 |
+
# Brute force: we keep interpolating until there is no '${var}' anymore
|
179 |
+
# or until interpolated string is equal to input string
|
180 |
+
def _interpolate(value):
|
181 |
+
for k in self._re.keys():
|
182 |
+
value = self._re[k].sub(self._re_sub[k], value)
|
183 |
+
return value
|
184 |
+
while _VAR.search(value):
|
185 |
+
nvalue = _interpolate(value)
|
186 |
+
if nvalue == value:
|
187 |
+
break
|
188 |
+
value = nvalue
|
189 |
+
|
190 |
+
return value
|
191 |
+
|
192 |
+
def variables(self):
|
193 |
+
"""
|
194 |
+
Return the list of variable names.
|
195 |
+
|
196 |
+
Parameters
|
197 |
+
----------
|
198 |
+
None
|
199 |
+
|
200 |
+
Returns
|
201 |
+
-------
|
202 |
+
names : list of str
|
203 |
+
The names of all variables in the `VariableSet` instance.
|
204 |
+
|
205 |
+
"""
|
206 |
+
return list(self._raw_data.keys())
|
207 |
+
|
208 |
+
# Emulate a dict to set/get variables values
|
209 |
+
def __getitem__(self, name):
|
210 |
+
return self._raw_data[name]
|
211 |
+
|
212 |
+
def __setitem__(self, name, value):
|
213 |
+
self._raw_data[name] = value
|
214 |
+
self._init_parse_var(name, value)
|
215 |
+
|
216 |
+
def parse_meta(config):
|
217 |
+
if not config.has_section('meta'):
|
218 |
+
raise FormatError("No meta section found !")
|
219 |
+
|
220 |
+
d = dict(config.items('meta'))
|
221 |
+
|
222 |
+
for k in ['name', 'description', 'version']:
|
223 |
+
if not k in d:
|
224 |
+
raise FormatError("Option %s (section [meta]) is mandatory, "
|
225 |
+
"but not found" % k)
|
226 |
+
|
227 |
+
if not 'requires' in d:
|
228 |
+
d['requires'] = []
|
229 |
+
|
230 |
+
return d
|
231 |
+
|
232 |
+
def parse_variables(config):
|
233 |
+
if not config.has_section('variables'):
|
234 |
+
raise FormatError("No variables section found !")
|
235 |
+
|
236 |
+
d = {}
|
237 |
+
|
238 |
+
for name, value in config.items("variables"):
|
239 |
+
d[name] = value
|
240 |
+
|
241 |
+
return VariableSet(d)
|
242 |
+
|
243 |
+
def parse_sections(config):
|
244 |
+
return meta_d, r
|
245 |
+
|
246 |
+
def pkg_to_filename(pkg_name):
|
247 |
+
return "%s.ini" % pkg_name
|
248 |
+
|
249 |
+
def parse_config(filename, dirs=None):
|
250 |
+
if dirs:
|
251 |
+
filenames = [os.path.join(d, filename) for d in dirs]
|
252 |
+
else:
|
253 |
+
filenames = [filename]
|
254 |
+
|
255 |
+
config = RawConfigParser()
|
256 |
+
|
257 |
+
n = config.read(filenames)
|
258 |
+
if not len(n) >= 1:
|
259 |
+
raise PkgNotFound("Could not find file(s) %s" % str(filenames))
|
260 |
+
|
261 |
+
# Parse meta and variables sections
|
262 |
+
meta = parse_meta(config)
|
263 |
+
|
264 |
+
vars = {}
|
265 |
+
if config.has_section('variables'):
|
266 |
+
for name, value in config.items("variables"):
|
267 |
+
vars[name] = _escape_backslash(value)
|
268 |
+
|
269 |
+
# Parse "normal" sections
|
270 |
+
secs = [s for s in config.sections() if not s in ['meta', 'variables']]
|
271 |
+
sections = {}
|
272 |
+
|
273 |
+
requires = {}
|
274 |
+
for s in secs:
|
275 |
+
d = {}
|
276 |
+
if config.has_option(s, "requires"):
|
277 |
+
requires[s] = config.get(s, 'requires')
|
278 |
+
|
279 |
+
for name, value in config.items(s):
|
280 |
+
d[name] = value
|
281 |
+
sections[s] = d
|
282 |
+
|
283 |
+
return meta, vars, sections, requires
|
284 |
+
|
285 |
+
def _read_config_imp(filenames, dirs=None):
|
286 |
+
def _read_config(f):
|
287 |
+
meta, vars, sections, reqs = parse_config(f, dirs)
|
288 |
+
# recursively add sections and variables of required libraries
|
289 |
+
for rname, rvalue in reqs.items():
|
290 |
+
nmeta, nvars, nsections, nreqs = _read_config(pkg_to_filename(rvalue))
|
291 |
+
|
292 |
+
# Update var dict for variables not in 'top' config file
|
293 |
+
for k, v in nvars.items():
|
294 |
+
if not k in vars:
|
295 |
+
vars[k] = v
|
296 |
+
|
297 |
+
# Update sec dict
|
298 |
+
for oname, ovalue in nsections[rname].items():
|
299 |
+
if ovalue:
|
300 |
+
sections[rname][oname] += ' %s' % ovalue
|
301 |
+
|
302 |
+
return meta, vars, sections, reqs
|
303 |
+
|
304 |
+
meta, vars, sections, reqs = _read_config(filenames)
|
305 |
+
|
306 |
+
# FIXME: document this. If pkgname is defined in the variables section, and
|
307 |
+
# there is no pkgdir variable defined, pkgdir is automatically defined to
|
308 |
+
# the path of pkgname. This requires the package to be imported to work
|
309 |
+
if not 'pkgdir' in vars and "pkgname" in vars:
|
310 |
+
pkgname = vars["pkgname"]
|
311 |
+
if not pkgname in sys.modules:
|
312 |
+
raise ValueError("You should import %s to get information on %s" %
|
313 |
+
(pkgname, meta["name"]))
|
314 |
+
|
315 |
+
mod = sys.modules[pkgname]
|
316 |
+
vars["pkgdir"] = _escape_backslash(os.path.dirname(mod.__file__))
|
317 |
+
|
318 |
+
return LibraryInfo(name=meta["name"], description=meta["description"],
|
319 |
+
version=meta["version"], sections=sections, vars=VariableSet(vars))
|
320 |
+
|
321 |
+
# Trivial cache to cache LibraryInfo instances creation. To be really
|
322 |
+
# efficient, the cache should be handled in read_config, since a same file can
|
323 |
+
# be parsed many time outside LibraryInfo creation, but I doubt this will be a
|
324 |
+
# problem in practice
|
325 |
+
_CACHE = {}
|
326 |
+
def read_config(pkgname, dirs=None):
|
327 |
+
"""
|
328 |
+
Return library info for a package from its configuration file.
|
329 |
+
|
330 |
+
Parameters
|
331 |
+
----------
|
332 |
+
pkgname : str
|
333 |
+
Name of the package (should match the name of the .ini file, without
|
334 |
+
the extension, e.g. foo for the file foo.ini).
|
335 |
+
dirs : sequence, optional
|
336 |
+
If given, should be a sequence of directories - usually including
|
337 |
+
the NumPy base directory - where to look for npy-pkg-config files.
|
338 |
+
|
339 |
+
Returns
|
340 |
+
-------
|
341 |
+
pkginfo : class instance
|
342 |
+
The `LibraryInfo` instance containing the build information.
|
343 |
+
|
344 |
+
Raises
|
345 |
+
------
|
346 |
+
PkgNotFound
|
347 |
+
If the package is not found.
|
348 |
+
|
349 |
+
See Also
|
350 |
+
--------
|
351 |
+
misc_util.get_info, misc_util.get_pkg_info
|
352 |
+
|
353 |
+
Examples
|
354 |
+
--------
|
355 |
+
>>> npymath_info = np.distutils.npy_pkg_config.read_config('npymath')
|
356 |
+
>>> type(npymath_info)
|
357 |
+
<class 'numpy.distutils.npy_pkg_config.LibraryInfo'>
|
358 |
+
>>> print(npymath_info)
|
359 |
+
Name: npymath
|
360 |
+
Description: Portable, core math library implementing C99 standard
|
361 |
+
Requires:
|
362 |
+
Version: 0.1 #random
|
363 |
+
|
364 |
+
"""
|
365 |
+
try:
|
366 |
+
return _CACHE[pkgname]
|
367 |
+
except KeyError:
|
368 |
+
v = _read_config_imp(pkg_to_filename(pkgname), dirs)
|
369 |
+
_CACHE[pkgname] = v
|
370 |
+
return v
|
371 |
+
|
372 |
+
# TODO:
|
373 |
+
# - implements version comparison (modversion + atleast)
|
374 |
+
|
375 |
+
# pkg-config simple emulator - useful for debugging, and maybe later to query
|
376 |
+
# the system
|
377 |
+
if __name__ == '__main__':
|
378 |
+
from optparse import OptionParser
|
379 |
+
import glob
|
380 |
+
|
381 |
+
parser = OptionParser()
|
382 |
+
parser.add_option("--cflags", dest="cflags", action="store_true",
|
383 |
+
help="output all preprocessor and compiler flags")
|
384 |
+
parser.add_option("--libs", dest="libs", action="store_true",
|
385 |
+
help="output all linker flags")
|
386 |
+
parser.add_option("--use-section", dest="section",
|
387 |
+
help="use this section instead of default for options")
|
388 |
+
parser.add_option("--version", dest="version", action="store_true",
|
389 |
+
help="output version")
|
390 |
+
parser.add_option("--atleast-version", dest="min_version",
|
391 |
+
help="Minimal version")
|
392 |
+
parser.add_option("--list-all", dest="list_all", action="store_true",
|
393 |
+
help="Minimal version")
|
394 |
+
parser.add_option("--define-variable", dest="define_variable",
|
395 |
+
help="Replace variable with the given value")
|
396 |
+
|
397 |
+
(options, args) = parser.parse_args(sys.argv)
|
398 |
+
|
399 |
+
if len(args) < 2:
|
400 |
+
raise ValueError("Expect package name on the command line:")
|
401 |
+
|
402 |
+
if options.list_all:
|
403 |
+
files = glob.glob("*.ini")
|
404 |
+
for f in files:
|
405 |
+
info = read_config(f)
|
406 |
+
print("%s\t%s - %s" % (info.name, info.name, info.description))
|
407 |
+
|
408 |
+
pkg_name = args[1]
|
409 |
+
d = os.environ.get('NPY_PKG_CONFIG_PATH')
|
410 |
+
if d:
|
411 |
+
info = read_config(pkg_name, ['numpy/core/lib/npy-pkg-config', '.', d])
|
412 |
+
else:
|
413 |
+
info = read_config(pkg_name, ['numpy/core/lib/npy-pkg-config', '.'])
|
414 |
+
|
415 |
+
if options.section:
|
416 |
+
section = options.section
|
417 |
+
else:
|
418 |
+
section = "default"
|
419 |
+
|
420 |
+
if options.define_variable:
|
421 |
+
m = re.search(r'([\S]+)=([\S]+)', options.define_variable)
|
422 |
+
if not m:
|
423 |
+
raise ValueError("--define-variable option should be of "
|
424 |
+
"the form --define-variable=foo=bar")
|
425 |
+
else:
|
426 |
+
name = m.group(1)
|
427 |
+
value = m.group(2)
|
428 |
+
info.vars[name] = value
|
429 |
+
|
430 |
+
if options.cflags:
|
431 |
+
print(info.cflags(section))
|
432 |
+
if options.libs:
|
433 |
+
print(info.libs(section))
|
434 |
+
if options.version:
|
435 |
+
print(info.version)
|
436 |
+
if options.min_version:
|
437 |
+
print(info.version >= options.min_version)
|
venv/lib/python3.10/site-packages/numpy/distutils/pathccompiler.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from distutils.unixccompiler import UnixCCompiler
|
2 |
+
|
3 |
+
class PathScaleCCompiler(UnixCCompiler):
|
4 |
+
|
5 |
+
"""
|
6 |
+
PathScale compiler compatible with an gcc built Python.
|
7 |
+
"""
|
8 |
+
|
9 |
+
compiler_type = 'pathcc'
|
10 |
+
cc_exe = 'pathcc'
|
11 |
+
cxx_exe = 'pathCC'
|
12 |
+
|
13 |
+
def __init__ (self, verbose=0, dry_run=0, force=0):
|
14 |
+
UnixCCompiler.__init__ (self, verbose, dry_run, force)
|
15 |
+
cc_compiler = self.cc_exe
|
16 |
+
cxx_compiler = self.cxx_exe
|
17 |
+
self.set_executables(compiler=cc_compiler,
|
18 |
+
compiler_so=cc_compiler,
|
19 |
+
compiler_cxx=cxx_compiler,
|
20 |
+
linker_exe=cc_compiler,
|
21 |
+
linker_so=cc_compiler + ' -shared')
|
venv/lib/python3.10/site-packages/numpy/doc/__init__.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
|
3 |
+
ref_dir = os.path.join(os.path.dirname(__file__))
|
4 |
+
|
5 |
+
__all__ = sorted(f[:-3] for f in os.listdir(ref_dir) if f.endswith('.py') and
|
6 |
+
not f.startswith('__'))
|
7 |
+
|
8 |
+
for f in __all__:
|
9 |
+
__import__(__name__ + '.' + f)
|
10 |
+
|
11 |
+
del f, ref_dir
|
12 |
+
|
13 |
+
__doc__ = """\
|
14 |
+
Topical documentation
|
15 |
+
=====================
|
16 |
+
|
17 |
+
The following topics are available:
|
18 |
+
%s
|
19 |
+
|
20 |
+
You can view them by
|
21 |
+
|
22 |
+
>>> help(np.doc.TOPIC) #doctest: +SKIP
|
23 |
+
|
24 |
+
""" % '\n- '.join([''] + __all__)
|
25 |
+
|
26 |
+
__all__.extend(['__doc__'])
|
venv/lib/python3.10/site-packages/numpy/doc/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (802 Bytes). View file
|
|
venv/lib/python3.10/site-packages/numpy/doc/__pycache__/constants.cpython-310.pyc
ADDED
Binary file (8.05 kB). View file
|
|
venv/lib/python3.10/site-packages/numpy/doc/__pycache__/ufuncs.cpython-310.pyc
ADDED
Binary file (5.54 kB). View file
|
|
venv/lib/python3.10/site-packages/numpy/doc/constants.py
ADDED
@@ -0,0 +1,412 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
=========
|
3 |
+
Constants
|
4 |
+
=========
|
5 |
+
|
6 |
+
.. currentmodule:: numpy
|
7 |
+
|
8 |
+
NumPy includes several constants:
|
9 |
+
|
10 |
+
%(constant_list)s
|
11 |
+
"""
|
12 |
+
#
|
13 |
+
# Note: the docstring is autogenerated.
|
14 |
+
#
|
15 |
+
import re
|
16 |
+
import textwrap
|
17 |
+
|
18 |
+
# Maintain same format as in numpy.add_newdocs
|
19 |
+
constants = []
|
20 |
+
def add_newdoc(module, name, doc):
|
21 |
+
constants.append((name, doc))
|
22 |
+
|
23 |
+
add_newdoc('numpy', 'pi',
|
24 |
+
"""
|
25 |
+
``pi = 3.1415926535897932384626433...``
|
26 |
+
|
27 |
+
References
|
28 |
+
----------
|
29 |
+
https://en.wikipedia.org/wiki/Pi
|
30 |
+
|
31 |
+
""")
|
32 |
+
|
33 |
+
add_newdoc('numpy', 'e',
|
34 |
+
"""
|
35 |
+
Euler's constant, base of natural logarithms, Napier's constant.
|
36 |
+
|
37 |
+
``e = 2.71828182845904523536028747135266249775724709369995...``
|
38 |
+
|
39 |
+
See Also
|
40 |
+
--------
|
41 |
+
exp : Exponential function
|
42 |
+
log : Natural logarithm
|
43 |
+
|
44 |
+
References
|
45 |
+
----------
|
46 |
+
https://en.wikipedia.org/wiki/E_%28mathematical_constant%29
|
47 |
+
|
48 |
+
""")
|
49 |
+
|
50 |
+
add_newdoc('numpy', 'euler_gamma',
|
51 |
+
"""
|
52 |
+
``γ = 0.5772156649015328606065120900824024310421...``
|
53 |
+
|
54 |
+
References
|
55 |
+
----------
|
56 |
+
https://en.wikipedia.org/wiki/Euler-Mascheroni_constant
|
57 |
+
|
58 |
+
""")
|
59 |
+
|
60 |
+
add_newdoc('numpy', 'inf',
|
61 |
+
"""
|
62 |
+
IEEE 754 floating point representation of (positive) infinity.
|
63 |
+
|
64 |
+
Returns
|
65 |
+
-------
|
66 |
+
y : float
|
67 |
+
A floating point representation of positive infinity.
|
68 |
+
|
69 |
+
See Also
|
70 |
+
--------
|
71 |
+
isinf : Shows which elements are positive or negative infinity
|
72 |
+
|
73 |
+
isposinf : Shows which elements are positive infinity
|
74 |
+
|
75 |
+
isneginf : Shows which elements are negative infinity
|
76 |
+
|
77 |
+
isnan : Shows which elements are Not a Number
|
78 |
+
|
79 |
+
isfinite : Shows which elements are finite (not one of Not a Number,
|
80 |
+
positive infinity and negative infinity)
|
81 |
+
|
82 |
+
Notes
|
83 |
+
-----
|
84 |
+
NumPy uses the IEEE Standard for Binary Floating-Point for Arithmetic
|
85 |
+
(IEEE 754). This means that Not a Number is not equivalent to infinity.
|
86 |
+
Also that positive infinity is not equivalent to negative infinity. But
|
87 |
+
infinity is equivalent to positive infinity.
|
88 |
+
|
89 |
+
`Inf`, `Infinity`, `PINF` and `infty` are aliases for `inf`.
|
90 |
+
|
91 |
+
Examples
|
92 |
+
--------
|
93 |
+
>>> np.inf
|
94 |
+
inf
|
95 |
+
>>> np.array([1]) / 0.
|
96 |
+
array([ Inf])
|
97 |
+
|
98 |
+
""")
|
99 |
+
|
100 |
+
add_newdoc('numpy', 'nan',
|
101 |
+
"""
|
102 |
+
IEEE 754 floating point representation of Not a Number (NaN).
|
103 |
+
|
104 |
+
Returns
|
105 |
+
-------
|
106 |
+
y : A floating point representation of Not a Number.
|
107 |
+
|
108 |
+
See Also
|
109 |
+
--------
|
110 |
+
isnan : Shows which elements are Not a Number.
|
111 |
+
|
112 |
+
isfinite : Shows which elements are finite (not one of
|
113 |
+
Not a Number, positive infinity and negative infinity)
|
114 |
+
|
115 |
+
Notes
|
116 |
+
-----
|
117 |
+
NumPy uses the IEEE Standard for Binary Floating-Point for Arithmetic
|
118 |
+
(IEEE 754). This means that Not a Number is not equivalent to infinity.
|
119 |
+
|
120 |
+
`NaN` and `NAN` are aliases of `nan`.
|
121 |
+
|
122 |
+
Examples
|
123 |
+
--------
|
124 |
+
>>> np.nan
|
125 |
+
nan
|
126 |
+
>>> np.log(-1)
|
127 |
+
nan
|
128 |
+
>>> np.log([-1, 1, 2])
|
129 |
+
array([ NaN, 0. , 0.69314718])
|
130 |
+
|
131 |
+
""")
|
132 |
+
|
133 |
+
add_newdoc('numpy', 'newaxis',
|
134 |
+
"""
|
135 |
+
A convenient alias for None, useful for indexing arrays.
|
136 |
+
|
137 |
+
Examples
|
138 |
+
--------
|
139 |
+
>>> newaxis is None
|
140 |
+
True
|
141 |
+
>>> x = np.arange(3)
|
142 |
+
>>> x
|
143 |
+
array([0, 1, 2])
|
144 |
+
>>> x[:, newaxis]
|
145 |
+
array([[0],
|
146 |
+
[1],
|
147 |
+
[2]])
|
148 |
+
>>> x[:, newaxis, newaxis]
|
149 |
+
array([[[0]],
|
150 |
+
[[1]],
|
151 |
+
[[2]]])
|
152 |
+
>>> x[:, newaxis] * x
|
153 |
+
array([[0, 0, 0],
|
154 |
+
[0, 1, 2],
|
155 |
+
[0, 2, 4]])
|
156 |
+
|
157 |
+
Outer product, same as ``outer(x, y)``:
|
158 |
+
|
159 |
+
>>> y = np.arange(3, 6)
|
160 |
+
>>> x[:, newaxis] * y
|
161 |
+
array([[ 0, 0, 0],
|
162 |
+
[ 3, 4, 5],
|
163 |
+
[ 6, 8, 10]])
|
164 |
+
|
165 |
+
``x[newaxis, :]`` is equivalent to ``x[newaxis]`` and ``x[None]``:
|
166 |
+
|
167 |
+
>>> x[newaxis, :].shape
|
168 |
+
(1, 3)
|
169 |
+
>>> x[newaxis].shape
|
170 |
+
(1, 3)
|
171 |
+
>>> x[None].shape
|
172 |
+
(1, 3)
|
173 |
+
>>> x[:, newaxis].shape
|
174 |
+
(3, 1)
|
175 |
+
|
176 |
+
""")
|
177 |
+
|
178 |
+
add_newdoc('numpy', 'NZERO',
|
179 |
+
"""
|
180 |
+
IEEE 754 floating point representation of negative zero.
|
181 |
+
|
182 |
+
Returns
|
183 |
+
-------
|
184 |
+
y : float
|
185 |
+
A floating point representation of negative zero.
|
186 |
+
|
187 |
+
See Also
|
188 |
+
--------
|
189 |
+
PZERO : Defines positive zero.
|
190 |
+
|
191 |
+
isinf : Shows which elements are positive or negative infinity.
|
192 |
+
|
193 |
+
isposinf : Shows which elements are positive infinity.
|
194 |
+
|
195 |
+
isneginf : Shows which elements are negative infinity.
|
196 |
+
|
197 |
+
isnan : Shows which elements are Not a Number.
|
198 |
+
|
199 |
+
isfinite : Shows which elements are finite - not one of
|
200 |
+
Not a Number, positive infinity and negative infinity.
|
201 |
+
|
202 |
+
Notes
|
203 |
+
-----
|
204 |
+
NumPy uses the IEEE Standard for Binary Floating-Point for Arithmetic
|
205 |
+
(IEEE 754). Negative zero is considered to be a finite number.
|
206 |
+
|
207 |
+
Examples
|
208 |
+
--------
|
209 |
+
>>> np.NZERO
|
210 |
+
-0.0
|
211 |
+
>>> np.PZERO
|
212 |
+
0.0
|
213 |
+
|
214 |
+
>>> np.isfinite([np.NZERO])
|
215 |
+
array([ True])
|
216 |
+
>>> np.isnan([np.NZERO])
|
217 |
+
array([False])
|
218 |
+
>>> np.isinf([np.NZERO])
|
219 |
+
array([False])
|
220 |
+
|
221 |
+
""")
|
222 |
+
|
223 |
+
add_newdoc('numpy', 'PZERO',
|
224 |
+
"""
|
225 |
+
IEEE 754 floating point representation of positive zero.
|
226 |
+
|
227 |
+
Returns
|
228 |
+
-------
|
229 |
+
y : float
|
230 |
+
A floating point representation of positive zero.
|
231 |
+
|
232 |
+
See Also
|
233 |
+
--------
|
234 |
+
NZERO : Defines negative zero.
|
235 |
+
|
236 |
+
isinf : Shows which elements are positive or negative infinity.
|
237 |
+
|
238 |
+
isposinf : Shows which elements are positive infinity.
|
239 |
+
|
240 |
+
isneginf : Shows which elements are negative infinity.
|
241 |
+
|
242 |
+
isnan : Shows which elements are Not a Number.
|
243 |
+
|
244 |
+
isfinite : Shows which elements are finite - not one of
|
245 |
+
Not a Number, positive infinity and negative infinity.
|
246 |
+
|
247 |
+
Notes
|
248 |
+
-----
|
249 |
+
NumPy uses the IEEE Standard for Binary Floating-Point for Arithmetic
|
250 |
+
(IEEE 754). Positive zero is considered to be a finite number.
|
251 |
+
|
252 |
+
Examples
|
253 |
+
--------
|
254 |
+
>>> np.PZERO
|
255 |
+
0.0
|
256 |
+
>>> np.NZERO
|
257 |
+
-0.0
|
258 |
+
|
259 |
+
>>> np.isfinite([np.PZERO])
|
260 |
+
array([ True])
|
261 |
+
>>> np.isnan([np.PZERO])
|
262 |
+
array([False])
|
263 |
+
>>> np.isinf([np.PZERO])
|
264 |
+
array([False])
|
265 |
+
|
266 |
+
""")
|
267 |
+
|
268 |
+
add_newdoc('numpy', 'NAN',
|
269 |
+
"""
|
270 |
+
IEEE 754 floating point representation of Not a Number (NaN).
|
271 |
+
|
272 |
+
`NaN` and `NAN` are equivalent definitions of `nan`. Please use
|
273 |
+
`nan` instead of `NAN`.
|
274 |
+
|
275 |
+
See Also
|
276 |
+
--------
|
277 |
+
nan
|
278 |
+
|
279 |
+
""")
|
280 |
+
|
281 |
+
add_newdoc('numpy', 'NaN',
|
282 |
+
"""
|
283 |
+
IEEE 754 floating point representation of Not a Number (NaN).
|
284 |
+
|
285 |
+
`NaN` and `NAN` are equivalent definitions of `nan`. Please use
|
286 |
+
`nan` instead of `NaN`.
|
287 |
+
|
288 |
+
See Also
|
289 |
+
--------
|
290 |
+
nan
|
291 |
+
|
292 |
+
""")
|
293 |
+
|
294 |
+
add_newdoc('numpy', 'NINF',
|
295 |
+
"""
|
296 |
+
IEEE 754 floating point representation of negative infinity.
|
297 |
+
|
298 |
+
Returns
|
299 |
+
-------
|
300 |
+
y : float
|
301 |
+
A floating point representation of negative infinity.
|
302 |
+
|
303 |
+
See Also
|
304 |
+
--------
|
305 |
+
isinf : Shows which elements are positive or negative infinity
|
306 |
+
|
307 |
+
isposinf : Shows which elements are positive infinity
|
308 |
+
|
309 |
+
isneginf : Shows which elements are negative infinity
|
310 |
+
|
311 |
+
isnan : Shows which elements are Not a Number
|
312 |
+
|
313 |
+
isfinite : Shows which elements are finite (not one of Not a Number,
|
314 |
+
positive infinity and negative infinity)
|
315 |
+
|
316 |
+
Notes
|
317 |
+
-----
|
318 |
+
NumPy uses the IEEE Standard for Binary Floating-Point for Arithmetic
|
319 |
+
(IEEE 754). This means that Not a Number is not equivalent to infinity.
|
320 |
+
Also that positive infinity is not equivalent to negative infinity. But
|
321 |
+
infinity is equivalent to positive infinity.
|
322 |
+
|
323 |
+
Examples
|
324 |
+
--------
|
325 |
+
>>> np.NINF
|
326 |
+
-inf
|
327 |
+
>>> np.log(0)
|
328 |
+
-inf
|
329 |
+
|
330 |
+
""")
|
331 |
+
|
332 |
+
add_newdoc('numpy', 'PINF',
|
333 |
+
"""
|
334 |
+
IEEE 754 floating point representation of (positive) infinity.
|
335 |
+
|
336 |
+
Use `inf` because `Inf`, `Infinity`, `PINF` and `infty` are aliases for
|
337 |
+
`inf`. For more details, see `inf`.
|
338 |
+
|
339 |
+
See Also
|
340 |
+
--------
|
341 |
+
inf
|
342 |
+
|
343 |
+
""")
|
344 |
+
|
345 |
+
add_newdoc('numpy', 'infty',
|
346 |
+
"""
|
347 |
+
IEEE 754 floating point representation of (positive) infinity.
|
348 |
+
|
349 |
+
Use `inf` because `Inf`, `Infinity`, `PINF` and `infty` are aliases for
|
350 |
+
`inf`. For more details, see `inf`.
|
351 |
+
|
352 |
+
See Also
|
353 |
+
--------
|
354 |
+
inf
|
355 |
+
|
356 |
+
""")
|
357 |
+
|
358 |
+
add_newdoc('numpy', 'Inf',
|
359 |
+
"""
|
360 |
+
IEEE 754 floating point representation of (positive) infinity.
|
361 |
+
|
362 |
+
Use `inf` because `Inf`, `Infinity`, `PINF` and `infty` are aliases for
|
363 |
+
`inf`. For more details, see `inf`.
|
364 |
+
|
365 |
+
See Also
|
366 |
+
--------
|
367 |
+
inf
|
368 |
+
|
369 |
+
""")
|
370 |
+
|
371 |
+
add_newdoc('numpy', 'Infinity',
|
372 |
+
"""
|
373 |
+
IEEE 754 floating point representation of (positive) infinity.
|
374 |
+
|
375 |
+
Use `inf` because `Inf`, `Infinity`, `PINF` and `infty` are aliases for
|
376 |
+
`inf`. For more details, see `inf`.
|
377 |
+
|
378 |
+
See Also
|
379 |
+
--------
|
380 |
+
inf
|
381 |
+
|
382 |
+
""")
|
383 |
+
|
384 |
+
|
385 |
+
if __doc__:
|
386 |
+
constants_str = []
|
387 |
+
constants.sort()
|
388 |
+
for name, doc in constants:
|
389 |
+
s = textwrap.dedent(doc).replace("\n", "\n ")
|
390 |
+
|
391 |
+
# Replace sections by rubrics
|
392 |
+
lines = s.split("\n")
|
393 |
+
new_lines = []
|
394 |
+
for line in lines:
|
395 |
+
m = re.match(r'^(\s+)[-=]+\s*$', line)
|
396 |
+
if m and new_lines:
|
397 |
+
prev = textwrap.dedent(new_lines.pop())
|
398 |
+
new_lines.append('%s.. rubric:: %s' % (m.group(1), prev))
|
399 |
+
new_lines.append('')
|
400 |
+
else:
|
401 |
+
new_lines.append(line)
|
402 |
+
s = "\n".join(new_lines)
|
403 |
+
|
404 |
+
# Done.
|
405 |
+
constants_str.append(""".. data:: %s\n %s""" % (name, s))
|
406 |
+
constants_str = "\n".join(constants_str)
|
407 |
+
|
408 |
+
__doc__ = __doc__ % dict(constant_list=constants_str)
|
409 |
+
del constants_str, name, doc
|
410 |
+
del line, lines, new_lines, m, s, prev
|
411 |
+
|
412 |
+
del constants, add_newdoc
|
venv/lib/python3.10/site-packages/numpy/doc/ufuncs.py
ADDED
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
===================
|
3 |
+
Universal Functions
|
4 |
+
===================
|
5 |
+
|
6 |
+
Ufuncs are, generally speaking, mathematical functions or operations that are
|
7 |
+
applied element-by-element to the contents of an array. That is, the result
|
8 |
+
in each output array element only depends on the value in the corresponding
|
9 |
+
input array (or arrays) and on no other array elements. NumPy comes with a
|
10 |
+
large suite of ufuncs, and scipy extends that suite substantially. The simplest
|
11 |
+
example is the addition operator: ::
|
12 |
+
|
13 |
+
>>> np.array([0,2,3,4]) + np.array([1,1,-1,2])
|
14 |
+
array([1, 3, 2, 6])
|
15 |
+
|
16 |
+
The ufunc module lists all the available ufuncs in numpy. Documentation on
|
17 |
+
the specific ufuncs may be found in those modules. This documentation is
|
18 |
+
intended to address the more general aspects of ufuncs common to most of
|
19 |
+
them. All of the ufuncs that make use of Python operators (e.g., +, -, etc.)
|
20 |
+
have equivalent functions defined (e.g. add() for +)
|
21 |
+
|
22 |
+
Type coercion
|
23 |
+
=============
|
24 |
+
|
25 |
+
What happens when a binary operator (e.g., +,-,\\*,/, etc) deals with arrays of
|
26 |
+
two different types? What is the type of the result? Typically, the result is
|
27 |
+
the higher of the two types. For example: ::
|
28 |
+
|
29 |
+
float32 + float64 -> float64
|
30 |
+
int8 + int32 -> int32
|
31 |
+
int16 + float32 -> float32
|
32 |
+
float32 + complex64 -> complex64
|
33 |
+
|
34 |
+
There are some less obvious cases generally involving mixes of types
|
35 |
+
(e.g. uints, ints and floats) where equal bit sizes for each are not
|
36 |
+
capable of saving all the information in a different type of equivalent
|
37 |
+
bit size. Some examples are int32 vs float32 or uint32 vs int32.
|
38 |
+
Generally, the result is the higher type of larger size than both
|
39 |
+
(if available). So: ::
|
40 |
+
|
41 |
+
int32 + float32 -> float64
|
42 |
+
uint32 + int32 -> int64
|
43 |
+
|
44 |
+
Finally, the type coercion behavior when expressions involve Python
|
45 |
+
scalars is different than that seen for arrays. Since Python has a
|
46 |
+
limited number of types, combining a Python int with a dtype=np.int8
|
47 |
+
array does not coerce to the higher type but instead, the type of the
|
48 |
+
array prevails. So the rules for Python scalars combined with arrays is
|
49 |
+
that the result will be that of the array equivalent the Python scalar
|
50 |
+
if the Python scalar is of a higher 'kind' than the array (e.g., float
|
51 |
+
vs. int), otherwise the resultant type will be that of the array.
|
52 |
+
For example: ::
|
53 |
+
|
54 |
+
Python int + int8 -> int8
|
55 |
+
Python float + int8 -> float64
|
56 |
+
|
57 |
+
ufunc methods
|
58 |
+
=============
|
59 |
+
|
60 |
+
Binary ufuncs support 4 methods.
|
61 |
+
|
62 |
+
**.reduce(arr)** applies the binary operator to elements of the array in
|
63 |
+
sequence. For example: ::
|
64 |
+
|
65 |
+
>>> np.add.reduce(np.arange(10)) # adds all elements of array
|
66 |
+
45
|
67 |
+
|
68 |
+
For multidimensional arrays, the first dimension is reduced by default: ::
|
69 |
+
|
70 |
+
>>> np.add.reduce(np.arange(10).reshape(2,5))
|
71 |
+
array([ 5, 7, 9, 11, 13])
|
72 |
+
|
73 |
+
The axis keyword can be used to specify different axes to reduce: ::
|
74 |
+
|
75 |
+
>>> np.add.reduce(np.arange(10).reshape(2,5),axis=1)
|
76 |
+
array([10, 35])
|
77 |
+
|
78 |
+
**.accumulate(arr)** applies the binary operator and generates an
|
79 |
+
equivalently shaped array that includes the accumulated amount for each
|
80 |
+
element of the array. A couple examples: ::
|
81 |
+
|
82 |
+
>>> np.add.accumulate(np.arange(10))
|
83 |
+
array([ 0, 1, 3, 6, 10, 15, 21, 28, 36, 45])
|
84 |
+
>>> np.multiply.accumulate(np.arange(1,9))
|
85 |
+
array([ 1, 2, 6, 24, 120, 720, 5040, 40320])
|
86 |
+
|
87 |
+
The behavior for multidimensional arrays is the same as for .reduce(),
|
88 |
+
as is the use of the axis keyword).
|
89 |
+
|
90 |
+
**.reduceat(arr,indices)** allows one to apply reduce to selected parts
|
91 |
+
of an array. It is a difficult method to understand. See the documentation
|
92 |
+
at:
|
93 |
+
|
94 |
+
**.outer(arr1,arr2)** generates an outer operation on the two arrays arr1 and
|
95 |
+
arr2. It will work on multidimensional arrays (the shape of the result is
|
96 |
+
the concatenation of the two input shapes.: ::
|
97 |
+
|
98 |
+
>>> np.multiply.outer(np.arange(3),np.arange(4))
|
99 |
+
array([[0, 0, 0, 0],
|
100 |
+
[0, 1, 2, 3],
|
101 |
+
[0, 2, 4, 6]])
|
102 |
+
|
103 |
+
Output arguments
|
104 |
+
================
|
105 |
+
|
106 |
+
All ufuncs accept an optional output array. The array must be of the expected
|
107 |
+
output shape. Beware that if the type of the output array is of a different
|
108 |
+
(and lower) type than the output result, the results may be silently truncated
|
109 |
+
or otherwise corrupted in the downcast to the lower type. This usage is useful
|
110 |
+
when one wants to avoid creating large temporary arrays and instead allows one
|
111 |
+
to reuse the same array memory repeatedly (at the expense of not being able to
|
112 |
+
use more convenient operator notation in expressions). Note that when the
|
113 |
+
output argument is used, the ufunc still returns a reference to the result.
|
114 |
+
|
115 |
+
>>> x = np.arange(2)
|
116 |
+
>>> np.add(np.arange(2),np.arange(2.),x)
|
117 |
+
array([0, 2])
|
118 |
+
>>> x
|
119 |
+
array([0, 2])
|
120 |
+
|
121 |
+
and & or as ufuncs
|
122 |
+
==================
|
123 |
+
|
124 |
+
Invariably people try to use the python 'and' and 'or' as logical operators
|
125 |
+
(and quite understandably). But these operators do not behave as normal
|
126 |
+
operators since Python treats these quite differently. They cannot be
|
127 |
+
overloaded with array equivalents. Thus using 'and' or 'or' with an array
|
128 |
+
results in an error. There are two alternatives:
|
129 |
+
|
130 |
+
1) use the ufunc functions logical_and() and logical_or().
|
131 |
+
2) use the bitwise operators & and \\|. The drawback of these is that if
|
132 |
+
the arguments to these operators are not boolean arrays, the result is
|
133 |
+
likely incorrect. On the other hand, most usages of logical_and and
|
134 |
+
logical_or are with boolean arrays. As long as one is careful, this is
|
135 |
+
a convenient way to apply these operators.
|
136 |
+
|
137 |
+
"""
|
venv/lib/python3.10/site-packages/numpy/f2py/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (5.36 kB). View file
|
|
venv/lib/python3.10/site-packages/numpy/f2py/__pycache__/__main__.cpython-310.pyc
ADDED
Binary file (232 Bytes). View file
|
|
venv/lib/python3.10/site-packages/numpy/f2py/__pycache__/__version__.cpython-310.pyc
ADDED
Binary file (226 Bytes). View file
|
|
venv/lib/python3.10/site-packages/numpy/f2py/__pycache__/_isocbind.cpython-310.pyc
ADDED
Binary file (1.58 kB). View file
|
|
venv/lib/python3.10/site-packages/numpy/f2py/__pycache__/_src_pyf.cpython-310.pyc
ADDED
Binary file (5.3 kB). View file
|
|
venv/lib/python3.10/site-packages/numpy/f2py/__pycache__/auxfuncs.cpython-310.pyc
ADDED
Binary file (25.3 kB). View file
|
|
venv/lib/python3.10/site-packages/numpy/f2py/__pycache__/capi_maps.cpython-310.pyc
ADDED
Binary file (18.5 kB). View file
|
|
venv/lib/python3.10/site-packages/numpy/f2py/__pycache__/cb_rules.cpython-310.pyc
ADDED
Binary file (18.1 kB). View file
|
|
venv/lib/python3.10/site-packages/numpy/f2py/__pycache__/cfuncs.cpython-310.pyc
ADDED
Binary file (45.2 kB). View file
|
|
venv/lib/python3.10/site-packages/numpy/f2py/__pycache__/common_rules.cpython-310.pyc
ADDED
Binary file (4.85 kB). View file
|
|
venv/lib/python3.10/site-packages/numpy/f2py/__pycache__/crackfortran.cpython-310.pyc
ADDED
Binary file (87.3 kB). View file
|
|
venv/lib/python3.10/site-packages/numpy/f2py/__pycache__/diagnose.cpython-310.pyc
ADDED
Binary file (3.83 kB). View file
|
|
venv/lib/python3.10/site-packages/numpy/f2py/__pycache__/f2py2e.cpython-310.pyc
ADDED
Binary file (22.7 kB). View file
|
|
venv/lib/python3.10/site-packages/numpy/f2py/__pycache__/f90mod_rules.cpython-310.pyc
ADDED
Binary file (7.23 kB). View file
|
|
venv/lib/python3.10/site-packages/numpy/f2py/__pycache__/func2subr.cpython-310.pyc
ADDED
Binary file (7.07 kB). View file
|
|
venv/lib/python3.10/site-packages/numpy/f2py/__pycache__/rules.cpython-310.pyc
ADDED
Binary file (38.4 kB). View file
|
|
venv/lib/python3.10/site-packages/numpy/f2py/__pycache__/setup.cpython-310.pyc
ADDED
Binary file (2.35 kB). View file
|
|
venv/lib/python3.10/site-packages/numpy/f2py/__pycache__/symbolic.cpython-310.pyc
ADDED
Binary file (38.9 kB). View file
|
|
venv/lib/python3.10/site-packages/numpy/f2py/__pycache__/use_rules.cpython-310.pyc
ADDED
Binary file (3.02 kB). View file
|
|
venv/lib/python3.10/site-packages/numpy/f2py/tests/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (184 Bytes). View file
|
|
venv/lib/python3.10/site-packages/numpy/f2py/tests/__pycache__/test_abstract_interface.cpython-310.pyc
ADDED
Binary file (1.39 kB). View file
|
|
venv/lib/python3.10/site-packages/numpy/f2py/tests/__pycache__/test_array_from_pyobj.cpython-310.pyc
ADDED
Binary file (20.2 kB). View file
|
|
venv/lib/python3.10/site-packages/numpy/f2py/tests/__pycache__/test_assumed_shape.cpython-310.pyc
ADDED
Binary file (1.86 kB). View file
|
|
venv/lib/python3.10/site-packages/numpy/f2py/tests/__pycache__/test_block_docstring.cpython-310.pyc
ADDED
Binary file (1 kB). View file
|
|
venv/lib/python3.10/site-packages/numpy/f2py/tests/__pycache__/test_callback.cpython-310.pyc
ADDED
Binary file (8.89 kB). View file
|
|