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.
- {yirgacheffe-1.7.1/yirgacheffe.egg-info → yirgacheffe-1.7.2}/PKG-INFO +1 -1
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/pyproject.toml +1 -1
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/tests/test_operators.py +46 -34
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/yirgacheffe/operators.py +8 -4
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2/yirgacheffe.egg-info}/PKG-INFO +1 -1
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/LICENSE +0 -0
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/MANIFEST.in +0 -0
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/README.md +0 -0
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/setup.cfg +0 -0
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/tests/test_area.py +0 -0
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/tests/test_auto_windowing.py +0 -0
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/tests/test_base.py +0 -0
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/tests/test_constants.py +0 -0
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/tests/test_datatypes.py +0 -0
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/tests/test_group.py +0 -0
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/tests/test_h3layer.py +0 -0
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/tests/test_intersection.py +0 -0
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/tests/test_multiband.py +0 -0
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/tests/test_nodata.py +0 -0
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/tests/test_openers.py +0 -0
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/tests/test_optimisation.py +0 -0
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/tests/test_parallel_operators.py +0 -0
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/tests/test_pickle.py +0 -0
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/tests/test_projection.py +0 -0
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/tests/test_raster.py +0 -0
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/tests/test_rescaling.py +0 -0
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/tests/test_rounding.py +0 -0
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/tests/test_save_with_window.py +0 -0
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/tests/test_sum_with_window.py +0 -0
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/tests/test_uniform_area_layer.py +0 -0
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/tests/test_union.py +0 -0
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/tests/test_vectors.py +0 -0
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/tests/test_window.py +0 -0
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/yirgacheffe/__init__.py +0 -0
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/yirgacheffe/_backends/__init__.py +0 -0
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/yirgacheffe/_backends/enumeration.py +0 -0
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/yirgacheffe/_backends/mlx.py +0 -0
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/yirgacheffe/_backends/numpy.py +0 -0
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/yirgacheffe/_core.py +0 -0
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/yirgacheffe/constants.py +0 -0
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/yirgacheffe/layers/__init__.py +0 -0
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/yirgacheffe/layers/area.py +0 -0
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/yirgacheffe/layers/base.py +0 -0
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/yirgacheffe/layers/constant.py +0 -0
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/yirgacheffe/layers/group.py +0 -0
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/yirgacheffe/layers/h3layer.py +0 -0
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/yirgacheffe/layers/rasters.py +0 -0
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/yirgacheffe/layers/rescaled.py +0 -0
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/yirgacheffe/layers/vectors.py +0 -0
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/yirgacheffe/rounding.py +0 -0
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/yirgacheffe/window.py +0 -0
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/yirgacheffe.egg-info/SOURCES.txt +0 -0
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/yirgacheffe.egg-info/dependency_links.txt +0 -0
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/yirgacheffe.egg-info/entry_points.txt +0 -0
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/yirgacheffe.egg-info/requires.txt +0 -0
- {yirgacheffe-1.7.1 → yirgacheffe-1.7.2}/yirgacheffe.egg-info/top_level.txt +0 -0
|
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
|
|
|
6
6
|
|
|
7
7
|
[project]
|
|
8
8
|
name = "yirgacheffe"
|
|
9
|
-
version = "1.7.
|
|
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
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
with
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
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
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
with
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
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)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|