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
239 lines (198 loc) · 4.37 KB
/
Copy path__init__.py
File metadata and controls
239 lines (198 loc) · 4.37 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
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
import os
from enum import Enum, auto
from ctypes import cdll
from llvmlite import binding
import platform
import pytest
# This is the source of truth for version
# https://packaging.python.org/guides/single-sourcing-package-version/
__version__ = "1.0.0-$IA_BUILD_VER"
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 Codec(Enum):
"""
Available codecs.
"""
BLOSCLZ = 0
LZ4 = 1
LZ4HC = 2
ZLIB = 4
ZSTD = 5
LIZARD = 6
# Filter
class Filter(Enum):
"""
Available filters.
"""
NOFILTER = 0
SHUFFLE = 1
BITSHUFFLE = 2
DELTA = 4
TRUNC_PREC = 8
# Favor. Select to favor compression speed, compression ratio or a balance between them.
class Favor(Enum):
"""
Which computer resource to be favored.
"""
BALANCE = 0
SPEED = 1
CRATIO = 2
# Split mode
class SplitMode(Enum):
"""
Available split modes.
"""
ALWAYS_SPLIT = 1
NEVER_SPLIT = 2
AUTO_SPLIT = 3
FORWARD_COMPAT_SPLIT = 4
# Random generators
class RandomGen(Enum):
"""
Available random generators.
"""
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):
"""
Available reduction operations.
"""
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,
Store,
set_config_defaults,
get_config_defaults,
config,
reset_config_defaults,
get_ncores,
partition_advice,
defaults as _defaults,
)
from .iarray_container import (
IArray,
matmul_params,
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,
_check_path_mode,
remove_urlpath,
)
# random constructors (follow NumPy convention)
from . import random
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()
from . import tests
def test():
retcode = pytest.main(["-x", os.path.dirname(tests.__file__)])
return retcode