imops 0.8.2__cp37-cp37m-win_amd64.whl → 0.8.3__cp37-cp37m-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of imops might be problematic. Click here for more details.
- _build_utils.py +87 -0
- imops/__init__.py +1 -0
- imops/__version__.py +1 -1
- imops/backend.py +14 -10
- imops/crop.py +18 -2
- imops/interp1d.py +7 -4
- imops/measure.py +7 -7
- imops/morphology.py +6 -5
- imops/numeric.py +376 -0
- imops/pad.py +41 -5
- imops/radon.py +7 -5
- imops/src/_backprojection.c +83 -83
- imops/src/_backprojection.cp37-win_amd64.pyd +0 -0
- imops/src/_fast_backprojection.c +98 -98
- imops/src/_fast_backprojection.cp37-win_amd64.pyd +0 -0
- imops/src/_fast_measure.c +98 -98
- imops/src/_fast_measure.cp37-win_amd64.pyd +0 -0
- imops/src/_fast_morphology.c +98 -98
- imops/src/_fast_morphology.cp37-win_amd64.pyd +0 -0
- imops/src/_fast_numeric.c +20547 -4998
- imops/src/_fast_numeric.cp37-win_amd64.pyd +0 -0
- imops/src/_fast_numeric.pyx +208 -30
- imops/src/_fast_radon.c +98 -98
- imops/src/_fast_radon.cp37-win_amd64.pyd +0 -0
- imops/src/_fast_zoom.c +98 -98
- imops/src/_fast_zoom.cp37-win_amd64.pyd +0 -0
- imops/src/_measure.c +83 -83
- imops/src/_measure.cp37-win_amd64.pyd +0 -0
- imops/src/_morphology.c +83 -83
- imops/src/_morphology.cp37-win_amd64.pyd +0 -0
- imops/src/_numeric.c +20532 -4983
- imops/src/_numeric.cp37-win_amd64.pyd +0 -0
- imops/src/_numeric.pyx +208 -30
- imops/src/_radon.c +83 -83
- imops/src/_radon.cp37-win_amd64.pyd +0 -0
- imops/src/_zoom.c +83 -83
- imops/src/_zoom.cp37-win_amd64.pyd +0 -0
- imops/utils.py +65 -12
- imops/zoom.py +2 -2
- {imops-0.8.2.dist-info → imops-0.8.3.dist-info}/METADATA +3 -2
- imops-0.8.3.dist-info/RECORD +60 -0
- {imops-0.8.2.dist-info → imops-0.8.3.dist-info}/WHEEL +1 -1
- imops-0.8.3.dist-info/top_level.txt +2 -0
- _pyproject_build.py +0 -61
- imops/_numeric.py +0 -124
- imops-0.8.2.dist-info/RECORD +0 -60
- imops-0.8.2.dist-info/top_level.txt +0 -2
- {imops-0.8.2.dist-info → imops-0.8.3.dist-info}/LICENSE +0 -0
|
Binary file
|
imops/utils.py
CHANGED
|
@@ -1,39 +1,92 @@
|
|
|
1
1
|
import os
|
|
2
|
+
from contextlib import contextmanager
|
|
2
3
|
from itertools import permutations
|
|
3
4
|
from typing import Callable, Optional, Sequence, Tuple, Union
|
|
4
5
|
from warnings import warn
|
|
5
6
|
|
|
6
7
|
import numpy as np
|
|
7
8
|
|
|
8
|
-
from .backend import
|
|
9
|
+
from .backend import BACKEND_NAME2ENV_NUM_THREADS_VAR_NAME, SINGLE_THREADED_BACKENDS, Backend
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
AxesLike = Union[int, Sequence[int]]
|
|
12
13
|
AxesParams = Union[float, Sequence[float]]
|
|
13
14
|
|
|
14
15
|
ZOOM_SRC_DIM = 4
|
|
16
|
+
# TODO: define imops-specific environment variable like `OMP_NUM_THREADS`?
|
|
17
|
+
IMOPS_NUM_THREADS = None
|
|
15
18
|
|
|
16
19
|
|
|
17
|
-
def
|
|
20
|
+
def set_num_threads(num_threads: int) -> int:
|
|
21
|
+
assert isinstance(num_threads, int) or num_threads is None, 'Number of threads must be int value or None.'
|
|
22
|
+
global IMOPS_NUM_THREADS
|
|
23
|
+
current = IMOPS_NUM_THREADS
|
|
24
|
+
IMOPS_NUM_THREADS = num_threads
|
|
25
|
+
return current
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@contextmanager
|
|
29
|
+
def imops_num_threads(num_threads: int):
|
|
30
|
+
previous = set_num_threads(num_threads)
|
|
31
|
+
try:
|
|
32
|
+
yield
|
|
33
|
+
finally:
|
|
34
|
+
set_num_threads(previous)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def normalize_num_threads(num_threads: int, backend: Backend, warn_stacklevel: int = 1) -> int:
|
|
38
|
+
"""Calculate the effective number of threads"""
|
|
39
|
+
|
|
40
|
+
global IMOPS_NUM_THREADS
|
|
18
41
|
if backend.name in SINGLE_THREADED_BACKENDS:
|
|
19
42
|
if num_threads != -1:
|
|
20
|
-
warn(
|
|
43
|
+
warn(
|
|
44
|
+
f'"{backend.name}" backend is single-threaded. Setting `num_threads` has no effect.',
|
|
45
|
+
stacklevel=warn_stacklevel,
|
|
46
|
+
)
|
|
21
47
|
return 1
|
|
48
|
+
|
|
49
|
+
env_num_threads_var_name = BACKEND_NAME2ENV_NUM_THREADS_VAR_NAME[backend.name]
|
|
50
|
+
# here we also handle the case `env_num_threads_var_name`=" " gracefully
|
|
51
|
+
env_num_threads = os.environ.get(env_num_threads_var_name, '').strip()
|
|
52
|
+
env_num_threads = int(env_num_threads) if env_num_threads else None
|
|
53
|
+
# TODO: maybe let user set the absolute maximum number of threads?
|
|
54
|
+
num_available_cpus = len(os.sched_getaffinity(0))
|
|
55
|
+
|
|
56
|
+
max_num_threads = min(filter(bool, [IMOPS_NUM_THREADS, env_num_threads, num_available_cpus]))
|
|
57
|
+
|
|
22
58
|
if num_threads >= 0:
|
|
23
59
|
# FIXME
|
|
24
60
|
if backend.name == 'Numba':
|
|
25
61
|
warn(
|
|
26
62
|
'Setting `num_threads` has no effect with "Numba" backend. '
|
|
27
|
-
'Use `NUMBA_NUM_THREADS` environment variable.'
|
|
63
|
+
'Use `NUMBA_NUM_THREADS` environment variable.',
|
|
64
|
+
stacklevel=warn_stacklevel,
|
|
28
65
|
)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
66
|
+
return num_threads
|
|
67
|
+
|
|
68
|
+
if num_threads > max_num_threads:
|
|
69
|
+
if max_num_threads == IMOPS_NUM_THREADS:
|
|
70
|
+
warn(
|
|
71
|
+
f'Required number of threads ({num_threads}) is greater than `IMOPS_NUM_THREADS` '
|
|
72
|
+
f'({IMOPS_NUM_THREADS}). Using {IMOPS_NUM_THREADS} threads.',
|
|
73
|
+
stacklevel=warn_stacklevel,
|
|
74
|
+
)
|
|
75
|
+
elif max_num_threads == env_num_threads:
|
|
76
|
+
warn(
|
|
77
|
+
f'Required number of threads ({num_threads}) is greater than `{env_num_threads_var_name}` '
|
|
78
|
+
f'({env_num_threads}). Using {env_num_threads} threads.',
|
|
79
|
+
stacklevel=warn_stacklevel,
|
|
80
|
+
)
|
|
81
|
+
else:
|
|
82
|
+
warn(
|
|
83
|
+
f'Required number of threads ({num_threads}) is greater than number of available CPU-s '
|
|
84
|
+
f'({num_available_cpus}). Using {num_available_cpus} threads.',
|
|
85
|
+
stacklevel=warn_stacklevel,
|
|
86
|
+
)
|
|
87
|
+
return min(num_threads, max_num_threads)
|
|
88
|
+
|
|
89
|
+
return max_num_threads + num_threads + 1
|
|
37
90
|
|
|
38
91
|
|
|
39
92
|
def get_c_contiguous_permutaion(array: np.ndarray) -> Optional[np.ndarray]:
|
imops/zoom.py
CHANGED
|
@@ -208,7 +208,7 @@ def _zoom(
|
|
|
208
208
|
|
|
209
209
|
See `https://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.zoom.html`
|
|
210
210
|
"""
|
|
211
|
-
backend = resolve_backend(backend)
|
|
211
|
+
backend = resolve_backend(backend, warn_stacklevel=4)
|
|
212
212
|
if backend.name not in ('Scipy', 'Numba', 'Cython'):
|
|
213
213
|
raise ValueError(f'Unsupported backend "{backend.name}".')
|
|
214
214
|
|
|
@@ -216,7 +216,7 @@ def _zoom(
|
|
|
216
216
|
dtype = input.dtype
|
|
217
217
|
cval = np.dtype(dtype).type(cval)
|
|
218
218
|
zoom = fill_by_indices(np.ones(input.ndim, 'float64'), zoom, range(input.ndim))
|
|
219
|
-
num_threads = normalize_num_threads(num_threads, backend)
|
|
219
|
+
num_threads = normalize_num_threads(num_threads, backend, warn_stacklevel=4)
|
|
220
220
|
|
|
221
221
|
if backend.name == 'Scipy':
|
|
222
222
|
return scipy_zoom(
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: imops
|
|
3
|
-
Version: 0.8.
|
|
3
|
+
Version: 0.8.3
|
|
4
4
|
Summary: Efficient parallelizable algorithms for multidimensional arrays to speed up your data pipelines
|
|
5
5
|
Home-page: https://github.com/neuro-ml/imops
|
|
6
|
-
Download-URL: https://github.com/neuro-ml/imops/archive/v0.8.
|
|
6
|
+
Download-URL: https://github.com/neuro-ml/imops/archive/v0.8.3.tar.gz
|
|
7
7
|
Author: maxme1, vovaf709, talgat
|
|
8
8
|
Author-email: maxme1 <maxs987@gmail.com>, vovaf709 <vovaf709@yandex.ru>, talgat <saparov2130@gmail.com>
|
|
9
9
|
License: MIT License
|
|
@@ -45,6 +45,7 @@ Requires-Python: >=3.6
|
|
|
45
45
|
Description-Content-Type: text/markdown
|
|
46
46
|
License-File: LICENSE
|
|
47
47
|
Requires-Dist: scipy <2.0.0,>=1.0
|
|
48
|
+
Requires-Dist: scikit-image
|
|
48
49
|
Requires-Dist: connected-components-3d
|
|
49
50
|
Requires-Dist: fastremap
|
|
50
51
|
Requires-Dist: dataclasses ; python_version < "3.7"
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
_build_utils.py,sha256=bxDoFEVfZgjl-yxMv5a-A7jncCD362m4RTpn5SyRgB4,3262
|
|
2
|
+
imops/__init__.py,sha256=QAqK6FnQnOjdDwSXzhnJNB2ur3cGUNbP3ZdLc_VoIEY,514
|
|
3
|
+
imops/__version__.py,sha256=lPOlZg8rjdgN8DyBl7I1rkzxiXOhafW_7RzlMGnvNo8,23
|
|
4
|
+
imops/_configs.py,sha256=6hBY2O4YSaQC_avvqI-dmhZkPMl4p39KQIPtqx5MAh0,734
|
|
5
|
+
imops/backend.py,sha256=8x6Zq9hetOt9_RDcytNNBJZBLNXgQd7ob2dh4WQuuqM,2598
|
|
6
|
+
imops/box.py,sha256=NbYsPKQ8fCGxSm5up0TyqERJ-5iWmnzHLo4Smv9eesk,1865
|
|
7
|
+
imops/crop.py,sha256=hCgwxDgNdIo9m0gleMB3oOUNA7tQurhYNhE5S39tMlE,4055
|
|
8
|
+
imops/interp1d.py,sha256=CSPJ77isqGOJTN-_C--iyz-3qJhpL4dE9i5VdJgSFDE,8400
|
|
9
|
+
imops/measure.py,sha256=YJ5hBDH6iW1hgqm6fi6FIURBKmeZjVfr7LSINOHgFrM,8657
|
|
10
|
+
imops/morphology.py,sha256=KG3RCCicsX7WHsBj4mH6iaJ0dy6tW9cGJJvD4fDisBQ,12723
|
|
11
|
+
imops/numeric.py,sha256=yiSjPTUD2w177LOBD_39_BHh9n8uKbSsHJDchNVsKRY,13650
|
|
12
|
+
imops/pad.py,sha256=OXy_r4X7hOPBU4NSH3B-8ZpxfcY1t6FFMgMSopULpv8,9314
|
|
13
|
+
imops/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
|
+
imops/radon.py,sha256=TWsgZvWRapBbU7MVr1fRdpVXCvi6-kt8fxroyQc44ek,9211
|
|
15
|
+
imops/testing.py,sha256=Qiy_Qn7bd7MIXoaZr4T_6r0jQWVRJFwR2z12c_Zwt30,1708
|
|
16
|
+
imops/utils.py,sha256=nfrMUU0OhPgK5UapD9GNC1StPxX3cKbob54kiuf4_qs,6890
|
|
17
|
+
imops/zoom.py,sha256=wl8wt7yoX5V4Mn7sMefV1Fy9KEetqMEdRHLdhT90o6o,9955
|
|
18
|
+
imops/src/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
19
|
+
imops/src/_backprojection.c,sha256=pq-WMMTwAzP0sRV-nlq_kw3u-1153p7XOHNcJCeE7Ak,1025929
|
|
20
|
+
imops/src/_backprojection.cp37-win_amd64.pyd,sha256=n8oH5kQTnAs-ls8dx8kmfwXIYNVMhF8qw8lVS-SV7mw,168960
|
|
21
|
+
imops/src/_backprojection.pyx,sha256=xngEJtJ6czjoBRBKL6tu5S7nt6ZgcsE82xDGdCIfagE,2724
|
|
22
|
+
imops/src/_fast_backprojection.c,sha256=uYYu_sctyj1JFLgzyBJXbf_zRx8Jom5aQ1VjFPJqagw,1036125
|
|
23
|
+
imops/src/_fast_backprojection.cp37-win_amd64.pyd,sha256=f_JWJv8qqONOP3Cex1wYE7757zw0u3UjhDdZJ082ebI,169984
|
|
24
|
+
imops/src/_fast_backprojection.pyx,sha256=xngEJtJ6czjoBRBKL6tu5S7nt6ZgcsE82xDGdCIfagE,2724
|
|
25
|
+
imops/src/_fast_measure.c,sha256=E6jzvgrBEgt-EgEzs9dv9Xv_1wS7iRMi9VsL9MH22Wc,1336403
|
|
26
|
+
imops/src/_fast_measure.cp37-win_amd64.pyd,sha256=W5P8jpd6kpNmSgOZhCGxDQDoWi4rKWTkuBijVnSSrko,250880
|
|
27
|
+
imops/src/_fast_measure.pyx,sha256=JzZ26PptkVT08OemSFaJakc4jf7xYocPqV8jfrYi_wA,2737
|
|
28
|
+
imops/src/_fast_morphology.c,sha256=VvbbltXUcddHVD2-BffBIV4-1My8I8cW3KkPMrP_PJQ,971646
|
|
29
|
+
imops/src/_fast_morphology.cp37-win_amd64.pyd,sha256=pbBdEaoLMh63bAMc4fvAmOO0Ik_s41yRfBQF9AB4pBg,139264
|
|
30
|
+
imops/src/_fast_morphology.pyx,sha256=QwFrPQ6M-bJDVQNCCtKK7FR3KOr5cZSx_CBvxh9THXM,9538
|
|
31
|
+
imops/src/_fast_numeric.c,sha256=w7CribnwLfd4coHROWKbN6peo8p8Lvd8qJAvWILWeNM,2107182
|
|
32
|
+
imops/src/_fast_numeric.cp37-win_amd64.pyd,sha256=VEo2cvWMp2MUQa-ANFaDDk9vMC01YD4HZuOz3F_FtKw,389632
|
|
33
|
+
imops/src/_fast_numeric.pyx,sha256=c8q3KlL8mDe0wsz72ooeqhffk1iqvA0Org7NWW5RbYo,8221
|
|
34
|
+
imops/src/_fast_radon.c,sha256=xjOPo7R-zC6hw051wNo5loN5LD_kACs0c0XENpU7pS4,1190116
|
|
35
|
+
imops/src/_fast_radon.cp37-win_amd64.pyd,sha256=mFRBaUhy4wXTshW6iNWgASFcgYSEa89GteThl6LWzxM,221696
|
|
36
|
+
imops/src/_fast_radon.pyx,sha256=pu8EZplCjIDz9HqBcAit8nj2lDgXpmdhU61_4CfdGWI,2987
|
|
37
|
+
imops/src/_fast_zoom.c,sha256=U-iqHZ-ny09OiBvY1bF0vqXgmj5cwmi5wz54w9DQCPY,2145110
|
|
38
|
+
imops/src/_fast_zoom.cp37-win_amd64.pyd,sha256=-0qT2Q8UDzKOvEwIb1ZlCEVJvh2cpw851ixkxlbeQNo,387584
|
|
39
|
+
imops/src/_fast_zoom.pyx,sha256=Dd5MDelALAh4-3QhnzfzKTB5Gmi2lVERrbyYj-q8kVQ,23091
|
|
40
|
+
imops/src/_measure.c,sha256=u3o9ozqfWnrn0PxRrY5l7LEvZEEzkfj4JMuTn0MKcSw,1324916
|
|
41
|
+
imops/src/_measure.cp37-win_amd64.pyd,sha256=eAP2pLYz4w0f3ucBP1fyijF2M5YbKdBvzLbioPppcao,250368
|
|
42
|
+
imops/src/_measure.pyx,sha256=JzZ26PptkVT08OemSFaJakc4jf7xYocPqV8jfrYi_wA,2737
|
|
43
|
+
imops/src/_morphology.c,sha256=ntlYexi4kFK85mMvUkWSlKMf-Fwix05M18NvVEVyYAQ,960908
|
|
44
|
+
imops/src/_morphology.cp37-win_amd64.pyd,sha256=jh1C3dkTAMfpwkUiwm8GjEpAn_65qmqqyfQPv0RSySQ,138752
|
|
45
|
+
imops/src/_morphology.pyx,sha256=QwFrPQ6M-bJDVQNCCtKK7FR3KOr5cZSx_CBvxh9THXM,9538
|
|
46
|
+
imops/src/_numba_zoom.py,sha256=OmMj7mCFkV2P0FaWVXFuYpfzMBQ3Ks60YiHQURes5wQ,16857
|
|
47
|
+
imops/src/_numeric.c,sha256=pxoAtM5-ZGaBVyWd8HBARI7_LnX6_n7kNt6vS1p_JmI,2091727
|
|
48
|
+
imops/src/_numeric.cp37-win_amd64.pyd,sha256=1x6HG1ybTbI88WOulH9yUjNsckbRGALQioda-MQLybo,388608
|
|
49
|
+
imops/src/_numeric.pyx,sha256=c8q3KlL8mDe0wsz72ooeqhffk1iqvA0Org7NWW5RbYo,8221
|
|
50
|
+
imops/src/_radon.c,sha256=TdmwLBra4NsH9qtX--0OC6XaTfzN8ApZxDovOC3J9kU,1178982
|
|
51
|
+
imops/src/_radon.cp37-win_amd64.pyd,sha256=5WT-xsTQghWhUSEbqigEqMlescGIyD6hCa7KvfhFhIk,220160
|
|
52
|
+
imops/src/_radon.pyx,sha256=pu8EZplCjIDz9HqBcAit8nj2lDgXpmdhU61_4CfdGWI,2987
|
|
53
|
+
imops/src/_zoom.c,sha256=Yli60QHVVNFUJ2ycnbEW_Hbnz15-tRcG_J_xg_rCL4U,2126517
|
|
54
|
+
imops/src/_zoom.cp37-win_amd64.pyd,sha256=er_Pl1OnxOfHr-HAq91DtI7kG6WYlUzH1Z-qajMYWU8,387072
|
|
55
|
+
imops/src/_zoom.pyx,sha256=Dd5MDelALAh4-3QhnzfzKTB5Gmi2lVERrbyYj-q8kVQ,23091
|
|
56
|
+
imops-0.8.3.dist-info/LICENSE,sha256=x7oyYZPKDTt8KoTitcNJLBWhueke5YEOopdr0XjyvBc,1085
|
|
57
|
+
imops-0.8.3.dist-info/METADATA,sha256=tDl7xwD4lJ6Yx_X7wYRKFuv-_QmBlXMHivDQCOnT_K8,9048
|
|
58
|
+
imops-0.8.3.dist-info/WHEEL,sha256=P6MkoxfArCDjH_Cd27qF5eFfOSJbz6XgNmPOs7M04KU,101
|
|
59
|
+
imops-0.8.3.dist-info/top_level.txt,sha256=jd2uO-zsYvKeqkZbjEjtkGqCca0IEXEiEuoyr3nsHB0,19
|
|
60
|
+
imops-0.8.3.dist-info/RECORD,,
|
_pyproject_build.py
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import shutil
|
|
2
|
-
from pathlib import Path
|
|
3
|
-
|
|
4
|
-
from setuptools import Extension
|
|
5
|
-
from setuptools.command.build_py import build_py
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class NumpyImport(dict):
|
|
9
|
-
"""Hacky way to return Numpy's include path with lazy import."""
|
|
10
|
-
|
|
11
|
-
# Must be json-serializable due to
|
|
12
|
-
# https://github.com/cython/cython/blob/6ad6ca0e9e7d030354b7fe7d7b56c3f6e6a4bc23/Cython/Compiler/ModuleNode.py#L773
|
|
13
|
-
def __init__(self):
|
|
14
|
-
return super().__init__(self, description=self.__doc__)
|
|
15
|
-
|
|
16
|
-
# Must be hashable due to
|
|
17
|
-
# https://github.com/cython/cython/blob/6ad6ca0e9e7d030354b7fe7d7b56c3f6e6a4bc23/Cython/Compiler/Main.py#L307
|
|
18
|
-
def __hash__(self):
|
|
19
|
-
return id(self)
|
|
20
|
-
|
|
21
|
-
def __repr__(self):
|
|
22
|
-
import numpy as np
|
|
23
|
-
|
|
24
|
-
return np.get_include()
|
|
25
|
-
|
|
26
|
-
__fspath__ = __repr__
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
class PyprojectBuild(build_py):
|
|
30
|
-
def run(self):
|
|
31
|
-
self.run_command('build_ext')
|
|
32
|
-
return super().run()
|
|
33
|
-
|
|
34
|
-
def initialize_options(self):
|
|
35
|
-
super().initialize_options()
|
|
36
|
-
|
|
37
|
-
name = 'imops'
|
|
38
|
-
args = ['-fopenmp']
|
|
39
|
-
|
|
40
|
-
if self.distribution.ext_modules is None:
|
|
41
|
-
self.distribution.ext_modules = []
|
|
42
|
-
|
|
43
|
-
# Cython extension and .pyx source file names must be the same to compile
|
|
44
|
-
# https://stackoverflow.com/questions/8024805/cython-compiled-c-extension-importerror-dynamic-module-does-not-define-init-fu
|
|
45
|
-
modules = ['backprojection', 'measure', 'morphology', 'numeric', 'radon', 'zoom']
|
|
46
|
-
for module in modules:
|
|
47
|
-
src_dir = Path(__file__).parent / name / 'src'
|
|
48
|
-
shutil.copyfile(src_dir / f'_{module}.pyx', src_dir / f'_fast_{module}.pyx')
|
|
49
|
-
|
|
50
|
-
for module in modules:
|
|
51
|
-
for prefix, additional_args in zip(['', 'fast_'], [[], ['-ffast-math']]):
|
|
52
|
-
self.distribution.ext_modules.append(
|
|
53
|
-
Extension(
|
|
54
|
-
f'{name}.src._{prefix}{module}',
|
|
55
|
-
[f'{name}/src/_{prefix}{module}.pyx'],
|
|
56
|
-
include_dirs=[NumpyImport()],
|
|
57
|
-
extra_compile_args=args + additional_args,
|
|
58
|
-
extra_link_args=args + additional_args,
|
|
59
|
-
define_macros=[('NPY_NO_DEPRECATED_API', 'NPY_1_7_API_VERSION')],
|
|
60
|
-
)
|
|
61
|
-
)
|
imops/_numeric.py
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
from warnings import warn
|
|
2
|
-
|
|
3
|
-
import numpy as np
|
|
4
|
-
|
|
5
|
-
from .backend import BackendLike, resolve_backend
|
|
6
|
-
from .src._fast_numeric import (
|
|
7
|
-
_parallel_pointwise_mul as cython_fast_parallel_pointwise_mul,
|
|
8
|
-
_parallel_sum as cython_fast_parallel_sum,
|
|
9
|
-
)
|
|
10
|
-
from .src._numeric import _parallel_pointwise_mul as cython_parallel_pointwise_mul, _parallel_sum as cython_parallel_sum
|
|
11
|
-
from .utils import normalize_num_threads
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
def _sum(nums: np.ndarray, num_threads: int = -1, backend: BackendLike = None) -> float:
|
|
15
|
-
"""
|
|
16
|
-
Parallel sum of flat numpy array
|
|
17
|
-
|
|
18
|
-
Parameters
|
|
19
|
-
----------
|
|
20
|
-
nums: np.ndarray
|
|
21
|
-
1-dimensional array
|
|
22
|
-
num_threads: int
|
|
23
|
-
the number of threads to use for computation. Default = the cpu count. If negative value passed
|
|
24
|
-
cpu count + num_threads + 1 threads will be used
|
|
25
|
-
backend: BackendLike
|
|
26
|
-
which backend to use. `cython` and `scipy` (primarly for benchmarking) are available,
|
|
27
|
-
`cython` is used by default
|
|
28
|
-
|
|
29
|
-
Returns
|
|
30
|
-
-------
|
|
31
|
-
sum: float
|
|
32
|
-
|
|
33
|
-
Examples
|
|
34
|
-
--------
|
|
35
|
-
>>> s = _sum(x, num_threads=1)
|
|
36
|
-
>>> s = _sum(x, num_threads=8, backend=Cython(fast=True)) # ffast-math compiled version
|
|
37
|
-
"""
|
|
38
|
-
ndim = nums.ndim
|
|
39
|
-
|
|
40
|
-
if ndim != 1:
|
|
41
|
-
raise ValueError(f'Input must be 1-dimensional instead of {ndim}-dimensional.')
|
|
42
|
-
|
|
43
|
-
backend = resolve_backend(backend)
|
|
44
|
-
if backend.name not in ('Cython', 'Scipy'):
|
|
45
|
-
raise ValueError(f'Unsupported backend "{backend.name}"')
|
|
46
|
-
|
|
47
|
-
num_threads = normalize_num_threads(num_threads, backend)
|
|
48
|
-
|
|
49
|
-
if backend.name == 'Scipy':
|
|
50
|
-
return nums.sum()
|
|
51
|
-
|
|
52
|
-
if backend.name == 'Cython':
|
|
53
|
-
src_parallel_sum = cython_fast_parallel_sum if backend.fast else cython_parallel_sum
|
|
54
|
-
|
|
55
|
-
return src_parallel_sum(nums, num_threads)
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
def _mul(nums1: np.ndarray, nums2: np.ndarray, num_threads: int = -1, backend: BackendLike = None) -> np.ndarray:
|
|
59
|
-
"""
|
|
60
|
-
Parallel pointwise multiplication of 2 numpy arrays (aka x * y). Works faster only for ndim <= 3.
|
|
61
|
-
|
|
62
|
-
Parameters
|
|
63
|
-
----------
|
|
64
|
-
nums1: np.ndarray
|
|
65
|
-
nums2: np.ndarray
|
|
66
|
-
num_threads: int
|
|
67
|
-
the number of threads to use for computation. Default = the cpu count. If negative value passed
|
|
68
|
-
cpu count + num_threads + 1 threads will be used
|
|
69
|
-
backend: BackendLike
|
|
70
|
-
which backend to use. `cython` and `scipy` (primarly for benchmarking) are available,
|
|
71
|
-
`cython` is used by default
|
|
72
|
-
|
|
73
|
-
Returns
|
|
74
|
-
-------
|
|
75
|
-
multiplied: np.ndarray
|
|
76
|
-
result of nums1 * nums2
|
|
77
|
-
|
|
78
|
-
Examples
|
|
79
|
-
--------
|
|
80
|
-
>>> mul = _mul(nums1, nums2, num_threads=8)
|
|
81
|
-
>>> mul = _mul(np.ones((2, 3)), np.ones((1, 3))) # broadcasting, mul.shape == (2, 3)
|
|
82
|
-
>>> mul = _mul(nums1, nums2, backend=Cython(fast=True)) # ffast-math compiled version
|
|
83
|
-
"""
|
|
84
|
-
if not nums1.size and not nums2.size:
|
|
85
|
-
return np.array([], dtype=nums1.dtype)
|
|
86
|
-
if bool(nums1.size) ^ bool(nums2.size):
|
|
87
|
-
raise ValueError('One of the arrays is empty, hence pointwise multiplication cannot be performed.')
|
|
88
|
-
if len(nums1.shape) != len(nums2.shape):
|
|
89
|
-
raise ValueError('Both arrays must have the same number of dimensions for pointwise multiplication.')
|
|
90
|
-
for dim1, dim2 in zip(nums1.shape, nums2.shape):
|
|
91
|
-
if dim1 != dim2 and dim1 != 1 and dim2 != 1:
|
|
92
|
-
raise ValueError(f'Arrays of shapes {nums1.shape} and {nums2.shape} are not broadcastable.')
|
|
93
|
-
|
|
94
|
-
if nums1.ndim > 3:
|
|
95
|
-
warn('Parallel pointwise multiplication is only supported for ndim<=3. Falling back to naive x * y.')
|
|
96
|
-
|
|
97
|
-
return nums1 * nums2
|
|
98
|
-
|
|
99
|
-
backend = resolve_backend(backend)
|
|
100
|
-
if backend.name not in ('Cython', 'Scipy'):
|
|
101
|
-
raise ValueError(f'Unsupported backend "{backend.name}"')
|
|
102
|
-
|
|
103
|
-
num_threads = normalize_num_threads(num_threads, backend)
|
|
104
|
-
|
|
105
|
-
if backend.name == 'Scipy':
|
|
106
|
-
return nums1 * nums2
|
|
107
|
-
|
|
108
|
-
if backend.name == 'Cython':
|
|
109
|
-
src_parallel_pointwise_mul = (
|
|
110
|
-
cython_fast_parallel_pointwise_mul if backend.fast else cython_parallel_pointwise_mul
|
|
111
|
-
)
|
|
112
|
-
|
|
113
|
-
n_dummy = 3 - nums1.ndim
|
|
114
|
-
|
|
115
|
-
if n_dummy:
|
|
116
|
-
nums1 = nums1[(None,) * n_dummy]
|
|
117
|
-
nums2 = nums2[(None,) * n_dummy]
|
|
118
|
-
|
|
119
|
-
out = src_parallel_pointwise_mul(nums1, nums2, np.maximum(nums1.shape, nums2.shape), num_threads)
|
|
120
|
-
|
|
121
|
-
if n_dummy:
|
|
122
|
-
out = out[(0,) * n_dummy]
|
|
123
|
-
|
|
124
|
-
return out
|
imops-0.8.2.dist-info/RECORD
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
_pyproject_build.py,sha256=uSukihAHOd50LUBHTTBCCQ3oi-95bBk01Q4Y6KrXTF8,2297
|
|
2
|
-
imops/__init__.py,sha256=DH8Dp0MIEq8j_taTwUMXKqoY3WjdVdBbMnNdKHx_qes,459
|
|
3
|
-
imops/__version__.py,sha256=XhFj_ipJJJgnq-LMeWY_tqb7jCV62Abi98yRdQ0le8U,23
|
|
4
|
-
imops/_configs.py,sha256=6hBY2O4YSaQC_avvqI-dmhZkPMl4p39KQIPtqx5MAh0,734
|
|
5
|
-
imops/_numeric.py,sha256=XfKU5mNGRAAoEKtJ9xrYTxpxNFZv0abHvoolEUVeVdo,4383
|
|
6
|
-
imops/backend.py,sha256=lt3BrosqmxFh7BA-rYwYAer3XMdBTPS-pBIR5hHDNa0,2368
|
|
7
|
-
imops/box.py,sha256=NbYsPKQ8fCGxSm5up0TyqERJ-5iWmnzHLo4Smv9eesk,1865
|
|
8
|
-
imops/crop.py,sha256=hDrPNVFU3vV758KTwZmZxHzm4XgUkLQLSqJOYQHG4P0,3446
|
|
9
|
-
imops/interp1d.py,sha256=55NFTGgYUDlcndRvPqKLLPpFe6U0K8B-so8yUgBbK3c,8183
|
|
10
|
-
imops/measure.py,sha256=NqCsj2yxuUEfpPmGmOL-YSvI_2rrYUWJyzaSCPoOe90,8575
|
|
11
|
-
imops/morphology.py,sha256=GDVnLjGjTZJgcGNyFXPn3BMM7WHZZQeg-i24ci6uCdQ,12625
|
|
12
|
-
imops/pad.py,sha256=SAPJQwnuKosPoiCU26YPE4cyRPNrskwfzNOrT3KqSuk,7447
|
|
13
|
-
imops/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
|
-
imops/radon.py,sha256=C643fB9tzqK0_RyhH9EzQBfHAeEqjbnbGKDT485k5pk,9008
|
|
15
|
-
imops/testing.py,sha256=Qiy_Qn7bd7MIXoaZr4T_6r0jQWVRJFwR2z12c_Zwt30,1708
|
|
16
|
-
imops/utils.py,sha256=9XoA8qywuuSTluGDf1aEa_zP2Ixu2pNYQnBbWhy92T4,4720
|
|
17
|
-
imops/zoom.py,sha256=g7lgv8Z51tNCYfAyQnLlA187QgDzyQHxckEY9Uu9EKY,9917
|
|
18
|
-
imops/src/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
19
|
-
imops/src/_backprojection.c,sha256=5XoMEZSqTNf01oDcfOnFJhjl8qnfCjhnP4seUv9FADk,1025929
|
|
20
|
-
imops/src/_backprojection.cp37-win_amd64.pyd,sha256=y_asn2NTwECvL6xjPU1veTrJKub8b8YX-rdW_vFdAdk,165376
|
|
21
|
-
imops/src/_backprojection.pyx,sha256=xngEJtJ6czjoBRBKL6tu5S7nt6ZgcsE82xDGdCIfagE,2724
|
|
22
|
-
imops/src/_fast_backprojection.c,sha256=lL3pfTJD8akPcsjTBoG7bmaNRdittdd-I8pE0FBJF28,1036125
|
|
23
|
-
imops/src/_fast_backprojection.cp37-win_amd64.pyd,sha256=KD0FgU-Q91vGOyIZEGcUKCgo_z8e13nKGFdhjGrKwPk,166400
|
|
24
|
-
imops/src/_fast_backprojection.pyx,sha256=xngEJtJ6czjoBRBKL6tu5S7nt6ZgcsE82xDGdCIfagE,2724
|
|
25
|
-
imops/src/_fast_measure.c,sha256=k9CMbR11uk6aEqc9NIAIvY9qIKKnVOw14hgvMnD953g,1336403
|
|
26
|
-
imops/src/_fast_measure.cp37-win_amd64.pyd,sha256=liDSz2MfqefuwdPRiQvJlX9yhyL701Pa9gkHeDEoQmM,249344
|
|
27
|
-
imops/src/_fast_measure.pyx,sha256=JzZ26PptkVT08OemSFaJakc4jf7xYocPqV8jfrYi_wA,2737
|
|
28
|
-
imops/src/_fast_morphology.c,sha256=ldGZJdpq4Dd-efu2bDXNzddF920H3NbIFTycBK-WGKA,971646
|
|
29
|
-
imops/src/_fast_morphology.cp37-win_amd64.pyd,sha256=H95ZU_sB0_cljWDKB5agQJd9QfsrKVeH0UeQfRoEYjs,137728
|
|
30
|
-
imops/src/_fast_morphology.pyx,sha256=QwFrPQ6M-bJDVQNCCtKK7FR3KOr5cZSx_CBvxh9THXM,9538
|
|
31
|
-
imops/src/_fast_numeric.c,sha256=kOZhqcPn3tDLoOYUBZD37uhuDlC_DUsjXpim3gn8RnQ,1315345
|
|
32
|
-
imops/src/_fast_numeric.cp37-win_amd64.pyd,sha256=HZK9dtRsqfbygvNyPHW6kzoC2XR81-LWtFVfJ3PY38c,236544
|
|
33
|
-
imops/src/_fast_numeric.pyx,sha256=bXv4qBx_k6B6INNR0r49HU2a8UNnpt-mCS19TczcU38,1919
|
|
34
|
-
imops/src/_fast_radon.c,sha256=crM8UpjwthoZOD5E-Coce18wMZE_nO5CwOdYBzHjTGE,1190116
|
|
35
|
-
imops/src/_fast_radon.cp37-win_amd64.pyd,sha256=uUkp89t98n_3XPMDcmmSvdWHmKSzf0ii_-u9cfzJT-c,218112
|
|
36
|
-
imops/src/_fast_radon.pyx,sha256=pu8EZplCjIDz9HqBcAit8nj2lDgXpmdhU61_4CfdGWI,2987
|
|
37
|
-
imops/src/_fast_zoom.c,sha256=e5maEpmD_KuVV6ScUfdgKq7sPgqHfZHpzCGATE1ildo,2145110
|
|
38
|
-
imops/src/_fast_zoom.cp37-win_amd64.pyd,sha256=sCU1OODEtNlyXHNfdOkVpx0RiTe-EQiOa51WmPXqcFo,367616
|
|
39
|
-
imops/src/_fast_zoom.pyx,sha256=Dd5MDelALAh4-3QhnzfzKTB5Gmi2lVERrbyYj-q8kVQ,23091
|
|
40
|
-
imops/src/_measure.c,sha256=UM3FmYicJKg7LuUgWDfAjegfiVYkHBcfJ25sYt5yUgI,1324916
|
|
41
|
-
imops/src/_measure.cp37-win_amd64.pyd,sha256=ruxp48ZlvlH0aCaYBA8JjZETHNZFJaVw7gisJSXXieM,248320
|
|
42
|
-
imops/src/_measure.pyx,sha256=JzZ26PptkVT08OemSFaJakc4jf7xYocPqV8jfrYi_wA,2737
|
|
43
|
-
imops/src/_morphology.c,sha256=DbXmz3xdWnjKVSCE2VUOSmdeX5Rmzyrjl8MAa5I0v8g,960908
|
|
44
|
-
imops/src/_morphology.cp37-win_amd64.pyd,sha256=ibbjwrDZN788b6yUPvvVWjMJDqJqeEav4KDL2FzP75g,137216
|
|
45
|
-
imops/src/_morphology.pyx,sha256=QwFrPQ6M-bJDVQNCCtKK7FR3KOr5cZSx_CBvxh9THXM,9538
|
|
46
|
-
imops/src/_numba_zoom.py,sha256=OmMj7mCFkV2P0FaWVXFuYpfzMBQ3Ks60YiHQURes5wQ,16857
|
|
47
|
-
imops/src/_numeric.c,sha256=uxea9Ex1oDrkmZd56CjX9HCmcPLmEXXVcItMQX2W6lY,1304396
|
|
48
|
-
imops/src/_numeric.cp37-win_amd64.pyd,sha256=2IRYB5O5j3D1QQ16V4YRvxVUQXiXrp2IqWYoI9D9N14,236032
|
|
49
|
-
imops/src/_numeric.pyx,sha256=bXv4qBx_k6B6INNR0r49HU2a8UNnpt-mCS19TczcU38,1919
|
|
50
|
-
imops/src/_radon.c,sha256=xTkrtTvqJahQaAqkr3_n46cBlFAp4EsZjbPuai1ngMU,1178982
|
|
51
|
-
imops/src/_radon.cp37-win_amd64.pyd,sha256=TivCwMEjuR0d-Ef_l37df3PP_2_hxXtPsFSty6pv670,217088
|
|
52
|
-
imops/src/_radon.pyx,sha256=pu8EZplCjIDz9HqBcAit8nj2lDgXpmdhU61_4CfdGWI,2987
|
|
53
|
-
imops/src/_zoom.c,sha256=l20RSfpVYnQ4OsGhXIgTfu7pk1Zx3FpO_ILPN4eKAV4,2126517
|
|
54
|
-
imops/src/_zoom.cp37-win_amd64.pyd,sha256=uVbhQUVY8M7h_HpxmO7fcAsA6l42pGA5FTKt9mv4Utw,367104
|
|
55
|
-
imops/src/_zoom.pyx,sha256=Dd5MDelALAh4-3QhnzfzKTB5Gmi2lVERrbyYj-q8kVQ,23091
|
|
56
|
-
imops-0.8.2.dist-info/LICENSE,sha256=x7oyYZPKDTt8KoTitcNJLBWhueke5YEOopdr0XjyvBc,1085
|
|
57
|
-
imops-0.8.2.dist-info/METADATA,sha256=e7IeHhaE0H-Aycd7_5C855KnzGRa8K3ILrXHHXslxkQ,9019
|
|
58
|
-
imops-0.8.2.dist-info/WHEEL,sha256=XjgoyucPba5KIJKeQEOuBejIax_ghuoOXGkTW4ghWp8,101
|
|
59
|
-
imops-0.8.2.dist-info/top_level.txt,sha256=N1kO5Q0hGO9R4DFsT_VsHcDKv2KQSsrBF4eQd2ZeURA,23
|
|
60
|
-
imops-0.8.2.dist-info/RECORD,,
|
|
File without changes
|