yirgacheffe 1.3.2__tar.gz → 1.3.3__tar.gz

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.

Files changed (52) hide show
  1. {yirgacheffe-1.3.2/yirgacheffe.egg-info → yirgacheffe-1.3.3}/PKG-INFO +4 -1
  2. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3}/README.md +3 -0
  3. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3}/pyproject.toml +1 -1
  4. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3}/tests/test_operators.py +84 -0
  5. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3}/yirgacheffe/backends/enumeration.py +3 -1
  6. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3}/yirgacheffe/backends/mlx.py +6 -0
  7. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3}/yirgacheffe/backends/numpy.py +6 -0
  8. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3}/yirgacheffe/operators.py +24 -0
  9. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3/yirgacheffe.egg-info}/PKG-INFO +4 -1
  10. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3}/LICENSE +0 -0
  11. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3}/MANIFEST.in +0 -0
  12. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3}/setup.cfg +0 -0
  13. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3}/tests/test_area.py +0 -0
  14. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3}/tests/test_auto_windowing.py +0 -0
  15. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3}/tests/test_base.py +0 -0
  16. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3}/tests/test_datatypes.py +0 -0
  17. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3}/tests/test_group.py +0 -0
  18. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3}/tests/test_h3layer.py +0 -0
  19. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3}/tests/test_intersection.py +0 -0
  20. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3}/tests/test_multiband.py +0 -0
  21. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3}/tests/test_optimisation.py +0 -0
  22. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3}/tests/test_parallel_operators.py +0 -0
  23. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3}/tests/test_pickle.py +0 -0
  24. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3}/tests/test_raster.py +0 -0
  25. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3}/tests/test_rescaling.py +0 -0
  26. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3}/tests/test_rounding.py +0 -0
  27. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3}/tests/test_save_with_window.py +0 -0
  28. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3}/tests/test_sum_with_window.py +0 -0
  29. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3}/tests/test_uniform_area_layer.py +0 -0
  30. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3}/tests/test_union.py +0 -0
  31. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3}/tests/test_vectors.py +0 -0
  32. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3}/tests/test_window.py +0 -0
  33. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3}/yirgacheffe/__init__.py +0 -0
  34. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3}/yirgacheffe/backends/__init__.py +0 -0
  35. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3}/yirgacheffe/constants.py +0 -0
  36. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3}/yirgacheffe/h3layer.py +0 -0
  37. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3}/yirgacheffe/layers/__init__.py +0 -0
  38. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3}/yirgacheffe/layers/area.py +0 -0
  39. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3}/yirgacheffe/layers/base.py +0 -0
  40. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3}/yirgacheffe/layers/constant.py +0 -0
  41. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3}/yirgacheffe/layers/group.py +0 -0
  42. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3}/yirgacheffe/layers/h3layer.py +0 -0
  43. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3}/yirgacheffe/layers/rasters.py +0 -0
  44. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3}/yirgacheffe/layers/rescaled.py +0 -0
  45. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3}/yirgacheffe/layers/vectors.py +0 -0
  46. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3}/yirgacheffe/rounding.py +0 -0
  47. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3}/yirgacheffe/window.py +0 -0
  48. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3}/yirgacheffe.egg-info/SOURCES.txt +0 -0
  49. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3}/yirgacheffe.egg-info/dependency_links.txt +0 -0
  50. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3}/yirgacheffe.egg-info/entry_points.txt +0 -0
  51. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3}/yirgacheffe.egg-info/requires.txt +0 -0
  52. {yirgacheffe-1.3.2 → yirgacheffe-1.3.3}/yirgacheffe.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: yirgacheffe
3
- Version: 1.3.2
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
 
@@ -280,9 +280,11 @@ with RasterLayer.layer_from_file('test1.tif') as layer1:
280
280
  The following math operators common to numpy and other libraries are currently supported:
281
281
 
282
282
  * abs
283
+ * ceil
283
284
  * clip
284
285
  * exp
285
286
  * exp2
287
+ * floor
286
288
  * isin
287
289
  * log
288
290
  * log2
@@ -290,6 +292,7 @@ The following math operators common to numpy and other libraries are currently s
290
292
  * maximum
291
293
  * minimum
292
294
  * nan_to_num
295
+ * round
293
296
 
294
297
  Typically these can be invoked either on a layer as a method:
295
298
 
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
6
6
 
7
7
  [project]
8
8
  name = "yirgacheffe"
9
- version = "1.3.2"
9
+ version = "1.3.3"
10
10
  description = "Abstraction of gdal datasets for doing basic math operations"
11
11
  readme = "README.md"
12
12
  authors = [{ name = "Michael Dales", email = "mwd24@cam.ac.uk" }]
@@ -1332,3 +1332,87 @@ def test_simple_conv2d_over_calculated_result(skip) -> None:
1332
1332
 
1333
1333
  # Torch and MLX give slightly different rounding
1334
1334
  assert np.isclose(expected, actual).all()
1335
+
1336
+ def test_floor_method() -> None:
1337
+ data1 = np.array([[1.0, 1.2, 1.5, 1.7], [-1.0, -1.2, -1.5, -1.7]])
1338
+ layer1 = RasterLayer(gdal_dataset_with_data((0.0, 0.0), 0.02, data1))
1339
+ result = RasterLayer.empty_raster_layer_like(layer1)
1340
+
1341
+ comp = layer1.floor()
1342
+ comp.save(result)
1343
+
1344
+ expected = backend.floor_op(backend.promote(data1))
1345
+ backend.eval_op(expected)
1346
+
1347
+ actual = result.read_array(0, 0, 4, 2)
1348
+ assert (expected == actual).all()
1349
+
1350
+ def test_floor_module() -> None:
1351
+ data1 = np.array([[1.0, 1.2, 1.5, 1.7], [-1.0, -1.2, -1.5, -1.7]])
1352
+ layer1 = RasterLayer(gdal_dataset_with_data((0.0, 0.0), 0.02, data1))
1353
+ result = RasterLayer.empty_raster_layer_like(layer1)
1354
+
1355
+ comp = LayerOperation.floor(layer1)
1356
+ comp.save(result)
1357
+
1358
+ expected = backend.floor_op(backend.promote(data1))
1359
+ backend.eval_op(expected)
1360
+
1361
+ actual = result.read_array(0, 0, 4, 2)
1362
+ assert (expected == actual).all()
1363
+
1364
+ def test_round_method() -> None:
1365
+ data1 = np.array([[1.0, 1.2, 1.5, 1.7], [-1.0, -1.2, -1.5, -1.7]])
1366
+ layer1 = RasterLayer(gdal_dataset_with_data((0.0, 0.0), 0.02, data1))
1367
+ result = RasterLayer.empty_raster_layer_like(layer1)
1368
+
1369
+ comp = layer1.round()
1370
+ comp.save(result)
1371
+
1372
+ expected = backend.round_op(backend.promote(data1))
1373
+ backend.eval_op(expected)
1374
+
1375
+ actual = result.read_array(0, 0, 4, 2)
1376
+ assert (expected == actual).all()
1377
+
1378
+ def test_round_module() -> None:
1379
+ data1 = np.array([[1.0, 1.2, 1.5, 1.7], [-1.0, -1.2, -1.5, -1.7]])
1380
+ layer1 = RasterLayer(gdal_dataset_with_data((0.0, 0.0), 0.02, data1))
1381
+ result = RasterLayer.empty_raster_layer_like(layer1)
1382
+
1383
+ comp = LayerOperation.round(layer1)
1384
+ comp.save(result)
1385
+
1386
+ expected = backend.round_op(backend.promote(data1))
1387
+ backend.eval_op(expected)
1388
+
1389
+ actual = result.read_array(0, 0, 4, 2)
1390
+ assert (expected == actual).all()
1391
+
1392
+ def test_ceil_method() -> None:
1393
+ data1 = np.array([[1.0, 1.2, 1.5, 1.7], [-1.0, -1.2, -1.5, -1.7]])
1394
+ layer1 = RasterLayer(gdal_dataset_with_data((0.0, 0.0), 0.02, data1))
1395
+ result = RasterLayer.empty_raster_layer_like(layer1)
1396
+
1397
+ comp = layer1.ceil()
1398
+ comp.save(result)
1399
+
1400
+ expected = backend.ceil_op(backend.promote(data1))
1401
+ backend.eval_op(expected)
1402
+
1403
+ actual = result.read_array(0, 0, 4, 2)
1404
+ assert (expected == actual).all()
1405
+
1406
+ def test_ceil_module() -> None:
1407
+ data1 = np.array([[1.0, 1.2, 1.5, 1.7], [-1.0, -1.2, -1.5, -1.7]])
1408
+ layer1 = RasterLayer(gdal_dataset_with_data((0.0, 0.0), 0.02, data1))
1409
+ result = RasterLayer.empty_raster_layer_like(layer1)
1410
+
1411
+ comp = LayerOperation.ceil(layer1)
1412
+ comp.save(result)
1413
+
1414
+ expected = backend.ceil_op(backend.promote(data1))
1415
+ backend.eval_op(expected)
1416
+
1417
+ actual = result.read_array(0, 0, 4, 2)
1418
+ assert (expected == actual).all()
@@ -35,7 +35,9 @@ class operators(Enum):
35
35
  CONV2D = 30
36
36
  ABS = 31
37
37
  ASTYPE = 32
38
-
38
+ FLOOR = 33
39
+ ROUND = 34
40
+ CEIL = 35
39
41
 
40
42
  class dtype(Enum):
41
43
  Float32 = gdal.GDT_Float32
@@ -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
  }
@@ -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
  }
@@ -121,6 +121,27 @@ class LayerMathMixin:
121
121
  window_op=WindowOperation.NONE,
122
122
  )
123
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
+
124
145
  def log(self):
125
146
  return LayerOperation(
126
147
  self,
@@ -765,3 +786,6 @@ exp2 = LayerOperation.exp2
765
786
  nan_to_num = LayerOperation.nan_to_num
766
787
  isin = LayerOperation.isin
767
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.2
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
 
File without changes
File without changes
File without changes