From 54d1bf159b7eda11fdd0285c8152b886112451fc Mon Sep 17 00:00:00 2001 From: Nate Kean <14845347+garlic-os@users.noreply.github.com> Date: Thu, 11 Jul 2024 14:37:46 -0500 Subject: [PATCH 1/3] Fix test name collision Renamed the writeArrayToRaster series of tests so that none are overridden by any of the others by having the same name. --- test/test_util.py | 71 +++++++++++++++++++++++------------------------ 1 file changed, 35 insertions(+), 36 deletions(-) diff --git a/test/test_util.py b/test/test_util.py index db538aa86..043a79f22 100644 --- a/test/test_util.py +++ b/test/test_util.py @@ -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 @@ -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 From 46cd20d204031db39013ea665196fd409ee9a18d Mon Sep 17 00:00:00 2001 From: Nate Kean <14845347+garlic-os@users.noreply.github.com> Date: Thu, 11 Jul 2024 15:33:15 -0500 Subject: [PATCH 2/3] Fix code typo --- test/test_util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_util.py b/test/test_util.py index 043a79f22..eae32a734 100644 --- a/test/test_util.py +++ b/test/test_util.py @@ -154,7 +154,7 @@ def test_writeArrayToRaster_3(tmp_path): fname = os.path.join(tmp_path, 'tmp_file.tif') writeArrayToRaster(test, fname) tmp = rio_profile(fname) - assert tmp['dtype'] == np.complex64 + assert tmp['dtype'] == 'complex64' def test_writeArrayToRaster_4(tmp_path): From ea82a1b4a751f97bc11229356ca2636ee01036a5 Mon Sep 17 00:00:00 2001 From: Nate Kean <14845347+garlic-os@users.noreply.github.com> Date: Thu, 11 Jul 2024 16:03:03 -0500 Subject: [PATCH 3/3] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4bc8d2491..04bd09590 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ and uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html). * [657](https://github.com/dbekaert/RAiDER/pull/657) - Fixed a few typos in `README.md`. * [658](https://github.com/dbekaert/RAiDER/pull/658) - Fixed opaque error message if a GUNW file is not produced while HyP3 independently against a previous INSAR_ISCE. * [661](https://github.com/dbekaert/RAiDER/pull/661) - Fixed bug in raiderDownloadGNSS, removed call to scipy.sum, and added unit tests. +* [669](https://github.com/dbekaert/RAiDER/pull/669) - Fixed test name collision (test_writeArrayToRaster). ## [0.5.1] ### Changed