From 65d0d0667608cf6a83ca67ae1eb91ac23f9317a8 Mon Sep 17 00:00:00 2001 From: Michael Dales Date: Thu, 30 Jan 2025 17:17:22 +0000 Subject: [PATCH] Add some more type tests --- tests/test_operators.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/test_operators.py b/tests/test_operators.py index ab86c0c..912697f 100644 --- a/tests/test_operators.py +++ b/tests/test_operators.py @@ -745,15 +745,21 @@ def test_isin_simple_module() -> None: actual = result.read_array(0, 0, 4, 2) assert (expected == actual).all() -def test_layer_comparison_to_value() -> None: +@pytest.mark.parametrize("val", [ + (float(2.0)), + (int(2)), + (np.uint16(2)), + (np.float32(2.0)), +]) +def test_layer_comparison_to_value(val) -> None: data1 = np.array([[1.0, 2.0, 3.0, 4.0], [5.0, 2.0, 7.0, 8.0]]) layer1 = RasterLayer(gdal_dataset_with_data((0.0, 0.0), 0.02, data1)) result = RasterLayer.empty_raster_layer_like(layer1) - comp = layer1 == 2.0 + comp = layer1 == val comp.save(result) - expected = data1 == 2.0 + expected = data1 == val actual = result.read_array(0, 0, 4, 2) assert (expected == actual).all()