From 00e2dabf63e1a842764818271e89d7b8891b4526 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 1 Dec 2023 00:58:48 +0100 Subject: [PATCH] BUG: fixes #123 --- pyotb/core.py | 2 +- tests/test_core.py | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/pyotb/core.py b/pyotb/core.py index 9cd9d4e..0b01249 100644 --- a/pyotb/core.py +++ b/pyotb/core.py @@ -764,7 +764,7 @@ class App(OTBObject): dtype: data type to use """ - if not dtype: + if dtype is None: param = self._settings.get(self.input_image_key) if not param: logger.warning( diff --git a/tests/test_core.py b/tests/test_core.py index 8b3f8fa..a84d5eb 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -1,6 +1,7 @@ import pytest import numpy as np +import pyotb from tests_data import * @@ -144,11 +145,17 @@ def test_xy_to_rowcol(): def test_write(): - assert INPUT.write("/dev/shm/test_write.tif", ext_fname="nodata=0") + # Write string filepath + assert INPUT.write("/dev/shm/test_write.tif") + INPUT["out"].filepath.unlink() + # With Path filepath + assert INPUT.write(Path("/dev/shm/test_write.tif")) INPUT["out"].filepath.unlink() - assert INPUT.write(Path("/dev/shm/test_write.tif"), ext_fname="nodata=0") + # Write to uint8 + assert INPUT.write(Path("/dev/shm/test_write.tif"), pixel_type="uint8") + assert INPUT["out"].dtype == "uint8" INPUT["out"].filepath.unlink() - # Frozen + # Write frozen app frozen_app = pyotb.BandMath(INPUT, exp="im1b1", frozen=True) assert frozen_app.write("/dev/shm/test_frozen_app_write.tif") frozen_app["out"].filepath.unlink() -- GitLab