Skip to content

Commit

Permalink
Fix test name collision
Browse files Browse the repository at this point in the history
Renamed the writeArrayToRaster series of tests so that none are overridden by any of the others by having the same name.
  • Loading branch information
garlic-os committed Jul 11, 2024
1 parent e4131dc commit 54d1bf1
Showing 1 changed file with 35 additions and 36 deletions.
71 changes: 35 additions & 36 deletions test/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,45 @@ def test_writeArrayToRaster(tmp_path):
band = src.read(1)
noval = src.nodatavals[0]


assert noval == 0
assert np.allclose(band, array)


def test_writeArrayToRaster_2():
test = np.random.randn(10,10,10)
with pytest.raises(RuntimeError):
writeArrayToRaster(test, 'dummy_file')


def test_writeArrayToRaster_3(tmp_path):
test = np.random.randn(10,10)
test = test + test * 1j
with pushd(tmp_path):
fname = os.path.join(tmp_path, 'tmp_file.tif')
writeArrayToRaster(test, fname)
tmp = rio_profile(fname)
assert tmp['dtype'] == np.complex64


def test_writeArrayToRaster_4(tmp_path):
SCENARIO0_DIR = os.path.join(TEST_DIR, "scenario_0")
geotif = os.path.join(SCENARIO0_DIR, 'small_dem.tif')
profile = rio_profile(geotif)
data = rio_open(geotif)
with pushd(tmp_path):
fname = os.path.join(tmp_path, 'tmp_file.nc')
writeArrayToRaster(
data,
fname,
proj=profile['crs'],
gt=profile['transform'],
fmt='nc',
)
new_fname = os.path.join(tmp_path, 'tmp_file.tif')
prof = rio_profile(new_fname)
assert prof['driver'] == 'GTiff'


def test_makePoints0D_cython(make_points_0d_data):
from RAiDER.makePoints import makePoints0D

Expand Down Expand Up @@ -516,41 +550,6 @@ def test_rio_4():
assert len(hd.shape) == 2


def test_writeArrayToRaster_2():
test = np.random.randn(10,10,10)
with pytest.raises(RuntimeError):
writeArrayToRaster(test, 'dummy_file')


def test_writeArrayToRaster_3(tmp_path):
test = np.random.randn(10,10)
test = test + test * 1j
with pushd(tmp_path):
fname = os.path.join(tmp_path, 'tmp_file.tif')
writeArrayToRaster(test, fname)
tmp = rio_profile(fname)
assert tmp['dtype'] == np.complex64


def test_writeArrayToRaster_3(tmp_path):
SCENARIO0_DIR = os.path.join(TEST_DIR, "scenario_0")
geotif = os.path.join(SCENARIO0_DIR, 'small_dem.tif')
profile = rio_profile(geotif)
data = rio_open(geotif)
with pushd(tmp_path):
fname = os.path.join(tmp_path, 'tmp_file.nc')
writeArrayToRaster(
data,
fname,
proj=profile['crs'],
gt=profile['transform'],
fmt='nc',
)
new_fname = os.path.join(tmp_path, 'tmp_file.tif')
prof = rio_profile(new_fname)
assert prof['driver'] == 'GTiff'


def test_robs():
assert robmin([1, 2, 3, np.nan])==1
assert robmin([1,2,3])==1
Expand Down

0 comments on commit 54d1bf1

Please sign in to comment.