yirgacheffe 1.3.3__py3-none-any.whl → 1.3.4__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/operators.py CHANGED
@@ -521,9 +521,17 @@ class LayerOperation(LayerMathMixin):
521
521
  except AttributeError as exc:
522
522
  raise ValueError("Layer must be a raster backed layer") from exc
523
523
 
524
- computation_window = self.window
525
524
  destination_window = destination_layer.window
526
525
 
526
+ # If we're calculating purely from a constant layer, then we don't have a window or area
527
+ # so we should use the destination raster details.
528
+ try:
529
+ computation_window = self.window
530
+ computation_area = self.area
531
+ except AttributeError:
532
+ computation_window = destination_window
533
+ computation_area = destination_layer.area
534
+
527
535
  if (computation_window.xsize != destination_window.xsize) \
528
536
  or (computation_window.ysize != destination_window.ysize):
529
537
  raise ValueError("Destination raster window size does not match input raster window size.")
@@ -536,7 +544,7 @@ class LayerOperation(LayerMathMixin):
536
544
  step=self.ystep
537
545
  if yoffset+step > computation_window.ysize:
538
546
  step = computation_window.ysize - yoffset
539
- chunk = self._eval(self.area, yoffset, step, computation_window)
547
+ chunk = self._eval(computation_area, yoffset, step, computation_window)
540
548
  if isinstance(chunk, (float, int)):
541
549
  chunk = backend.full((step, destination_window.xsize), chunk)
542
550
  band.WriteArray(
@@ -599,7 +607,18 @@ class LayerOperation(LayerMathMixin):
599
607
 
600
608
  def _parallel_save(self, destination_layer, and_sum=False, callback=None, parallelism=None, band=1):
601
609
  assert (destination_layer is not None) or and_sum
602
- computation_window = self.window
610
+ try:
611
+ computation_window = self.window
612
+ except AttributeError:
613
+ # This is most likely because the calculation is on a constant layer (or combination of only constant
614
+ # layers) and there's no real benefit to parallel saving then, so to keep this code from getting yet
615
+ # more complicated just fall back to the single threaded path
616
+ if destination_layer:
617
+ return self.save(destination_layer, and_sum, callback, band)
618
+ elif and_sum:
619
+ return self.sum()
620
+ else:
621
+ assert False
603
622
 
604
623
  worker_count = parallelism or multiprocessing.cpu_count()
605
624
  work_blocks = len(range(0, computation_window.ysize, self.ystep))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: yirgacheffe
3
- Version: 1.3.3
3
+ Version: 1.3.4
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
2
  yirgacheffe/constants.py,sha256=WccPcISG1FqL_Kw1tI72BJGjHy6RvEcGEx_I9RK776U,42
3
3
  yirgacheffe/h3layer.py,sha256=MT2hm6n64hzHSeRPvjn-CwErru937ntKXbEU7CIlPSU,91
4
- yirgacheffe/operators.py,sha256=dWbT_QASfSmEdrf_3y5ytUWVPY0VJk1AvFvkTkrZ-80,28155
4
+ yirgacheffe/operators.py,sha256=KIMYmRl0uJG9LYnmX_uwHhGNfCNOEZlfaXZU7kD1aL4,29081
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.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,,
20
+ yirgacheffe-1.3.4.dist-info/licenses/LICENSE,sha256=dNSHwUCJr6axStTKDEdnJtfmDdFqlE3h1NPCveqPfnY,757
21
+ yirgacheffe-1.3.4.dist-info/METADATA,sha256=tKSbYq3ZonA4FTn9AeYFgAB9AcZOnMBdky7oZ_Vcz60,20496
22
+ yirgacheffe-1.3.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
23
+ yirgacheffe-1.3.4.dist-info/entry_points.txt,sha256=j4KgHXbVGbGyfTySc1ypBdERpfihO4WNjppvCdE9HjE,52
24
+ yirgacheffe-1.3.4.dist-info/top_level.txt,sha256=9DBFlKO2Ld3hG6TuE3qOTd3Tt8ugTiXil4AN4Wr9_y0,12
25
+ yirgacheffe-1.3.4.dist-info/RECORD,,