Commit 3743341c authored by Daniel Scheffler's avatar Daniel Scheffler

Added tests for test_get_subset_2D.

parent 172b79f5
Pipeline #3088 passed with stages
in 1 minute and 24 seconds
......@@ -541,6 +541,24 @@ class Test_GeoarrayFunctions(unittest.TestCase):
sub_gA = gA_2D.get_subset(xslice=slice(2, 5), yslice=slice(None, 3), reset_bandnames=True)
self.assertTrue(list(sub_gA.bandnames), ['B1'])
# test arrays are equal
sub_gA = gA_2D.get_subset(xslice=slice(2, 5), yslice=slice(None, 3))
sub_gA_2D = gA_2D[:3, 2:5]
self.assertTrue(np.array_equal(sub_gA[:], sub_gA_2D))
# test deepcopied arrays (modification of sub_gA.arr must not affect self.testtiff.arr)
sub_gA[:2, :2] = 99
self.assertTrue(np.array_equal(sub_gA[:2, :2], np.full((2, 2), 99, gA_2D.dtype)))
self.assertNotEqual(np.mean(sub_gA_2D[:2, :2]), 99)
self.assertNotEqual(np.std(sub_gA_2D[:2, :2]), 0)
# test metadata
self.assertEqual(sub_gA.meta.bands, 1)
self.assertEqual(len(list(sub_gA.meta.band_meta.values())[0]), 1)
self.assertEqual(len(list(sub_gA.bandnames.keys())), 1)
self.assertNotEqual(sub_gA.gt, gA_2D.gt)
self.assertEqual(sub_gA.prj, gA_2D.prj)
# test not to return GeoArray
out = gA_2D.get_subset(xslice=slice(2, 5), yslice=slice(None, 3), return_GeoArray=False)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment