yirgacheffe 1.3.1__py3-none-any.whl → 1.3.2__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/constants.py CHANGED
@@ -1 +1,2 @@
1
1
  YSTEP = 512
2
+ MINIMUM_CHUNKS_PER_THREAD = 1
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
@@ -578,6 +579,20 @@ class LayerOperation(LayerMathMixin):
578
579
  def _parallel_save(self, destination_layer, and_sum=False, callback=None, parallelism=None, band=1):
579
580
  assert (destination_layer is not None) or and_sum
580
581
  computation_window = self.window
582
+
583
+ worker_count = parallelism or multiprocessing.cpu_count()
584
+ work_blocks = len(range(0, computation_window.ysize, self.ystep))
585
+ adjusted_blocks = math.ceil(work_blocks / constants.MINIMUM_CHUNKS_PER_THREAD)
586
+ worker_count = min(adjusted_blocks, worker_count)
587
+
588
+ if worker_count == 1:
589
+ if destination_layer:
590
+ return self.save(destination_layer, and_sum, callback, band)
591
+ elif and_sum:
592
+ return self.sum()
593
+ else:
594
+ assert False
595
+
581
596
  if destination_layer is not None:
582
597
  try:
583
598
  band = destination_layer._dataset.GetRasterBand(band)
@@ -615,10 +630,6 @@ class LayerOperation(LayerMathMixin):
615
630
  with multiprocessing.Manager() as manager:
616
631
  with SharedMemoryManager() as smm:
617
632
 
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
633
  mem_sem_cast = []
623
634
  for i in range(worker_count):
624
635
  shared_buf = smm.SharedMemory(size=np_dtype.itemsize * self.ystep * computation_window.xsize)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: yirgacheffe
3
- Version: 1.3.1
3
+ Version: 1.3.2
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
@@ -1,7 +1,7 @@
1
1
  yirgacheffe/__init__.py,sha256=U5AoPk_iWreSCexG2ID-tmSXiJz4_9Lvzbf42DMvT7k,658
2
- yirgacheffe/constants.py,sha256=9ZcFLcir4GhPBBDG2rzLhDtJ0pMzpZYuzE9f-CFeA44,12
2
+ yirgacheffe/constants.py,sha256=WccPcISG1FqL_Kw1tI72BJGjHy6RvEcGEx_I9RK776U,42
3
3
  yirgacheffe/h3layer.py,sha256=MT2hm6n64hzHSeRPvjn-CwErru937ntKXbEU7CIlPSU,91
4
- yirgacheffe/operators.py,sha256=g_QdvaUs5ddaLg2rFIz8otGidTHGktZfBjBV6g7vyBo,27278
4
+ yirgacheffe/operators.py,sha256=f72xFsH6KmmWhrbsU0V7g_jgTJQ4BAaZzDhV7i-wPio,27607
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
@@ -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.1.dist-info/licenses/LICENSE,sha256=dNSHwUCJr6axStTKDEdnJtfmDdFqlE3h1NPCveqPfnY,757
21
- yirgacheffe-1.3.1.dist-info/METADATA,sha256=Z6-RV1V3MjUKE_pKLJlP4H14WAZIDqpB17uV94THEAc,20473
22
- yirgacheffe-1.3.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
23
- yirgacheffe-1.3.1.dist-info/entry_points.txt,sha256=j4KgHXbVGbGyfTySc1ypBdERpfihO4WNjppvCdE9HjE,52
24
- yirgacheffe-1.3.1.dist-info/top_level.txt,sha256=9DBFlKO2Ld3hG6TuE3qOTd3Tt8ugTiXil4AN4Wr9_y0,12
25
- yirgacheffe-1.3.1.dist-info/RECORD,,
20
+ yirgacheffe-1.3.2.dist-info/licenses/LICENSE,sha256=dNSHwUCJr6axStTKDEdnJtfmDdFqlE3h1NPCveqPfnY,757
21
+ yirgacheffe-1.3.2.dist-info/METADATA,sha256=Nb9n3FKLxFJXTZZqrdWZAdfYbCogEMxWrrEEw96zE3M,20473
22
+ yirgacheffe-1.3.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
23
+ yirgacheffe-1.3.2.dist-info/entry_points.txt,sha256=j4KgHXbVGbGyfTySc1ypBdERpfihO4WNjppvCdE9HjE,52
24
+ yirgacheffe-1.3.2.dist-info/top_level.txt,sha256=9DBFlKO2Ld3hG6TuE3qOTd3Tt8ugTiXil4AN4Wr9_y0,12
25
+ yirgacheffe-1.3.2.dist-info/RECORD,,