mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Fixed #26417 -- Allowed setting GDALBand data with partial values.
This commit is contained in:
committed by
Tim Graham
parent
03b6947728
commit
870dd1d38b
@@ -483,3 +483,24 @@ class GDALBandTests(SimpleTestCase):
|
||||
else:
|
||||
rsmem.bands[0].nodata_value = None
|
||||
self.assertIsNone(rsmem.bands[0].nodata_value)
|
||||
|
||||
def test_band_data_replication(self):
|
||||
band = GDALRaster({
|
||||
'srid': 4326,
|
||||
'width': 3,
|
||||
'height': 3,
|
||||
'bands': [{'data': range(10, 19), 'nodata_value': 0}],
|
||||
}).bands[0]
|
||||
|
||||
# Variations for input (data, shape, expected result).
|
||||
combos = (
|
||||
([1], (1, 1), [1] * 9),
|
||||
(range(3), (1, 3), [0, 0, 0, 1, 1, 1, 2, 2, 2]),
|
||||
(range(3), (3, 1), [0, 1, 2, 0, 1, 2, 0, 1, 2]),
|
||||
)
|
||||
for combo in combos:
|
||||
band.data(combo[0], shape=combo[1])
|
||||
if numpy:
|
||||
numpy.testing.assert_equal(band.data(), numpy.array(combo[2]).reshape(3, 3))
|
||||
else:
|
||||
self.assertEqual(band.data(), list(combo[2]))
|
||||
|
||||
Reference in New Issue
Block a user