Skip to content

Commit

Permalink
FIX: Update with statement.
Browse files Browse the repository at this point in the history
  • Loading branch information
zssherman committed Oct 8, 2024
1 parent cf83ba0 commit cf842f5
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions tests/io/test_output_to_geotiff.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
""" Unit Tests for Py-ART's output_to_geotiff.py module. """

import warnings
from pathlib import Path

import numpy as np
import pytest
from PIL import Image

import pyart

Expand Down Expand Up @@ -157,12 +155,10 @@ def test_write_grid_geotiff_missing_field():
)
def test_write_grid_geotiff_transparent_background():
grid = make_tiny_grid_with_mask()
with pyart.testing.InTemporaryDirectory() as tmpdir:
tmp = Path(tmpdir)
outname = tmp / "transparent_bg.tif"
with pyart.testing.InTemporaryDirectory():
pyart.io.write_grid_geotiff(
grid,
str(outname),
"transparent.foo",
"reflectivity",
rgb=True,
cmap="pyart_HomeyerRainbow",
Expand All @@ -171,22 +167,19 @@ def test_write_grid_geotiff_transparent_background():
transparent_bg=True,
opacity=1,
)
imgname = outname.rename(tmp / "transparent_bg.tiff")
img = Image.open(imgname)
img.show()
with open("transparent.foo", "rb") as f:
assert len(f.read()) > 0


@pytest.mark.skipif(
not pyart.io.output_to_geotiff.IMPORT_FLAG, reason="GDAL is not installed."
)
def test_write_grid_geotiff_opacity():
grid = make_tiny_grid_with_mask()
with pyart.testing.InTemporaryDirectory() as tmpdir:
tmp = Path(tmpdir)
outname = tmp / "opacity.tif"
with pyart.testing.InTemporaryDirectory():
pyart.io.write_grid_geotiff(
grid,
str(outname),
"opacity.foo",
"reflectivity",
rgb=True,
cmap="pyart_HomeyerRainbow",
Expand All @@ -195,6 +188,5 @@ def test_write_grid_geotiff_opacity():
transparent_bg=False,
opacity=0.25,
)
imgname = outname.rename(tmp / "opacity.tiff")
img = Image.open(imgname)
img.show()
with open("opacity.foo", "rb") as f:
assert len(f.read()) > 0

0 comments on commit cf842f5

Please sign in to comment.