forked from inaos/iron-array-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
187 lines (160 loc) · 3.58 KB
/
Copy path__init__.py
File metadata and controls
187 lines (160 loc) · 3.58 KB
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
import os
from enum import Enum, auto
from ctypes import cdll
from llvmlite import binding
import platform
# This is the source of truth for version
# https://packaging.python.org/guides/single-sourcing-package-version/
__version__ = "1.0.0-beta.1"
binding.initialize()
binding.initialize_native_target()
binding.initialize_native_asmprinter()
install_dir = os.path.dirname(__file__)
platform_system = platform.system()
if platform_system == "Linux":
# Force the load of shared libs with no need to mess with LD_LIBRARY_PATH
# https://stackoverflow.com/questions/6543847/setting-ld-library-path-from-inside-python
# We can disable this when/if we can package iron-array into its own wheel
# and make a dependency of it. The same goes for other platforms.
try:
binding.load_library_permanently("libintlc.so.5")
binding.load_library_permanently("libsvml.so")
except RuntimeError:
# Runtime libraries are not in the path. Probably we are running from wheels,
# and wheels ensure than libraries are in the same directory than this file.
binding.load_library_permanently(os.path.join(install_dir, "libintlc.so.5"))
binding.load_library_permanently(os.path.join(install_dir, "libsvml.so"))
lib0 = cdll.LoadLibrary(os.path.join(install_dir, "libiarray.so"))
elif platform_system == "Darwin":
binding.load_library_permanently("libsvml.dylib")
lib0 = cdll.LoadLibrary(os.path.join(install_dir, "libiarray.dylib"))
else:
binding.load_library_permanently(os.path.join(install_dir, "svml_dispmd.dll"))
lib1 = cdll.LoadLibrary(os.path.join(install_dir, "iarray.dll"))
# Compression codecs
class Codecs(Enum):
BLOSCLZ = 0
LZ4 = 1
LZ4HC = 2
ZLIB = 4
ZSTD = 5
LIZARD = 6
# Filters
class Filters(Enum):
NOFILTER = 0
SHUFFLE = 1
BITSHUFFLE = 2
DELTA = 4
TRUNC_PREC = 8
# Random generators
class RandomGen(Enum):
MERSENNE_TWISTER = 0
SOBOL = 1
# Eval method
class Eval(Enum):
"""
Available eval methods
"""
AUTO = auto()
ITERBLOSC = auto() # Iterblosc method
ITERCHUNK = auto() # Iterchunk method
class Reduce(Enum):
MAX = 0
MIN = 1
SUM = 2
PROD = 3
MEAN = 4
# List of all know universal functions
UFUNC_LIST = (
"abs",
"arccos",
"arcsin",
"arctan",
"arctan2",
"ceil",
"cos",
"cosh",
"exp",
"floor",
"log",
"log10",
"negative",
"power",
"sin",
"sinh",
"sqrt",
"tan",
"tanh",
)
# That must come here so as to avoid circular import errors
from .config_params import (
Config,
Storage,
set_config,
get_config,
config,
reset_config_defaults,
get_ncores,
partition_advice,
)
from .iarray_container import (
IArray,
matmul,
transpose,
# reductions
max,
min,
sum,
prod,
mean,
# ufuncs
abs,
arccos,
arcsin,
arctan,
arctan2,
ceil,
cos,
cosh,
exp,
floor,
log,
log10,
negative,
power,
sin,
sinh,
sqrt,
tan,
tanh,
)
from .constructors import (
DTShape,
empty,
arange,
linspace,
zeros,
ones,
full,
)
from .utils import (
load,
open,
save,
cmp_arrays,
iarray2numpy,
numpy2iarray,
)
# random constructors (follow NumPy convention)
from . import irandom
from .expression import (
Expr,
expr_from_string,
expr_from_udf,
)
from .lazy_expr import (
LazyExpr,
)
# For some reason this needs to go to the end, else matmul function does not work.
from . import iarray_ext as ext
ext.IArrayInit()