yirgacheffe 1.7.7__py3-none-any.whl → 1.7.9__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.

@@ -131,7 +131,7 @@ def conv2d_op(data, weights):
131
131
  return res[0]
132
132
 
133
133
 
134
- def dtype_to_backed(dt):
134
+ def dtype_to_backend(dt):
135
135
  match dt:
136
136
  case dtype.Float32:
137
137
  return mx.float32
@@ -182,7 +182,7 @@ def backend_to_dtype(val):
182
182
  raise ValueError
183
183
 
184
184
  def astype_op(data, datatype):
185
- return data.astype(dtype_to_backed(datatype))
185
+ return data.astype(dtype_to_backend(datatype))
186
186
 
187
187
  operator_map : Dict[op,Callable] = {
188
188
  op.ADD: mx.array.__add__,
@@ -67,7 +67,7 @@ def conv2d_op(data, weights):
67
67
  res = conv(preped_data)
68
68
  return res.detach().numpy()[0][0]
69
69
 
70
- def dtype_to_backed(dt):
70
+ def dtype_to_backend(dt):
71
71
  match dt:
72
72
  case dtype.Float32:
73
73
  return np.float32
@@ -120,7 +120,7 @@ def backend_to_dtype(val):
120
120
  raise ValueError
121
121
 
122
122
  def astype_op(data, datatype):
123
- return data.astype(dtype_to_backed(datatype))
123
+ return data.astype(dtype_to_backend(datatype))
124
124
 
125
125
  operator_map : Dict[op,Callable] = {
126
126
  op.ADD: np.ndarray.__add__,
yirgacheffe/_operators.py CHANGED
@@ -12,7 +12,7 @@ from enum import Enum
12
12
  from multiprocessing import Semaphore, Process
13
13
  from multiprocessing.managers import SharedMemoryManager
14
14
  from pathlib import Path
15
- from typing import Callable, Dict, Optional, Union
15
+ from typing import Callable, Dict, List, Optional, Union
16
16
 
17
17
  import deprecation
18
18
  import numpy as np
@@ -26,6 +26,8 @@ from .window import Area, PixelScale, MapProjection, Window
26
26
  from ._backends import backend
27
27
  from ._backends.enumeration import operators as op
28
28
  from ._backends.enumeration import dtype as DataType
29
+ from ._backends.numpy import dtype_to_backend as dtype_to_numpy
30
+ from ._backends.numpy import backend_to_dtype as numpy_to_dtype
29
31
 
30
32
  logger = logging.getLogger(__name__)
31
33
  logger.setLevel(logging.WARNING)
@@ -47,6 +49,11 @@ class LayerConstant:
47
49
  def _eval(self, _area, _projection, _index, _step, _target_window):
48
50
  return self.val
49
51
 
52
+ @property
53
+ def datatype(self) -> DataType:
54
+ numpy_type = np.result_type(self.val)
55
+ return numpy_to_dtype(numpy_type)
56
+
50
57
  @property
51
58
  def area(self) -> Area:
52
59
  return Area.world()
@@ -475,8 +482,16 @@ class LayerOperation(LayerMathMixin):
475
482
 
476
483
  @property
477
484
  def datatype(self) -> DataType:
478
- # TODO: Work out how to indicate type promotion via numpy
479
- return self.lhs.datatype
485
+ internal_types: List[DataType] = [
486
+ self.lhs.datatype
487
+ ]
488
+ if self.rhs is not None:
489
+ internal_types.append(self.rhs.datatype)
490
+ if self.other is not None:
491
+ internal_types.append(self.other.datatype)
492
+ internal_types_as_numpy_types = [dtype_to_numpy(x) for x in internal_types]
493
+ coerced_type = np.result_type(*internal_types_as_numpy_types)
494
+ return numpy_to_dtype(coerced_type)
480
495
 
481
496
  @property
482
497
  @deprecation.deprecated(
@@ -1,5 +1,6 @@
1
1
  from math import ceil, floor
2
- from typing import Any, Optional
2
+ from pathlib import Path
3
+ from typing import Any, Optional, Union
3
4
 
4
5
  import numpy
5
6
  from osgeo import gdal
@@ -18,7 +19,7 @@ class UniformAreaLayer(RasterLayer):
18
19
  """
19
20
 
20
21
  @staticmethod
21
- def generate_narrow_area_projection(source_filename: str, target_filename: str) -> None:
22
+ def generate_narrow_area_projection(source_filename: Union[Path,str], target_filename: Union[Path,str]) -> None:
22
23
  source = gdal.Open(source_filename, gdal.GA_ReadOnly)
23
24
  if source is None:
24
25
  raise FileNotFoundError(source_filename)
@@ -27,7 +27,7 @@ class RasterLayer(YirgacheffeLayer):
27
27
  area: Area,
28
28
  scale: PixelScale,
29
29
  datatype: Union[int, DataType],
30
- filename: Optional[str]=None,
30
+ filename: Optional[Union[Path,str]]=None,
31
31
  projection: str=WGS_84_PROJECTION,
32
32
  name: Optional[str]=None,
33
33
  compress: bool=True,
@@ -165,7 +165,7 @@ class RasterLayer(YirgacheffeLayer):
165
165
  cls,
166
166
  source: RasterLayer,
167
167
  new_pixel_scale: PixelScale,
168
- filename: Optional[str]=None,
168
+ filename: Optional[Union[Path,str]]=None,
169
169
  compress: bool=True,
170
170
  algorithm: int=gdal.GRA_NearestNeighbour,
171
171
  ) -> RasterLayer:
yirgacheffe/py.typed ADDED
File without changes
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: yirgacheffe
3
- Version: 1.7.7
3
+ Version: 1.7.9
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
@@ -8,24 +8,34 @@ Project-URL: Homepage, https://github.com/quantifyearth/yirgacheffe
8
8
  Project-URL: Repository, https://github.com/quantifyearth/yirgacheffe.git
9
9
  Project-URL: Issues, https://github.com/quantifyearth/yirgacheffe/issues
10
10
  Project-URL: Changelog, https://github.com/quantifyearth/yirgacheffe/blob/main/CHANGES.md
11
- Keywords: gdal,numpy,math
11
+ Keywords: gdal,gis,geospatial,declarative
12
+ Classifier: Development Status :: 5 - Production/Stable
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Topic :: Scientific/Engineering :: GIS
12
19
  Requires-Python: >=3.10
13
20
  Description-Content-Type: text/markdown
14
21
  License-File: LICENSE
15
- Requires-Dist: numpy
16
- Requires-Dist: gdal[numpy]
17
- Requires-Dist: scikit-image
22
+ Requires-Dist: numpy<3.0,>=1.24
23
+ Requires-Dist: gdal[numpy]<4.0,>=3.8
24
+ Requires-Dist: scikit-image<1.0,>=0.20
18
25
  Requires-Dist: torch
19
26
  Requires-Dist: dill
20
27
  Requires-Dist: deprecation
21
28
  Requires-Dist: tomli
29
+ Requires-Dist: h3
30
+ Provides-Extra: mlx
31
+ Requires-Dist: mlx; extra == "mlx"
22
32
  Provides-Extra: dev
23
33
  Requires-Dist: mypy; extra == "dev"
24
34
  Requires-Dist: pylint; extra == "dev"
25
35
  Requires-Dist: pytest; extra == "dev"
26
- Requires-Dist: h3; extra == "dev"
27
36
  Requires-Dist: pytest-cov; extra == "dev"
28
- Requires-Dist: mlx; extra == "dev"
37
+ Requires-Dist: build; extra == "dev"
38
+ Requires-Dist: twine; extra == "dev"
29
39
  Dynamic: license-file
30
40
 
31
41
  # Yirgacheffe: a gdal wrapper that does the tricky bits
@@ -1,26 +1,27 @@
1
1
  yirgacheffe/__init__.py,sha256=pY9dqmHHARfY44T-7-7y6Ah97qQHj9_0pgYTItI5TR8,567
2
2
  yirgacheffe/_core.py,sha256=hnACrthBI8OFNoi88-Qnj-4aizBGZstFO7kj-5g9MSU,6083
3
- yirgacheffe/_operators.py,sha256=wI0JPbIQyYjPKAlkfaBfshNx5JVNaTohvjucytWaFw4,35607
3
+ yirgacheffe/_operators.py,sha256=63KZZKTW-Pz0eOBRZUuolWxNNQvPC_sHruAdyo6J5dc,36238
4
4
  yirgacheffe/constants.py,sha256=uCWJwec3-ND-zVxYbsk1sdHKANl3ToNCTPg7MZb0j2g,434
5
5
  yirgacheffe/operators.py,sha256=nw-BpnAwTjCwFtjosa8wKd2MGUuC0PJR5jACFdLhqCg,412
6
+ yirgacheffe/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
7
  yirgacheffe/rounding.py,sha256=ggBG4lMyLMtHLW3dBxr3gBCcF2qhRrY5etZiFGlIoqA,2258
7
8
  yirgacheffe/window.py,sha256=Oxf8VcslLxNacqjUcDHqZLvdMaTnIwuNwjsm1WEOc0g,9503
8
9
  yirgacheffe/_backends/__init__.py,sha256=jN-2iRrHStnPI6cNL7XhwhsROtI0EaGfIrbF5c-ECV0,334
9
10
  yirgacheffe/_backends/enumeration.py,sha256=Jrce2p2n4Wlk5tHBkiWntDnpLSD_0H-bnwgsKXHjkwQ,1018
10
- yirgacheffe/_backends/mlx.py,sha256=kEWcJOhhUQSHkRPljv6s0MYlxcuu-LzLL55Fdd8tIqc,6171
11
- yirgacheffe/_backends/numpy.py,sha256=IdAgK8oFZxjzK1I_-_yXYu_G935920GxpB6oZoJvWvQ,4110
11
+ yirgacheffe/_backends/mlx.py,sha256=6a0S80JCxwiq72hWv-83238NaQykn-vQw_IDRBIBbbw,6173
12
+ yirgacheffe/_backends/numpy.py,sha256=N-Ygpw1lgJJI7xGoRJnB480rR0tst75cOIowubGnSjw,4112
12
13
  yirgacheffe/layers/__init__.py,sha256=mYKjw5YTcMNv_hMy7a6K4yRzIuNUbR8WuBTw4WIAmSk,435
13
- yirgacheffe/layers/area.py,sha256=OFOM1_dMblzXLW29TwEqfdgSecl6aNs04bKJwUydLH0,3914
14
+ yirgacheffe/layers/area.py,sha256=LeLSinB-z2k4ODSfiNJvQnSnMfa8Gn7VnkJrLt50zVU,3970
14
15
  yirgacheffe/layers/base.py,sha256=-7QIfAI3iGlzt-dDLztpRaLrL2sSqB1y2Yw2TdJ9VJM,14426
15
16
  yirgacheffe/layers/constant.py,sha256=8wfyw1JOxr5FQv_M9Jzbd6vW2rjK3AJHmoe-ftDmPlM,1457
16
17
  yirgacheffe/layers/group.py,sha256=hK84oCAweaX2eQP0DXPd_uHj1aVdTD9F-gaCRPfjxmY,16202
17
18
  yirgacheffe/layers/h3layer.py,sha256=t8yC3c8pXU5qbFqsfP76ZX8UHkW9lK4ZgnNm4pwTjls,9886
18
- yirgacheffe/layers/rasters.py,sha256=9Wgvr-WeavU7VELTz5Q-rwWQIN3g5E9TbEY8-yERpjk,13586
19
+ yirgacheffe/layers/rasters.py,sha256=M2DG5-UPbhKsCHL5B2LDncqgb7VP6yzeDfXv_U6EaZo,13610
19
20
  yirgacheffe/layers/rescaled.py,sha256=jbr2GxFy3I29vudX0oyMaFRTimrbEcAPI6dnHvjWpfU,3377
20
21
  yirgacheffe/layers/vectors.py,sha256=c8QWeKF1umBGo5BYyJPl-CN_EfjxdTGNaQJDfAkvTIM,20139
21
- yirgacheffe-1.7.7.dist-info/licenses/LICENSE,sha256=dNSHwUCJr6axStTKDEdnJtfmDdFqlE3h1NPCveqPfnY,757
22
- yirgacheffe-1.7.7.dist-info/METADATA,sha256=FfXMda6MkjVV05yZkV3iBa72wHAu36xvyQQkXb_GQUU,23134
23
- yirgacheffe-1.7.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
24
- yirgacheffe-1.7.7.dist-info/entry_points.txt,sha256=j4KgHXbVGbGyfTySc1ypBdERpfihO4WNjppvCdE9HjE,52
25
- yirgacheffe-1.7.7.dist-info/top_level.txt,sha256=9DBFlKO2Ld3hG6TuE3qOTd3Tt8ugTiXil4AN4Wr9_y0,12
26
- yirgacheffe-1.7.7.dist-info/RECORD,,
22
+ yirgacheffe-1.7.9.dist-info/licenses/LICENSE,sha256=dNSHwUCJr6axStTKDEdnJtfmDdFqlE3h1NPCveqPfnY,757
23
+ yirgacheffe-1.7.9.dist-info/METADATA,sha256=cfrQwtndmOW5MTb28UoWG73U-1j4ufa1SyqoLACr2SA,23618
24
+ yirgacheffe-1.7.9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
25
+ yirgacheffe-1.7.9.dist-info/entry_points.txt,sha256=j4KgHXbVGbGyfTySc1ypBdERpfihO4WNjppvCdE9HjE,52
26
+ yirgacheffe-1.7.9.dist-info/top_level.txt,sha256=9DBFlKO2Ld3hG6TuE3qOTd3Tt8ugTiXil4AN4Wr9_y0,12
27
+ yirgacheffe-1.7.9.dist-info/RECORD,,