Skip to content

Commit

Permalink
change None check and add test for comp
Browse files Browse the repository at this point in the history
  • Loading branch information
Antsalacia committed Dec 16, 2024
1 parent 2dd7d8a commit 533c2f9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
6 changes: 3 additions & 3 deletions earthspy/earthspy.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,10 @@ def get_raster_compression(self, raster_compression: Union[None, str]) -> str:
]

# use rasterio compression method as is
if raster_compression.lower() in rasterio_compression_algorithms:
self.raster_compression = raster_compression
elif raster_compression is None:
if raster_compression is None:
self.raster_compression = None
elif raster_compression.lower() in rasterio_compression_algorithms:
self.raster_compression = raster_compression
else:
raise KeyError("Compression algorithm not found")

Expand Down
13 changes: 8 additions & 5 deletions tests/test_earthspy.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,11 @@ def test_merge_rasters() -> None:
# assert len(t3.outputs) == len(t3.split_boxes)


# def test_get_raster_compression(t4) -> None:
# """"""

# comp_def = t4.raster_compression()
# assert comp_def == None
def test_get_raster_compression(t3, t4) -> None:
""""""

comp_def = t3.raster_compression
assert comp_def == None

Check notice

Code scanning / CodeQL

Testing equality to None Note test

Testing for None should use the 'is' operator.

comp_cust = t4.raster_compression
assert comp_cust == "LZW"

0 comments on commit 533c2f9

Please sign in to comment.