

def test_band_statistics_automatic_refresh(self):
    rsmem = GDALRaster({
        'srid': 4326,
        'width': 2,
        'height': 2,
        'bands': [{
            'data': ([0] * 4),
            'nodata_value': 99,
        }],
    })
    band = rsmem.bands[0]
    self.assertEqual(band.statistics(), (0, 0, 0, 0))
    band.data([1, 1, 0, 0])
    self.assertEqual(band.statistics(), (0.0, 1.0, 0.5, 0.5))
    band.nodata_value = 0
    self.assertEqual(band.statistics(), (1.0, 1.0, 1.0, 0.0))

dataset/ETHPy150Open django/django/tests/gis_tests/gdal_tests/test_raster.py GDALBandTests.test_band_statistics_automatic_refresh/original