yirgacheffe 1.7.1__py3-none-any.whl → 1.7.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.

@@ -91,7 +91,7 @@ class YirgacheffeLayer(LayerMathMixin):
91
91
  else:
92
92
  return self._underlying_area
93
93
 
94
- def _get_operation_area(self, projection: Optional[MapProjection]) -> Area:
94
+ def _get_operation_area(self, projection: Optional[MapProjection]=None) -> Area:
95
95
  if self._projection is not None and projection is not None and self._projection != projection:
96
96
  raise ValueError("Calculation projection does not match layer projection")
97
97
  return self.area
@@ -119,11 +119,12 @@ class YirgacheffeLayer(LayerMathMixin):
119
119
  if not all(projections[0] == x for x in projections[1:]):
120
120
  raise ValueError("Not all layers are at the same projectin or pixel scale")
121
121
 
122
+ layer_areas = [x._get_operation_area() for x in layers]
122
123
  intersection = Area(
123
- left=max(x._underlying_area.left for x in layers),
124
- top=min(x._underlying_area.top for x in layers),
125
- right=min(x._underlying_area.right for x in layers),
126
- bottom=max(x._underlying_area.bottom for x in layers)
124
+ left=max(x.left for x in layer_areas),
125
+ top=min(x.top for x in layer_areas),
126
+ right=min(x.right for x in layer_areas),
127
+ bottom=max(x.bottom for x in layer_areas)
127
128
  )
128
129
  if (intersection.left >= intersection.right) or (intersection.bottom >= intersection.top):
129
130
  raise ValueError('No intersection possible')
@@ -142,11 +143,12 @@ class YirgacheffeLayer(LayerMathMixin):
142
143
  if not all(projections[0] == x for x in projections[1:]):
143
144
  raise ValueError("Not all layers are at the same projectin or pixel scale")
144
145
 
146
+ layer_areas = [x._get_operation_area() for x in layers]
145
147
  return Area(
146
- left=min(x._underlying_area.left for x in layers),
147
- top=max(x._underlying_area.top for x in layers),
148
- right=max(x._underlying_area.right for x in layers),
149
- bottom=min(x._underlying_area.bottom for x in layers)
148
+ left=min(x.left for x in layer_areas),
149
+ top=max(x.top for x in layer_areas),
150
+ right=max(x.right for x in layer_areas),
151
+ bottom=min(x.bottom for x in layer_areas)
150
152
  )
151
153
 
152
154
  @property
yirgacheffe/operators.py CHANGED
@@ -251,7 +251,7 @@ class LayerMathMixin:
251
251
  self,
252
252
  filename: Union[Path,str],
253
253
  and_sum: bool = False,
254
- parallelism:Optional[int]=None
254
+ parallelism:Optional[Union[int,bool]]=None
255
255
  ) -> Optional[float]:
256
256
  return LayerOperation(self).to_geotiff(filename, and_sum, parallelism)
257
257
 
@@ -659,7 +659,9 @@ class LayerOperation(LayerMathMixin):
659
659
 
660
660
  if (computation_window.xsize != destination_window.xsize) \
661
661
  or (computation_window.ysize != destination_window.ysize):
662
- raise ValueError("Destination raster window size does not match input raster window size.")
662
+ raise ValueError((f"Destination raster window size does not match input raster window size: "
663
+ f"{(destination_window.xsize, destination_window.ysize)} vs "
664
+ f"{(computation_window.xsize, computation_window.ysize)}"))
663
665
 
664
666
  total = 0.0
665
667
 
@@ -899,7 +901,7 @@ class LayerOperation(LayerMathMixin):
899
901
  self,
900
902
  filename: Union[Path,str],
901
903
  and_sum: bool = False,
902
- parallelism:Optional[int]=None
904
+ parallelism:Optional[Union[int,bool]] = None
903
905
  ) -> Optional[float]:
904
906
  """Saves a calculation to a raster file, optionally also returning the sum of pixels.
905
907
 
@@ -909,8 +911,9 @@ class LayerOperation(LayerMathMixin):
909
911
  Path of the raster to save the result to.
910
912
  and_sum : bool, default=False
911
913
  If true then the function will also calculate the sum of the raster as it goes and return that value.
912
- parallelism : int, optional, default=None
913
- If passed, attempt to use multiple CPU cores up to the number provided.
914
+ parallelism : int or bool, optional, default=None
915
+ If passed, attempt to use multiple CPU cores up to the number provided, or if set to True, yirgacheffe
916
+ will pick a sensible value.
914
917
 
915
918
  Returns
916
919
  -------
@@ -932,6 +935,9 @@ class LayerOperation(LayerMathMixin):
932
935
  if parallelism is None:
933
936
  result = self.save(layer, and_sum=and_sum)
934
937
  else:
938
+ if isinstance(parallelism, bool):
939
+ # Parallel save treats None as "work it out"
940
+ parallelism = None
935
941
  result = self.parallel_save(layer, and_sum=and_sum, parallelism=parallelism)
936
942
 
937
943
  os.makedirs(target_dir, exist_ok=True)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: yirgacheffe
3
- Version: 1.7.1
3
+ Version: 1.7.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
@@ -1,7 +1,7 @@
1
1
  yirgacheffe/__init__.py,sha256=flTXNQQs6k8nboEv9O4eJnlv8kZ11z5zrfWcmUovCLg,537
2
2
  yirgacheffe/_core.py,sha256=2CtRkVOpXBhFnj4fnpwSQBL3lJIvAmQJ4AgsMmKJOSs,4193
3
3
  yirgacheffe/constants.py,sha256=uCWJwec3-ND-zVxYbsk1sdHKANl3ToNCTPg7MZb0j2g,434
4
- yirgacheffe/operators.py,sha256=fqk61NW_BjNuuBVPx_nvxPbgBs839cx6WztGOxrtiuE,35653
4
+ yirgacheffe/operators.py,sha256=FhW6A6AQ-ElzxPT23L9UtX5hv0gcBXBwyri66rMTS-U,36081
5
5
  yirgacheffe/rounding.py,sha256=ggBG4lMyLMtHLW3dBxr3gBCcF2qhRrY5etZiFGlIoqA,2258
6
6
  yirgacheffe/window.py,sha256=0Wy3BT4SZLyviDwzLcX8LYOo2MeZ2zXCWAiJNpMbQpc,9505
7
7
  yirgacheffe/_backends/__init__.py,sha256=jN-2iRrHStnPI6cNL7XhwhsROtI0EaGfIrbF5c-ECV0,334
@@ -10,16 +10,16 @@ yirgacheffe/_backends/mlx.py,sha256=2vOTMqHbQbeqt81Eq_8hxWDXZHaPsDpbXkALRVGEnnw,
10
10
  yirgacheffe/_backends/numpy.py,sha256=cYO628s4-5K_-Bp3CrnHegzYSZfkt2QC8iE9oOOMtvA,4069
11
11
  yirgacheffe/layers/__init__.py,sha256=mYKjw5YTcMNv_hMy7a6K4yRzIuNUbR8WuBTw4WIAmSk,435
12
12
  yirgacheffe/layers/area.py,sha256=OFOM1_dMblzXLW29TwEqfdgSecl6aNs04bKJwUydLH0,3914
13
- yirgacheffe/layers/base.py,sha256=4BjtEBzAHBWu06k-9Q7J1bm11xNILKDgA2cxuARxVyI,14344
13
+ yirgacheffe/layers/base.py,sha256=MPVGEsFRPuRDYtL1OBu7XP26kBDWfpS3RS3twYKBOQc,14381
14
14
  yirgacheffe/layers/constant.py,sha256=XQ1ibeSckAcUOow-dMUlZiW5S2MKeFquOz_m8Y027GI,1437
15
15
  yirgacheffe/layers/group.py,sha256=QyrECH5IthmBVV1debqttNvZGVocE-azdayJsvd6qqI,16096
16
16
  yirgacheffe/layers/h3layer.py,sha256=Ys6F-e4Jre7lbFBYErF_4oidQx22WkWMKpHpQ7pPDTs,9875
17
17
  yirgacheffe/layers/rasters.py,sha256=-yECyz3Odhy1er0ilJ9bfLUseI2cTHfwqhP-H3ImUKo,13365
18
18
  yirgacheffe/layers/rescaled.py,sha256=hkvsd7paDCyUViABxrAXdXPOZegdwiphibkdrBuRclk,3366
19
19
  yirgacheffe/layers/vectors.py,sha256=OpZaV2MgM0v4-CbrCNy_AHv3T2bvV9PFytolIzPPXFc,19900
20
- yirgacheffe-1.7.1.dist-info/licenses/LICENSE,sha256=dNSHwUCJr6axStTKDEdnJtfmDdFqlE3h1NPCveqPfnY,757
21
- yirgacheffe-1.7.1.dist-info/METADATA,sha256=KJuxRRohoo57E8Vcaft3WsItttbVaFK5eAHsf0GRMos,22351
22
- yirgacheffe-1.7.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
23
- yirgacheffe-1.7.1.dist-info/entry_points.txt,sha256=j4KgHXbVGbGyfTySc1ypBdERpfihO4WNjppvCdE9HjE,52
24
- yirgacheffe-1.7.1.dist-info/top_level.txt,sha256=9DBFlKO2Ld3hG6TuE3qOTd3Tt8ugTiXil4AN4Wr9_y0,12
25
- yirgacheffe-1.7.1.dist-info/RECORD,,
20
+ yirgacheffe-1.7.3.dist-info/licenses/LICENSE,sha256=dNSHwUCJr6axStTKDEdnJtfmDdFqlE3h1NPCveqPfnY,757
21
+ yirgacheffe-1.7.3.dist-info/METADATA,sha256=VA_iyH9HrhwwNwHPSCmQc9K54nHPBSCSb6L3Bbvm1Zw,22351
22
+ yirgacheffe-1.7.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
23
+ yirgacheffe-1.7.3.dist-info/entry_points.txt,sha256=j4KgHXbVGbGyfTySc1ypBdERpfihO4WNjppvCdE9HjE,52
24
+ yirgacheffe-1.7.3.dist-info/top_level.txt,sha256=9DBFlKO2Ld3hG6TuE3qOTd3Tt8ugTiXil4AN4Wr9_y0,12
25
+ yirgacheffe-1.7.3.dist-info/RECORD,,