proxsuite
0.7.3
The Advanced Proximal Optimization Toolbox
Toggle main menu visibility
Loading...
Searching...
No Matches
__init__.py
Go to the documentation of this file.
1
"""
2
Copyright (c) 2022-2025, INRIA
3
"""
4
5
import
numpy
# noqa F401 for OpenMP proper linkage
6
from
typing
import
TYPE_CHECKING
7
8
if
TYPE_CHECKING:
9
from
.proxsuite_pywrap
import
*
# noqa F403
10
11
12
def
_load_main_module
():
13
import
platform
14
import
importlib
15
16
machine = platform.machine()
17
has_vectorization_instructions =
not
machine.startswith(
18
(
"arm"
,
"aarch64"
,
"power"
,
"ppc64"
,
"s390x"
,
"sparc"
)
19
)
20
21
def
load_module(main_module_name):
22
try
:
23
return
importlib.import_module(
"."
+ main_module_name, __name__)
24
except
ModuleNotFoundError:
25
return
False
26
27
if
has_vectorization_instructions:
# noqa
28
from
.
import
instructionset
29
30
all_modules = [
31
(
"proxsuite_pywrap_avx512"
, instructionset.has_AVX512F),
32
(
"proxsuite_pywrap_avx2"
, instructionset.has_AVX2),
33
]
34
35
for
module_name, checker
in
all_modules:
36
if
checker()
and
(mod := load_module(module_name)):
37
return
mod
38
39
return
load_module(
"proxsuite_pywrap"
)
40
41
42
_submodule =
_load_main_module
()
43
44
45
def
__getattr__
(name: str):
46
# reroute proxsuite module's attributes to be that of the loaded submodule.
47
return
getattr(_submodule, name)
48
49
50
def
__dir__
():
51
# returns iterable of all accessible attributes in the module.
52
# implement this for instropection, for e.g. autocomplete in interpreters (IPython).
53
# We return the attributes from the submodule.
54
return
dir(_submodule)
proxsuite.__getattr__
__getattr__(str name)
Definition
__init__.py:45
proxsuite.__dir__
__dir__()
Definition
__init__.py:50
proxsuite._load_main_module
_load_main_module()
Definition
__init__.py:12
bindings
python
proxsuite
__init__.py
Generated by
1.17.0