yirgacheffe 1.7.1__tar.gz → 1.7.2__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 (56) hide show
  1. {yirgacheffe-1.7.1/yirgacheffe.egg-info → yirgacheffe-1.7.2}/PKG-INFO +1 -1
  2. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/pyproject.toml +1 -1
  3. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/tests/test_operators.py +46 -34
  4. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/yirgacheffe/operators.py +8 -4
  5. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2/yirgacheffe.egg-info}/PKG-INFO +1 -1
  6. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/LICENSE +0 -0
  7. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/MANIFEST.in +0 -0
  8. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/README.md +0 -0
  9. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/setup.cfg +0 -0
  10. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/tests/test_area.py +0 -0
  11. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/tests/test_auto_windowing.py +0 -0
  12. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/tests/test_base.py +0 -0
  13. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/tests/test_constants.py +0 -0
  14. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/tests/test_datatypes.py +0 -0
  15. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/tests/test_group.py +0 -0
  16. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/tests/test_h3layer.py +0 -0
  17. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/tests/test_intersection.py +0 -0
  18. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/tests/test_multiband.py +0 -0
  19. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/tests/test_nodata.py +0 -0
  20. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/tests/test_openers.py +0 -0
  21. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/tests/test_optimisation.py +0 -0
  22. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/tests/test_parallel_operators.py +0 -0
  23. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/tests/test_pickle.py +0 -0
  24. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/tests/test_projection.py +0 -0
  25. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/tests/test_raster.py +0 -0
  26. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/tests/test_rescaling.py +0 -0
  27. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/tests/test_rounding.py +0 -0
  28. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/tests/test_save_with_window.py +0 -0
  29. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/tests/test_sum_with_window.py +0 -0
  30. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/tests/test_uniform_area_layer.py +0 -0
  31. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/tests/test_union.py +0 -0
  32. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/tests/test_vectors.py +0 -0
  33. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/tests/test_window.py +0 -0
  34. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/yirgacheffe/__init__.py +0 -0
  35. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/yirgacheffe/_backends/__init__.py +0 -0
  36. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/yirgacheffe/_backends/enumeration.py +0 -0
  37. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/yirgacheffe/_backends/mlx.py +0 -0
  38. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/yirgacheffe/_backends/numpy.py +0 -0
  39. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/yirgacheffe/_core.py +0 -0
  40. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/yirgacheffe/constants.py +0 -0
  41. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/yirgacheffe/layers/__init__.py +0 -0
  42. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/yirgacheffe/layers/area.py +0 -0
  43. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/yirgacheffe/layers/base.py +0 -0
  44. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/yirgacheffe/layers/constant.py +0 -0
  45. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/yirgacheffe/layers/group.py +0 -0
  46. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/yirgacheffe/layers/h3layer.py +0 -0
  47. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/yirgacheffe/layers/rasters.py +0 -0
  48. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/yirgacheffe/layers/rescaled.py +0 -0
  49. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/yirgacheffe/layers/vectors.py +0 -0
  50. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/yirgacheffe/rounding.py +0 -0
  51. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/yirgacheffe/window.py +0 -0
  52. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/yirgacheffe.egg-info/SOURCES.txt +0 -0
  53. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/yirgacheffe.egg-info/dependency_links.txt +0 -0
  54. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/yirgacheffe.egg-info/entry_points.txt +0 -0
  55. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/yirgacheffe.egg-info/requires.txt +0 -0
  56. {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/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.7.1
3
+ Version: 1.7.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
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
6
6
 
7
7
  [project]
8
8
  name = "yirgacheffe"
9
- version = "1.7.1"
9
+ version = "1.7.2"
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" }]
@@ -1472,42 +1472,54 @@ def test_to_geotiff_single_thread_and_sum() -> None:
1472
1472
  assert (expected == actual).all()
1473
1473
 
1474
1474
  @pytest.mark.skipif(yirgacheffe._backends.BACKEND != "NUMPY", reason="Only applies for numpy")
1475
- def test_to_geotiff_parallel_thread(monkeypatch) -> None:
1476
- data1 = np.array([[1, 2, 3, 4], [5, 6, 7, 8]])
1477
- layer1 = RasterLayer(gdal_dataset_with_data((0.0, 0.0), 0.02, data1))
1478
-
1479
- calc = layer1 * 2
1480
-
1481
- with tempfile.TemporaryDirectory() as tempdir:
1482
- filename = os.path.join(tempdir, "test.tif")
1483
- with monkeypatch.context() as m:
1484
- m.setattr(yirgacheffe.constants, "YSTEP", 1)
1485
- calc.to_geotiff(filename, parallelism=2)
1486
-
1487
- with RasterLayer.layer_from_file(filename) as result:
1488
- expected = data1 * 2
1489
- actual = result.read_array(0, 0, 4, 2)
1490
- assert (expected == actual).all()
1475
+ @pytest.mark.parametrize("parallelism", [
1476
+ 2,
1477
+ True,
1478
+ ])
1479
+ def test_to_geotiff_parallel_thread(monkeypatch, parallelism) -> None:
1480
+ with monkeypatch.context() as m:
1481
+ m.setattr(yirgacheffe.constants, "YSTEP", 1)
1482
+ m.setattr(LayerOperation, "save", None)
1483
+ with tempfile.TemporaryDirectory() as tempdir:
1484
+ data1 = np.array([[1, 2, 3, 4], [5, 6, 7, 8]])
1485
+ src_filename = os.path.join("src.tif")
1486
+ dataset = gdal_dataset_with_data((0.0, 0.0), 0.02, data1, filename=src_filename)
1487
+ dataset.Close()
1488
+ with yirgacheffe.read_raster(src_filename) as layer1:
1489
+ calc = layer1 * 2
1490
+ filename = os.path.join(tempdir, "test.tif")
1491
+ calc.to_geotiff(filename, parallelism=parallelism)
1492
+
1493
+ with RasterLayer.layer_from_file(filename) as result:
1494
+ expected = data1 * 2
1495
+ actual = result.read_array(0, 0, 4, 2)
1496
+ assert (expected == actual).all()
1491
1497
 
1492
1498
  @pytest.mark.skipif(yirgacheffe._backends.BACKEND != "NUMPY", reason="Only applies for numpy")
1493
- def test_to_geotiff_parallel_thread_and_sum(monkeypatch) -> None:
1494
- data1 = np.array([[1, 2, 3, 4], [5, 6, 7, 8]])
1495
- layer1 = RasterLayer(gdal_dataset_with_data((0.0, 0.0), 0.02, data1))
1496
-
1497
- calc = layer1 * 2
1498
-
1499
- with tempfile.TemporaryDirectory() as tempdir:
1500
- filename = os.path.join(tempdir, "test.tif")
1501
- with monkeypatch.context() as m:
1502
- m.setattr(yirgacheffe.constants, "YSTEP", 1)
1503
- actual_sum = calc.to_geotiff(filename, and_sum=True)
1504
-
1505
- assert (data1.sum() * 2) == actual_sum
1506
-
1507
- with RasterLayer.layer_from_file(filename) as result:
1508
- expected = data1 * 2
1509
- actual = result.read_array(0, 0, 4, 2)
1510
- assert (expected == actual).all()
1499
+ @pytest.mark.parametrize("parallelism", [
1500
+ 2,
1501
+ True,
1502
+ ])
1503
+ def test_to_geotiff_parallel_thread_and_sum(monkeypatch, parallelism) -> None:
1504
+ with monkeypatch.context() as m:
1505
+ m.setattr(yirgacheffe.constants, "YSTEP", 1)
1506
+ m.setattr(LayerOperation, "save", None)
1507
+ with tempfile.TemporaryDirectory() as tempdir:
1508
+ data1 = np.array([[1, 2, 3, 4], [5, 6, 7, 8]])
1509
+ src_filename = os.path.join("src.tif")
1510
+ dataset = gdal_dataset_with_data((0.0, 0.0), 0.02, data1, filename=src_filename)
1511
+ dataset.Close()
1512
+ with yirgacheffe.read_raster(src_filename) as layer1:
1513
+ filename = os.path.join(tempdir, "test.tif")
1514
+ calc = layer1 * 2
1515
+ actual_sum = calc.to_geotiff(filename, and_sum=True, parallelism=parallelism)
1516
+
1517
+ assert (data1.sum() * 2) == actual_sum
1518
+
1519
+ with RasterLayer.layer_from_file(filename) as result:
1520
+ expected = data1 * 2
1521
+ actual = result.read_array(0, 0, 4, 2)
1522
+ assert (expected == actual).all()
1511
1523
 
1512
1524
  def test_raster_and_vector() -> None:
1513
1525
  with tempfile.TemporaryDirectory() as tempdir:
@@ -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
 
@@ -899,7 +899,7 @@ class LayerOperation(LayerMathMixin):
899
899
  self,
900
900
  filename: Union[Path,str],
901
901
  and_sum: bool = False,
902
- parallelism:Optional[int]=None
902
+ parallelism:Optional[Union[int,bool]] = None
903
903
  ) -> Optional[float]:
904
904
  """Saves a calculation to a raster file, optionally also returning the sum of pixels.
905
905
 
@@ -909,8 +909,9 @@ class LayerOperation(LayerMathMixin):
909
909
  Path of the raster to save the result to.
910
910
  and_sum : bool, default=False
911
911
  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.
912
+ parallelism : int or bool, optional, default=None
913
+ If passed, attempt to use multiple CPU cores up to the number provided, or if set to True, yirgacheffe
914
+ will pick a sensible value.
914
915
 
915
916
  Returns
916
917
  -------
@@ -932,6 +933,9 @@ class LayerOperation(LayerMathMixin):
932
933
  if parallelism is None:
933
934
  result = self.save(layer, and_sum=and_sum)
934
935
  else:
936
+ if isinstance(parallelism, bool):
937
+ # Parallel save treats None as "work it out"
938
+ parallelism = None
935
939
  result = self.parallel_save(layer, and_sum=and_sum, parallelism=parallelism)
936
940
 
937
941
  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.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
File without changes
File without changes
File without changes
File without changes