yirgacheffe 1.3.1__py3-none-any.whl → 1.3.3__py3-none-any.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 yirgacheffe might be problematic. Click here for more details.
- yirgacheffe/backends/enumeration.py +3 -1
- yirgacheffe/backends/mlx.py +6 -0
- yirgacheffe/backends/numpy.py +6 -0
- yirgacheffe/constants.py +1 -0
- yirgacheffe/operators.py +39 -4
- {yirgacheffe-1.3.1.dist-info → yirgacheffe-1.3.3.dist-info}/METADATA +4 -1
- {yirgacheffe-1.3.1.dist-info → yirgacheffe-1.3.3.dist-info}/RECORD +11 -11
- {yirgacheffe-1.3.1.dist-info → yirgacheffe-1.3.3.dist-info}/WHEEL +0 -0
- {yirgacheffe-1.3.1.dist-info → yirgacheffe-1.3.3.dist-info}/entry_points.txt +0 -0
- {yirgacheffe-1.3.1.dist-info → yirgacheffe-1.3.3.dist-info}/licenses/LICENSE +0 -0
- {yirgacheffe-1.3.1.dist-info → yirgacheffe-1.3.3.dist-info}/top_level.txt +0 -0
yirgacheffe/backends/mlx.py
CHANGED
|
@@ -45,6 +45,9 @@ allclose = mx.allclose
|
|
|
45
45
|
remainder_op = mx.remainder
|
|
46
46
|
floordiv_op = mx.array.__floordiv__
|
|
47
47
|
abs_op = mx.abs
|
|
48
|
+
floor_op = mx.floor
|
|
49
|
+
round_op = mx.round
|
|
50
|
+
ceil_op = mx.ceil
|
|
48
51
|
|
|
49
52
|
def sum_op(a):
|
|
50
53
|
# There are weird issues around how MLX overflows int8, so just promote the data ahead of summing
|
|
@@ -211,4 +214,7 @@ operator_map = {
|
|
|
211
214
|
op.CONV2D: conv2d_op,
|
|
212
215
|
op.ABS: mx.abs,
|
|
213
216
|
op.ASTYPE: astype_op,
|
|
217
|
+
op.FLOOR: mx.floor,
|
|
218
|
+
op.ROUND: mx.round,
|
|
219
|
+
op.CEIL: mx.ceil,
|
|
214
220
|
}
|
yirgacheffe/backends/numpy.py
CHANGED
|
@@ -48,6 +48,9 @@ allclose = np.allclose
|
|
|
48
48
|
remainder_op = np.ndarray.__mod__
|
|
49
49
|
floordiv_op = np.ndarray.__floordiv__
|
|
50
50
|
abs_op = np.abs
|
|
51
|
+
floor_op = np.floor
|
|
52
|
+
round_op = np.round
|
|
53
|
+
ceil_op = np.ceil
|
|
51
54
|
|
|
52
55
|
def conv2d_op(data, weights):
|
|
53
56
|
# torch wants to process dimensions of channels of width of height
|
|
@@ -149,4 +152,7 @@ operator_map = {
|
|
|
149
152
|
op.CONV2D: conv2d_op,
|
|
150
153
|
op.ABS: np.abs,
|
|
151
154
|
op.ASTYPE: astype_op,
|
|
155
|
+
op.FLOOR: np.floor,
|
|
156
|
+
op.ROUND: np.round,
|
|
157
|
+
op.CEIL: np.ceil,
|
|
152
158
|
}
|
yirgacheffe/constants.py
CHANGED
yirgacheffe/operators.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import logging
|
|
2
|
+
import math
|
|
2
3
|
import multiprocessing
|
|
3
4
|
import sys
|
|
4
5
|
import time
|
|
@@ -120,6 +121,27 @@ class LayerMathMixin:
|
|
|
120
121
|
window_op=WindowOperation.NONE,
|
|
121
122
|
)
|
|
122
123
|
|
|
124
|
+
def floor(self):
|
|
125
|
+
return LayerOperation(
|
|
126
|
+
self,
|
|
127
|
+
op.FLOOR,
|
|
128
|
+
window_op=WindowOperation.NONE,
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
def round(self):
|
|
132
|
+
return LayerOperation(
|
|
133
|
+
self,
|
|
134
|
+
op.ROUND,
|
|
135
|
+
window_op=WindowOperation.NONE,
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
def ceil(self):
|
|
139
|
+
return LayerOperation(
|
|
140
|
+
self,
|
|
141
|
+
op.CEIL,
|
|
142
|
+
window_op=WindowOperation.NONE,
|
|
143
|
+
)
|
|
144
|
+
|
|
123
145
|
def log(self):
|
|
124
146
|
return LayerOperation(
|
|
125
147
|
self,
|
|
@@ -578,6 +600,20 @@ class LayerOperation(LayerMathMixin):
|
|
|
578
600
|
def _parallel_save(self, destination_layer, and_sum=False, callback=None, parallelism=None, band=1):
|
|
579
601
|
assert (destination_layer is not None) or and_sum
|
|
580
602
|
computation_window = self.window
|
|
603
|
+
|
|
604
|
+
worker_count = parallelism or multiprocessing.cpu_count()
|
|
605
|
+
work_blocks = len(range(0, computation_window.ysize, self.ystep))
|
|
606
|
+
adjusted_blocks = math.ceil(work_blocks / constants.MINIMUM_CHUNKS_PER_THREAD)
|
|
607
|
+
worker_count = min(adjusted_blocks, worker_count)
|
|
608
|
+
|
|
609
|
+
if worker_count == 1:
|
|
610
|
+
if destination_layer:
|
|
611
|
+
return self.save(destination_layer, and_sum, callback, band)
|
|
612
|
+
elif and_sum:
|
|
613
|
+
return self.sum()
|
|
614
|
+
else:
|
|
615
|
+
assert False
|
|
616
|
+
|
|
581
617
|
if destination_layer is not None:
|
|
582
618
|
try:
|
|
583
619
|
band = destination_layer._dataset.GetRasterBand(band)
|
|
@@ -615,10 +651,6 @@ class LayerOperation(LayerMathMixin):
|
|
|
615
651
|
with multiprocessing.Manager() as manager:
|
|
616
652
|
with SharedMemoryManager() as smm:
|
|
617
653
|
|
|
618
|
-
worker_count = parallelism or multiprocessing.cpu_count()
|
|
619
|
-
work_blocks = len(range(0, computation_window.ysize, self.ystep))
|
|
620
|
-
worker_count = min(work_blocks, worker_count)
|
|
621
|
-
|
|
622
654
|
mem_sem_cast = []
|
|
623
655
|
for i in range(worker_count):
|
|
624
656
|
shared_buf = smm.SharedMemory(size=np_dtype.itemsize * self.ystep * computation_window.xsize)
|
|
@@ -754,3 +786,6 @@ exp2 = LayerOperation.exp2
|
|
|
754
786
|
nan_to_num = LayerOperation.nan_to_num
|
|
755
787
|
isin = LayerOperation.isin
|
|
756
788
|
abs = LayerOperation.abs # pylint: disable=W0622
|
|
789
|
+
floor = LayerOperation.floor
|
|
790
|
+
round = LayerOperation.round # pylint: disable=W0622
|
|
791
|
+
ceil = LayerOperation.ceil
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: yirgacheffe
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.3
|
|
4
4
|
Summary: Abstraction of gdal datasets for doing basic math operations
|
|
5
5
|
Author-email: Michael Dales <mwd24@cam.ac.uk>
|
|
6
6
|
License-Expression: ISC
|
|
@@ -304,9 +304,11 @@ with RasterLayer.layer_from_file('test1.tif') as layer1:
|
|
|
304
304
|
The following math operators common to numpy and other libraries are currently supported:
|
|
305
305
|
|
|
306
306
|
* abs
|
|
307
|
+
* ceil
|
|
307
308
|
* clip
|
|
308
309
|
* exp
|
|
309
310
|
* exp2
|
|
311
|
+
* floor
|
|
310
312
|
* isin
|
|
311
313
|
* log
|
|
312
314
|
* log2
|
|
@@ -314,6 +316,7 @@ The following math operators common to numpy and other libraries are currently s
|
|
|
314
316
|
* maximum
|
|
315
317
|
* minimum
|
|
316
318
|
* nan_to_num
|
|
319
|
+
* round
|
|
317
320
|
|
|
318
321
|
Typically these can be invoked either on a layer as a method:
|
|
319
322
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
yirgacheffe/__init__.py,sha256=U5AoPk_iWreSCexG2ID-tmSXiJz4_9Lvzbf42DMvT7k,658
|
|
2
|
-
yirgacheffe/constants.py,sha256=
|
|
2
|
+
yirgacheffe/constants.py,sha256=WccPcISG1FqL_Kw1tI72BJGjHy6RvEcGEx_I9RK776U,42
|
|
3
3
|
yirgacheffe/h3layer.py,sha256=MT2hm6n64hzHSeRPvjn-CwErru937ntKXbEU7CIlPSU,91
|
|
4
|
-
yirgacheffe/operators.py,sha256=
|
|
4
|
+
yirgacheffe/operators.py,sha256=dWbT_QASfSmEdrf_3y5ytUWVPY0VJk1AvFvkTkrZ-80,28155
|
|
5
5
|
yirgacheffe/rounding.py,sha256=ggBG4lMyLMtHLW3dBxr3gBCcF2qhRrY5etZiFGlIoqA,2258
|
|
6
6
|
yirgacheffe/window.py,sha256=0XZdwD4mz0bRU9eBhFY1Xk1hQt6FqCKp3BnUgxZup3c,5224
|
|
7
7
|
yirgacheffe/backends/__init__.py,sha256=149-fg1PVXC36cgyuSZsU8SYOm65fzUmYN_MHZtEyrY,313
|
|
8
|
-
yirgacheffe/backends/enumeration.py,sha256=
|
|
9
|
-
yirgacheffe/backends/mlx.py,sha256=
|
|
10
|
-
yirgacheffe/backends/numpy.py,sha256=
|
|
8
|
+
yirgacheffe/backends/enumeration.py,sha256=pADawllxpW_hW-IVVvZpHWIKzvEMs9aaqfkZRD1zjnY,1003
|
|
9
|
+
yirgacheffe/backends/mlx.py,sha256=3HSKU7ZU846trdxeVhPj2OPkFWrCxfbjB65-NpnmANQ,6097
|
|
10
|
+
yirgacheffe/backends/numpy.py,sha256=qQYvff1oHIuGUimV04rcFyPxnwEf0acvVd3ijeom4T4,4015
|
|
11
11
|
yirgacheffe/layers/__init__.py,sha256=GR_TJlhPKDK1212CG2T99X2FdBlNo_G8q2zQ6nJbiO4,1534
|
|
12
12
|
yirgacheffe/layers/area.py,sha256=yIRXzeeLi3MMyuh4LG_VgZrKNWe5xwZgDGdgaoYRpP0,3805
|
|
13
13
|
yirgacheffe/layers/base.py,sha256=vVxumZgFLTYXFtVxJEiBVV1QqtQWa5kwL10ckUF-ykE,11617
|
|
@@ -17,9 +17,9 @@ yirgacheffe/layers/h3layer.py,sha256=Cyrw_6nXc1a_Twsb0FfexKhHAbegKXStL3J5LLk2AX8
|
|
|
17
17
|
yirgacheffe/layers/rasters.py,sha256=8mAbH49RtKIoA3h9mxWNbPzo8NJWDSfoRPT7fpkTJ4I,12328
|
|
18
18
|
yirgacheffe/layers/rescaled.py,sha256=kWJlu7DuUB3nRDt3VtbJKiqBDQb2Ba8xzIIXTvOGdK8,2945
|
|
19
19
|
yirgacheffe/layers/vectors.py,sha256=JOqM7Ym53ZdxWKpBJac-opPp2N_ynMfet1Xtsi85dpM,15087
|
|
20
|
-
yirgacheffe-1.3.
|
|
21
|
-
yirgacheffe-1.3.
|
|
22
|
-
yirgacheffe-1.3.
|
|
23
|
-
yirgacheffe-1.3.
|
|
24
|
-
yirgacheffe-1.3.
|
|
25
|
-
yirgacheffe-1.3.
|
|
20
|
+
yirgacheffe-1.3.3.dist-info/licenses/LICENSE,sha256=dNSHwUCJr6axStTKDEdnJtfmDdFqlE3h1NPCveqPfnY,757
|
|
21
|
+
yirgacheffe-1.3.3.dist-info/METADATA,sha256=738pvuHHiNO0juyHkUq3TWrsPDf4oESM5zhZtuKc8IM,20496
|
|
22
|
+
yirgacheffe-1.3.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
23
|
+
yirgacheffe-1.3.3.dist-info/entry_points.txt,sha256=j4KgHXbVGbGyfTySc1ypBdERpfihO4WNjppvCdE9HjE,52
|
|
24
|
+
yirgacheffe-1.3.3.dist-info/top_level.txt,sha256=9DBFlKO2Ld3hG6TuE3qOTd3Tt8ugTiXil4AN4Wr9_y0,12
|
|
25
|
+
yirgacheffe-1.3.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|