Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: be specific about nodata being None #363

Merged
merged 3 commits into from
Feb 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions scripts/files/file_tiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,10 @@ def check_no_data(self, gdalinfo: GdalInfo) -> None:
)

def is_no_data(self, gdalinfo: GdalInfo) -> bool:
"""return True if bands have a "noDataValue" and it is set to 255."""
"""return True if bands have a "noDataValue" set."""
bands = gdalinfo["bands"]
if "noDataValue" in bands[0] and bands[0]["noDataValue"]:
# 0 in noDataValue can return false unless specific here about None
if "noDataValue" in bands[0] and bands[0]["noDataValue"] is not None:
return True
return False

Expand Down
15 changes: 13 additions & 2 deletions scripts/files/tests/file_tiff_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,9 @@ def test_check_no_data_no_value() -> None:
assert file_tiff.get_errors()


def test_is_no_data_true() -> None:
def test_is_no_data_true_255() -> None:
"""
tests is_no_data when the input layer that has no_data value assigned
tests is_no_data when the input layer that has 255 no_data value assigned
"""
gdalinfo = fake_gdal_info()
add_band(gdalinfo, no_data_value=255)
Expand All @@ -166,6 +166,17 @@ def test_is_no_data_true() -> None:
assert file_tiff.is_no_data(gdalinfo)


def test_is_no_data_true_0() -> None:
"""
tests is_no_data when the input layer that has 0 no_data value assigned
"""
gdalinfo = fake_gdal_info()
add_band(gdalinfo, no_data_value=0)

file_tiff = FileTiff("test")
assert file_tiff.is_no_data(gdalinfo)


def test_is_no_data_false() -> None:
"""
tests is_no_data when the input layer that does not have no_data value assigned
Expand Down