Skip to content

Commit

Permalink
Added image-dimension tolerance
Browse files Browse the repository at this point in the history
  • Loading branch information
kcartier-wri committed Aug 9, 2024
1 parent 981852d commit 67957f3
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions tests/test_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from city_metrix.layers.layer import get_image_collection
from tests.fixtures.bbox_constants import BBOX_BRAZIL_LAURO_DE_FREITAS_1

EE_IMAGE_DIMENSION_TOLERANCE = 1 # Tolerance compensates for variable results from GEE service

def test_albedo():
assert Albedo().get_data(BBOX_BRAZIL_LAURO_DE_FREITAS_1).mean()
Expand Down Expand Up @@ -58,13 +59,18 @@ def test_read_image_collection():
expected_y_dimension = 199

assert data.rio.crs == expected_crs
assert data.dims == {"x": expected_x_dimension, "y": expected_y_dimension}
assert (
pytest.approx(expected_x_dimension, rel=EE_IMAGE_DIMENSION_TOLERANCE) == "x",
pytest.approx(expected_y_dimension, rel=EE_IMAGE_DIMENSION_TOLERANCE) == "y"
)


def test_read_image_collection_scale():
ic = ee.ImageCollection("ESA/WorldCover/v100")
data = get_image_collection(ic, BBOX_BRAZIL_LAURO_DE_FREITAS_1, 100, "test")
assert data.dims == {"x": 19, "y": 20}
expected_x_dimension = 19
expected_y_dimension = 20
assert data.dims == {"x": expected_x_dimension, "y": expected_y_dimension}


def test_high_land_surface_temperature():
Expand Down Expand Up @@ -113,9 +119,9 @@ def test_overture_buildings():
assert count


def test_sentinal_2_level2():
sentinal_2_bands = ["green"]
data = Sentinel2Level2(sentinal_2_bands).get_data(BBOX_BRAZIL_LAURO_DE_FREITAS_1)
def test_sentinel_2_level2():
sentinel_2_bands = ["green"]
data = Sentinel2Level2(sentinel_2_bands).get_data(BBOX_BRAZIL_LAURO_DE_FREITAS_1)
assert data.any()


Expand All @@ -124,7 +130,7 @@ def test_smart_surface_lulc():
assert count


def test_tree_canopy_hight():
def test_tree_canopy_height():
count = TreeCanopyHeight().get_data(BBOX_BRAZIL_LAURO_DE_FREITAS_1).count()
assert count

Expand Down

0 comments on commit 67957f3

Please sign in to comment.