From 0e7d59df3ed6988cd5a45e26414c013ad40c7402 Mon Sep 17 00:00:00 2001 From: Daniel Wiesmann Date: Thu, 3 Dec 2015 11:28:07 +0000 Subject: [PATCH] Refs #25734 -- Relaxed GDALRaster statistics test to use assertAlmostEqual. Some versions of GDAL give slightly different results. --- tests/gis_tests/gdal_tests/test_raster.py | 25 ++++++++++++++--------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/tests/gis_tests/gdal_tests/test_raster.py b/tests/gis_tests/gdal_tests/test_raster.py index 3f281d277e..ea3f423429 100644 --- a/tests/gis_tests/gdal_tests/test_raster.py +++ b/tests/gis_tests/gdal_tests/test_raster.py @@ -318,18 +318,23 @@ class GDALBandTests(unittest.TestCase): self.assertEqual(self.band.datatype(as_string=True), 'GDT_Byte') self.assertEqual(self.band.nodata_value, 15) try: - self.assertEqual( - self.band.statistics(approximate=True), - (0.0, 9.0, 2.842331288343558, 2.3965567248965356) - ) - self.assertEqual( - self.band.statistics(approximate=False, refresh=True), - (0.0, 9.0, 2.828326634228898, 2.4260526986669095) - ) + smin, smax, smean, sstd = self.band.statistics(approximate=True) + self.assertEqual(smin, 0) + self.assertEqual(smax, 9) + self.assertAlmostEqual(smean, 2.842331288343558) + self.assertAlmostEqual(sstd, 2.3965567248965356) + + smin, smax, smean, sstd = self.band.statistics(approximate=False, refresh=True) + self.assertEqual(smin, 0) + self.assertEqual(smax, 9) + self.assertAlmostEqual(smean, 2.828326634228898) + self.assertAlmostEqual(sstd, 2.4260526986669095) + self.assertEqual(self.band.min, 0) self.assertEqual(self.band.max, 9) - self.assertEqual(self.band.mean, 2.8283266342289) - self.assertEqual(self.band.std, 2.4260526986669) + self.assertAlmostEqual(self.band.mean, 2.828326634228898) + self.assertAlmostEqual(self.band.std, 2.4260526986669095) + # Check that statistics are persisted into PAM file on band close self.band = None self.assertTrue(os.path.isfile(pam_file))