imops 0.8.2__cp36-cp36m-musllinux_1_1_i686.whl → 0.8.3__cp36-cp36m-musllinux_1_1_i686.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.

imops/src/_numeric.pyx CHANGED
@@ -8,10 +8,19 @@
8
8
  import numpy as np
9
9
 
10
10
  cimport numpy as np
11
+ from libc.stdint cimport uint16_t
11
12
 
12
13
  from cython.parallel import prange
13
14
 
14
15
 
16
+ # https://stackoverflow.com/questions/47421443/using-half-precision-numpy-floats-in-cython
17
+ cdef extern from "numpy/halffloat.h":
18
+ ctypedef uint16_t npy_half
19
+
20
+ float npy_half_to_float(npy_half h) nogil
21
+ npy_half npy_float_to_half(float f) nogil
22
+
23
+
15
24
  ctypedef fused NUM:
16
25
  short
17
26
  int
@@ -20,45 +29,214 @@ ctypedef fused NUM:
20
29
  double
21
30
 
22
31
 
23
- def _parallel_sum(NUM[:] nums, Py_ssize_t num_threads) -> NUM:
24
- cdef NUM res = 0
25
- cdef Py_ssize_t i, len_nums = len(nums)
32
+ ctypedef fused NUM_AND_NPY_HALF:
33
+ NUM
34
+ npy_half
26
35
 
27
- for i in prange(len_nums, num_threads=num_threads, nogil=True):
28
- res += nums[i]
29
36
 
30
- return res
31
-
32
-
33
- def _parallel_pointwise_mul(
37
+ # TODO: Generalize code below to n-d
38
+ def _pointwise_add_array_3d(
34
39
  NUM[:, :, :] nums1,
35
40
  NUM[:, :, :] nums2,
36
- Py_ssize_t[:] res_shape,
37
- Py_ssize_t num_threads
41
+ NUM[:, :, :] out,
42
+ Py_ssize_t num_threads,
38
43
  ) -> np.ndarray:
39
- cdef NUM[:, :, ::1] contiguous_nums1 = np.ascontiguousarray(nums1), contiguous_nums2 = np.ascontiguousarray(nums2)
40
- cdef Py_ssize_t rows = res_shape[0], cols = res_shape[1], dims = res_shape[2]
44
+ cdef Py_ssize_t rows = out.shape[0], cols = out.shape[1], dims = out.shape[2]
45
+ cdef Py_ssize_t i, j, k
46
+
47
+ for i in prange(rows, nogil=True, num_threads=num_threads):
48
+ for j in prange(cols):
49
+ for k in prange(dims):
50
+ out[i, j, k] = nums1[i, j, k] + nums2[i, j, k]
51
+
52
+ return np.asarray(out)
41
53
 
42
- cdef char[:] broadcast_mask1 = np.array([x == y for x, y in zip(res_shape, nums1.shape)], dtype=np.int8)
43
- cdef char[:] broadcast_mask2 = np.array([x == y for x, y in zip(res_shape, nums2.shape)], dtype=np.int8)
44
54
 
45
- cdef NUM[:, :, ::1] mul = np.empty_like(nums1, shape=res_shape)
55
+ def _pointwise_add_array_4d(
56
+ NUM[:, :, :, :] nums1,
57
+ NUM[:, :, :, :] nums2,
58
+ NUM[:, :, :, :] out,
59
+ Py_ssize_t num_threads,
60
+ ) -> np.ndarray:
61
+ cdef Py_ssize_t dim1 = out.shape[0], dim2 = out.shape[1], dim3 = out.shape[2], dim4 = out.shape[3]
62
+ cdef Py_ssize_t i1, i2, i3, i4
63
+
64
+ for i1 in prange(dim1, nogil=True, num_threads=num_threads):
65
+ for i2 in prange(dim2):
66
+ for i3 in prange(dim3):
67
+ for i4 in prange(dim4):
68
+ out[i1, i2, i3, i4] = nums1[i1, i2, i3, i4] + nums2[i1, i2, i3, i4]
69
+
70
+ return np.asarray(out)
71
+
72
+
73
+ def _pointwise_add_value_3d(
74
+ NUM[:, :, :] nums,
75
+ NUM value,
76
+ NUM[:, :, :] out,
77
+ Py_ssize_t num_threads,
78
+ ) -> np.ndarray:
79
+ cdef Py_ssize_t rows = out.shape[0], cols = out.shape[1], dims = out.shape[2]
46
80
  cdef Py_ssize_t i, j, k
47
81
 
48
82
  for i in prange(rows, nogil=True, num_threads=num_threads):
49
83
  for j in prange(cols):
50
84
  for k in prange(dims):
51
- mul[i, j, k] = (
52
- contiguous_nums1[
53
- i * broadcast_mask1[0],
54
- j * broadcast_mask1[1],
55
- k * broadcast_mask1[2]
56
- ] *
57
- contiguous_nums2[
58
- i * broadcast_mask2[0],
59
- j * broadcast_mask2[1],
60
- k * broadcast_mask2[2]
61
- ]
62
- )
63
-
64
- return np.asarray(mul)
85
+ out[i, j, k] = nums[i, j, k] + value
86
+
87
+ return np.asarray(out)
88
+
89
+
90
+ def _pointwise_add_value_4d(
91
+ NUM[:, :, :, :] nums,
92
+ NUM value,
93
+ NUM[:, :, :, :] out,
94
+ Py_ssize_t num_threads,
95
+ ) -> np.ndarray:
96
+ cdef Py_ssize_t dim1 = out.shape[0], dim2 = out.shape[1], dim3 = out.shape[2], dim4 = out.shape[3]
97
+ cdef Py_ssize_t i1, i2, i3, i4
98
+
99
+ for i1 in prange(dim1, nogil=True, num_threads=num_threads):
100
+ for i2 in prange(dim2):
101
+ for i3 in prange(dim3):
102
+ for i4 in prange(dim4):
103
+ out[i1, i2, i3, i4] = nums[i1, i2, i3, i4] + value
104
+
105
+ return np.asarray(out)
106
+
107
+
108
+ def _pointwise_add_array_3d_fp16(
109
+ npy_half[:, :, :] nums1,
110
+ npy_half[:, :, :] nums2,
111
+ npy_half[:, :, :] out,
112
+ Py_ssize_t num_threads,
113
+ ) -> np.ndarray:
114
+ cdef Py_ssize_t rows = out.shape[0], cols = out.shape[1], dims = out.shape[2]
115
+ cdef Py_ssize_t i, j, k
116
+
117
+ for i in prange(rows, nogil=True, num_threads=num_threads):
118
+ for j in prange(cols):
119
+ for k in prange(dims):
120
+ out[i, j, k] = (npy_float_to_half(npy_half_to_float(nums1[i, j, k]) +
121
+ npy_half_to_float(nums2[i, j, k])))
122
+
123
+ return np.asarray(out)
124
+
125
+
126
+ def _pointwise_add_array_4d_fp16(
127
+ npy_half[:, :, :, :] nums1,
128
+ npy_half[:, :, :, :] nums2,
129
+ npy_half[:, :, :, :] out,
130
+ Py_ssize_t num_threads,
131
+ ) -> np.ndarray:
132
+ cdef Py_ssize_t dim1 = out.shape[0], dim2 = out.shape[1], dim3 = out.shape[2], dim4 = out.shape[3]
133
+ cdef Py_ssize_t i1, i2, i3, i4
134
+
135
+ for i1 in prange(dim1, nogil=True, num_threads=num_threads):
136
+ for i2 in prange(dim2):
137
+ for i3 in prange(dim3):
138
+ for i4 in prange(dim4):
139
+ out[i1, i2, i3, i4] = (npy_float_to_half(npy_half_to_float(nums1[i1, i2, i3, i4]) +
140
+ npy_half_to_float(nums2[i1, i2, i3, i4])))
141
+
142
+ return np.asarray(out)
143
+
144
+
145
+ def _pointwise_add_value_3d_fp16(
146
+ npy_half[:, :, :] nums,
147
+ npy_half value,
148
+ npy_half[:, :, :] out,
149
+ Py_ssize_t num_threads,
150
+ ) -> np.ndarray:
151
+ cdef Py_ssize_t rows = out.shape[0], cols = out.shape[1], dims = out.shape[2]
152
+ cdef Py_ssize_t i, j, k
153
+
154
+ for i in prange(rows, nogil=True, num_threads=num_threads):
155
+ for j in prange(cols):
156
+ for k in prange(dims):
157
+ out[i, j, k] = npy_float_to_half(npy_half_to_float(nums[i, j, k]) + npy_half_to_float(value))
158
+
159
+ return np.asarray(out)
160
+
161
+
162
+ def _pointwise_add_value_4d_fp16(
163
+ npy_half[:, :, :, :] nums,
164
+ npy_half value,
165
+ npy_half[:, :, :, :] out,
166
+ Py_ssize_t num_threads,
167
+ ) -> np.ndarray:
168
+ cdef Py_ssize_t dim1 = out.shape[0], dim2 = out.shape[1], dim3 = out.shape[2], dim4 = out.shape[3]
169
+ cdef Py_ssize_t i1, i2, i3, i4
170
+
171
+ for i1 in prange(dim1, nogil=True, num_threads=num_threads):
172
+ for i2 in prange(dim2):
173
+ for i3 in prange(dim3):
174
+ for i4 in prange(dim4):
175
+ out[i1, i2, i3, i4] = (npy_float_to_half(npy_half_to_float(nums[i1, i2, i3, i4]) +
176
+ npy_half_to_float(value)))
177
+
178
+ return np.asarray(out)
179
+
180
+
181
+ def _fill_3d(NUM_AND_NPY_HALF[:, :, :] nums, NUM_AND_NPY_HALF value, Py_ssize_t num_threads) -> None:
182
+ cdef Py_ssize_t rows = nums.shape[0], cols = nums.shape[1], dims = nums.shape[2]
183
+ cdef Py_ssize_t i, j, k
184
+
185
+ for i in prange(rows, nogil=True, num_threads=num_threads):
186
+ for j in prange(cols):
187
+ for k in prange(dims):
188
+ nums[i, j, k] = value
189
+
190
+
191
+ def _fill_4d(NUM_AND_NPY_HALF[:, :, :, :] nums, NUM_AND_NPY_HALF value, Py_ssize_t num_threads) -> None:
192
+ cdef Py_ssize_t dim1 = nums.shape[0], dim2 = nums.shape[1], dim3 = nums.shape[2], dim4 = nums.shape[3]
193
+ cdef Py_ssize_t i1, i2, i3, i4
194
+
195
+ for i1 in prange(dim1, nogil=True, num_threads=num_threads):
196
+ for i2 in prange(dim2):
197
+ for i3 in prange(dim3):
198
+ for i4 in prange(dim4):
199
+ nums[i1, i2, i3, i4] = value
200
+
201
+
202
+ # FIXME: somehow `const NUM_AND_NPY_HALF` is not working
203
+ cpdef void _copy_3d(const NUM[:, :, :] nums1, NUM[:, :, :] nums2, Py_ssize_t num_threads):
204
+ cdef Py_ssize_t rows = nums1.shape[0], cols = nums1.shape[1], dims = nums1.shape[2]
205
+ cdef Py_ssize_t i, j, k
206
+
207
+ for i in prange(rows, nogil=True, num_threads=num_threads):
208
+ for j in prange(cols):
209
+ for k in prange(dims):
210
+ nums2[i, j, k] = nums1[i, j, k]
211
+
212
+
213
+ cpdef void _copy_4d(const NUM[:, :, :, :] nums1, NUM[:, :, :, :] nums2, Py_ssize_t num_threads):
214
+ cdef Py_ssize_t dim1 = nums1.shape[0], dim2 = nums1.shape[1], dim3 = nums1.shape[2], dim4 = nums1.shape[3]
215
+ cdef Py_ssize_t i1, i2, i3, i4
216
+
217
+ for i1 in prange(dim1, nogil=True, num_threads=num_threads):
218
+ for i2 in prange(dim2):
219
+ for i3 in prange(dim3):
220
+ for i4 in prange(dim4):
221
+ nums2[i1, i2, i3, i4] = nums1[i1, i2, i3, i4]
222
+
223
+
224
+ cpdef void _copy_3d_fp16(const npy_half[:, :, :] nums1, npy_half[:, :, :] nums2, Py_ssize_t num_threads):
225
+ cdef Py_ssize_t rows = nums1.shape[0], cols = nums1.shape[1], dims = nums1.shape[2]
226
+ cdef Py_ssize_t i, j, k
227
+
228
+ for i in prange(rows, nogil=True, num_threads=num_threads):
229
+ for j in prange(cols):
230
+ for k in prange(dims):
231
+ nums2[i, j, k] = nums1[i, j, k]
232
+
233
+
234
+ cpdef void _copy_4d_fp16(const npy_half[:, :, :, :] nums1, npy_half[:, :, :, :] nums2, Py_ssize_t num_threads):
235
+ cdef Py_ssize_t dim1 = nums1.shape[0], dim2 = nums1.shape[1], dim3 = nums1.shape[2], dim4 = nums1.shape[3]
236
+ cdef Py_ssize_t i1, i2, i3, i4
237
+
238
+ for i1 in prange(dim1, nogil=True, num_threads=num_threads):
239
+ for i2 in prange(dim2):
240
+ for i3 in prange(dim3):
241
+ for i4 in prange(dim4):
242
+ nums2[i1, i2, i3, i4] = nums1[i1, i2, i3, i4]
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 BACKEND2NUM_THREADS_VAR_NAME, SINGLE_THREADED_BACKENDS, Backend
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 normalize_num_threads(num_threads: int, backend: Backend):
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(f'"{backend.name}" backend is single-threaded. Setting `num_threads` has no effect.')
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
- return num_threads
30
-
31
- num_threads_var_name = BACKEND2NUM_THREADS_VAR_NAME[backend.name]
32
- # here we also handle the case `num_threads_var`=" " gracefully
33
- env_num_threads = os.environ.get(num_threads_var_name, '').strip()
34
- max_threads = int(env_num_threads) if env_num_threads else len(os.sched_getaffinity(0))
35
-
36
- return max_threads + num_threads + 1
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,12 +1,12 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: imops
3
- Version: 0.8.2
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
6
  Author: maxme1, vovaf709, talgat
7
7
  Author-email: maxs987@gmail.com, vovaf709@yandex.ru, saparov2130@gmail.com
8
8
  License: MIT
9
- Download-URL: https://github.com/neuro-ml/imops/archive/v0.8.2.tar.gz
9
+ Download-URL: https://github.com/neuro-ml/imops/archive/v0.8.3.tar.gz
10
10
  Keywords: image processing,fast,ndarray,data pipelines
11
11
  Platform: UNKNOWN
12
12
  Classifier: Development Status :: 5 - Production/Stable
@@ -21,6 +21,7 @@ Requires-Python: >=3.6
21
21
  Description-Content-Type: text/markdown
22
22
  License-File: LICENSE
23
23
  Requires-Dist: scipy (<2.0.0,>=1.0)
24
+ Requires-Dist: scikit-image
24
25
  Requires-Dist: connected-components-3d
25
26
  Requires-Dist: fastremap
26
27
  Requires-Dist: dataclasses ; python_version < "3.7"
@@ -0,0 +1,47 @@
1
+ imops-0.8.3.dist-info/METADATA,sha256=NdA1fnC5rCLIg-kvfInPxqlWIckur-inz1uUF89mft0,7391
2
+ imops-0.8.3.dist-info/LICENSE,sha256=s4td51soCfOr_HP5fF2gTARksncu_DD1TgugcUGTBQ0,1064
3
+ imops-0.8.3.dist-info/WHEEL,sha256=vKL5TyPvBaqrVS_wrd1wwVcCEkHcF1Y5mT8I1AQaxRA,110
4
+ imops-0.8.3.dist-info/RECORD,,
5
+ imops-0.8.3.dist-info/top_level.txt,sha256=kEVHvrc8A4lkLQP8xew2pWdYcyQAMvAwqnlZXtoWwnc,6
6
+ imops.libs/libgomp-41890ef0.so.1.0.0,sha256=v1S9wI3pI7LI5wKB6AvV6AdAUscM_zZ95LWxXvmoAN8,195208
7
+ imops/morphology.py,sha256=rIzE7HXyBE91NWMR9rR1di4s0QccRnPMxivA3PnlM1M,12376
8
+ imops/backend.py,sha256=9kJtdd4-66SOP7MEXF-o9-aFImLtvpaqTKe1ttNb0hk,2503
9
+ imops/__version__.py,sha256=LokQdkRCwhhLh0zOp7jizhyDgbtAU-IWRIObrz2zLjA,22
10
+ imops/radon.py,sha256=bygHhDe_SD7sjubcGBsXtTa3z4-z1JiOXpkIRSt8xpw,8968
11
+ imops/crop.py,sha256=PSOOlJUb_R8Hj3P18aRicwFXil19Q6a1QrwLmZZfZkQ,3945
12
+ imops/utils.py,sha256=X6dYRExW4nnpgO1z5-DcHhmReIvzaOBdBNKd5TeUbjg,6684
13
+ imops/measure.py,sha256=ehJ1F4DJK6FTS0XsuKzzxQnFX78Fo4eShinYYrbItu8,8433
14
+ imops/pad.py,sha256=AjgLCQVgGOwVNxYY7xMMyX7YO82uObxEroApuQxZE34,9069
15
+ imops/_configs.py,sha256=PoPlwnmmCz-Z8GmKYIqR8xsqcWHPKiYSGWldbQX9GU0,705
16
+ imops/zoom.py,sha256=cHKuXrKY5GmBDLMat1_ElIBuZGd8Mk5MXHtVD5WtEQk,9664
17
+ imops/__init__.py,sha256=FUVB4d2PQlM4PJUSIjyz9oRlWaqU6RSskyyrX56-RrY,504
18
+ imops/numeric.py,sha256=OUu-aXg2ZsULvBxwxFd3pbeFzIhlTlt5fO2Koje7wPo,13274
19
+ imops/box.py,sha256=3WrOdpUigoGKNnWhLLgX5NX_D9WzgwDKIWf75baTK-Y,1794
20
+ imops/interp1d.py,sha256=FUVvEIldoIf4_-RbRcZHrbNZ6UoW9cpRfW4flWCxdyI,8195
21
+ imops/testing.py,sha256=JgUWoD7fzshdaVrrgmf9y9jpl3EHgmoYYmHHGCFI4Ws,1650
22
+ imops/src/_numeric.pyx,sha256=05GbyyFzdill8M_L9KYA9hfYP7ULiAnvMpWyBATl7vQ,7979
23
+ imops/src/_radon.pyx,sha256=ztXVnOfUjsRY5R22-7LbodG_FAbUoBemTnaIDZsPeI4,2896
24
+ imops/src/_zoom.cpython-36m-i386-linux-gnu.so,sha256=5ZHv7Qp5-8Kuj2SVHJgijJvLFO03Mb9g3SN8XvcWv3s,2705820
25
+ imops/src/_morphology.cpython-36m-i386-linux-gnu.so,sha256=CyUwzySEqPsUAeQNb24QVYg_im3luw0L7uzRdohSyK4,997184
26
+ imops/src/_fast_radon.cpython-36m-i386-linux-gnu.so,sha256=rI2jqfqf-8AmxsBGqgmRlXHS0hwzDGvBEVc-JknORVE,1403312
27
+ imops/src/_fast_radon.pyx,sha256=ztXVnOfUjsRY5R22-7LbodG_FAbUoBemTnaIDZsPeI4,2896
28
+ imops/src/_fast_morphology.cpython-36m-i386-linux-gnu.so,sha256=qcyftg7hEBkk3VyQYd9e66d1E8X2WOeWoY-FJp5kvJU,1001292
29
+ imops/src/_fast_measure.pyx,sha256=pKFBt8ITxy1QsO5wFkRrhdYMfT2ENCA7yPZ-ZJRCh44,2650
30
+ imops/src/_fast_morphology.pyx,sha256=X96ad1iadGPelOipNjXNd9s77x95LCVFBTAs0gr4iXE,9209
31
+ imops/src/_morphology.pyx,sha256=X96ad1iadGPelOipNjXNd9s77x95LCVFBTAs0gr4iXE,9209
32
+ imops/src/_measure.cpython-36m-i386-linux-gnu.so,sha256=VSUfpKZnfH9m_vC3St0RBbsh8vUm6aPHlLMgargFb8E,1530424
33
+ imops/src/_fast_zoom.cpython-36m-i386-linux-gnu.so,sha256=J95uGErxll9HspJeWn3OgRpI9q4f-jsLXvIkh9k8HSc,2714024
34
+ imops/src/_numeric.cpython-36m-i386-linux-gnu.so,sha256=7PnAFhQv07WK5nBm8lOndlHFIZ4uKMA_jtM5lVgJxVY,2512784
35
+ imops/src/_numba_zoom.py,sha256=NH1u-64xExw0b_l6GQJ7ICOoWVsGOH8ztuS1LFvsiz0,16354
36
+ imops/src/_measure.pyx,sha256=pKFBt8ITxy1QsO5wFkRrhdYMfT2ENCA7yPZ-ZJRCh44,2650
37
+ imops/src/_fast_measure.cpython-36m-i386-linux-gnu.so,sha256=p7PF-YP6bKH3h1vimhSkxE9BdFmR8fmIcxuZJFNESGw,1530432
38
+ imops/src/_backprojection.pyx,sha256=RMB_GS2mbOS8mQWeo640p9FdeHHFjmjW3qrlEGGoL0s,2645
39
+ imops/src/_fast_numeric.pyx,sha256=05GbyyFzdill8M_L9KYA9hfYP7ULiAnvMpWyBATl7vQ,7979
40
+ imops/src/_fast_numeric.cpython-36m-i386-linux-gnu.so,sha256=r6FAEOzngxFuLy9Mqbwc3zC8FOBCKRHF2zRCYZXNonQ,2520984
41
+ imops/src/_radon.cpython-36m-i386-linux-gnu.so,sha256=jG-Z4Yll41PNMRfuxFKwK7PZd857-eQVO5PJy58VLho,1403300
42
+ imops/src/_fast_zoom.pyx,sha256=_7cPgowHRuFuc7WFuqSnbr_gVzsQi2Bu1nhwoi_yDmw,22566
43
+ imops/src/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
44
+ imops/src/_backprojection.cpython-36m-i386-linux-gnu.so,sha256=9kiPSNl27lvXmG8yhlZ-Ti0CmU7SH_tHo53wPn_Is_Y,1157552
45
+ imops/src/_fast_backprojection.cpython-36m-i386-linux-gnu.so,sha256=PVJgqh5M2WGkZyqIG4GAO5RmbR21Mn6CpuVh-aIRVGM,1157564
46
+ imops/src/_fast_backprojection.pyx,sha256=RMB_GS2mbOS8mQWeo640p9FdeHHFjmjW3qrlEGGoL0s,2645
47
+ imops/src/_zoom.pyx,sha256=_7cPgowHRuFuc7WFuqSnbr_gVzsQi2Bu1nhwoi_yDmw,22566
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
@@ -1,47 +0,0 @@
1
- imops/measure.py,sha256=CtR6Qx8oU_FX3XbC1HIqOV0kMr_E0qq3wwg646FTXV4,8351
2
- imops/pad.py,sha256=FBRsooy11j3XJbrTeewgVS_qpKvkMnc_0J-tGJ061DI,7238
3
- imops/crop.py,sha256=26dS16ryTDlizCzPQFjN9E-_dUgRR4XHZZwow2nJ4UU,3352
4
- imops/box.py,sha256=3WrOdpUigoGKNnWhLLgX5NX_D9WzgwDKIWf75baTK-Y,1794
5
- imops/radon.py,sha256=LjIrcDmhLc17vVbHERMNlrxsh8_kMXrPDlvZUJtqe64,8767
6
- imops/_numeric.py,sha256=gb217xV7z3dcH9sE4UFatinIVH9r_7WSRgoveZ7Neno,4259
7
- imops/_configs.py,sha256=PoPlwnmmCz-Z8GmKYIqR8xsqcWHPKiYSGWldbQX9GU0,705
8
- imops/utils.py,sha256=8pcn53Rw8LOyO-2vnazlNLrcJ9cEsGgQFQN8X-EYfCQ,4567
9
- imops/morphology.py,sha256=c_UJvHXsZEgz6b1PgHXkhMII7u7S8-WEJQTjo58045o,12279
10
- imops/testing.py,sha256=JgUWoD7fzshdaVrrgmf9y9jpl3EHgmoYYmHHGCFI4Ws,1650
11
- imops/backend.py,sha256=D1TJ1WB7lmzCwjT7KA9axbjC3B6rWRDQP1veTNwFqKI,2277
12
- imops/interp1d.py,sha256=lLnthTOIB7j7k638174se8omGIKehtNleTtFRIaPACk,7981
13
- imops/__version__.py,sha256=K2rsUy8S7UHe3tStL6NCs5z92apbvbkrpGIEjcCNCNs,22
14
- imops/zoom.py,sha256=9JrgjSzedETxCCfhsOrMz9XOQuTi4OtgeC4jFmEVRLE,9626
15
- imops/__init__.py,sha256=qWjreqFvwVqyxDdV1_ylx-FxsLt9f0vRtgmMt3ZhHjg,450
16
- imops/src/_fast_backprojection.pyx,sha256=RMB_GS2mbOS8mQWeo640p9FdeHHFjmjW3qrlEGGoL0s,2645
17
- imops/src/_fast_zoom.pyx,sha256=_7cPgowHRuFuc7WFuqSnbr_gVzsQi2Bu1nhwoi_yDmw,22566
18
- imops/src/_backprojection.cpython-36m-i386-linux-gnu.so,sha256=R7ai58PmMbl4na-wIZ-1ha8Nusd9ze5B0hJc3zPpDLc,1157552
19
- imops/src/_zoom.cpython-36m-i386-linux-gnu.so,sha256=ak_r7_B10L7mi7xmgguBzVeRrSw76BDM6UWwaoZyyXQ,2705820
20
- imops/src/_fast_zoom.cpython-36m-i386-linux-gnu.so,sha256=0fuL7uCLJ3CF6NFjlD3XkGMj10ybuzSwjzW9YMDR9Ps,2673036
21
- imops/src/_zoom.pyx,sha256=_7cPgowHRuFuc7WFuqSnbr_gVzsQi2Bu1nhwoi_yDmw,22566
22
- imops/src/_fast_measure.cpython-36m-i386-linux-gnu.so,sha256=_dc5dIVXieewd3FUCJBq31UHX858V4r8TskFBWuvuUA,1534544
23
- imops/src/_fast_backprojection.cpython-36m-i386-linux-gnu.so,sha256=NNSYmFjCP0JsxQ2G-2BWcPkDtHfYk7xayQW0XZPQiFM,1157532
24
- imops/src/_morphology.pyx,sha256=X96ad1iadGPelOipNjXNd9s77x95LCVFBTAs0gr4iXE,9209
25
- imops/src/_backprojection.pyx,sha256=RMB_GS2mbOS8mQWeo640p9FdeHHFjmjW3qrlEGGoL0s,2645
26
- imops/src/_fast_measure.pyx,sha256=pKFBt8ITxy1QsO5wFkRrhdYMfT2ENCA7yPZ-ZJRCh44,2650
27
- imops/src/_numeric.pyx,sha256=OHFH0W02-gwB_nW6A5GgVw-70Eb__tiRZnOY1igtqAE,1855
28
- imops/src/_fast_numeric.cpython-36m-i386-linux-gnu.so,sha256=JeRipp9urmmmcPI3kVFIdA88I5nGKtYRYy3JRKSnoMs,1616236
29
- imops/src/_numba_zoom.py,sha256=NH1u-64xExw0b_l6GQJ7ICOoWVsGOH8ztuS1LFvsiz0,16354
30
- imops/src/_radon.cpython-36m-i386-linux-gnu.so,sha256=umxBSCUbfx5oQ-7H6tP-NoqR5AwEC_b4rEqpS3mC7A4,1403300
31
- imops/src/_fast_morphology.cpython-36m-i386-linux-gnu.so,sha256=lsfWPuExwKJF96fQfdvo3Yl-_Yi0AmuTK4hgm0jmpzY,1001308
32
- imops/src/_fast_numeric.pyx,sha256=OHFH0W02-gwB_nW6A5GgVw-70Eb__tiRZnOY1igtqAE,1855
33
- imops/src/_fast_morphology.pyx,sha256=X96ad1iadGPelOipNjXNd9s77x95LCVFBTAs0gr4iXE,9209
34
- imops/src/_radon.pyx,sha256=ztXVnOfUjsRY5R22-7LbodG_FAbUoBemTnaIDZsPeI4,2896
35
- imops/src/_fast_radon.cpython-36m-i386-linux-gnu.so,sha256=Vs2JPaN1YszKP3VMQw_8dIYbW4dfF71rMOSPY6f0aUI,1399144
36
- imops/src/_measure.cpython-36m-i386-linux-gnu.so,sha256=71f6p-uVWwsob49empcSAA8VaNNHP1lQXW0Wrct4XY0,1530424
37
- imops/src/_measure.pyx,sha256=pKFBt8ITxy1QsO5wFkRrhdYMfT2ENCA7yPZ-ZJRCh44,2650
38
- imops/src/_numeric.cpython-36m-i386-linux-gnu.so,sha256=z1HVzs-BJ1Zv-JxFO5OZPlUcUDWl8x-A0fz6f1MANMA,1612112
39
- imops/src/_fast_radon.pyx,sha256=ztXVnOfUjsRY5R22-7LbodG_FAbUoBemTnaIDZsPeI4,2896
40
- imops/src/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
41
- imops/src/_morphology.cpython-36m-i386-linux-gnu.so,sha256=_DJZrHy_dKDmCuTkY3VhetuEpnQRrEkq5D-8yYFHsY4,997184
42
- imops.libs/libgomp-41890ef0.so.1.0.0,sha256=v1S9wI3pI7LI5wKB6AvV6AdAUscM_zZ95LWxXvmoAN8,195208
43
- imops-0.8.2.dist-info/LICENSE,sha256=s4td51soCfOr_HP5fF2gTARksncu_DD1TgugcUGTBQ0,1064
44
- imops-0.8.2.dist-info/RECORD,,
45
- imops-0.8.2.dist-info/top_level.txt,sha256=kEVHvrc8A4lkLQP8xew2pWdYcyQAMvAwqnlZXtoWwnc,6
46
- imops-0.8.2.dist-info/METADATA,sha256=B9oMqoxEC0eeetqk0bQqDGbKTN8qxq3vGrp0sXIq9tg,7363
47
- imops-0.8.2.dist-info/WHEEL,sha256=vKL5TyPvBaqrVS_wrd1wwVcCEkHcF1Y5mT8I1AQaxRA,110
File without changes
File without changes