From 0538b55d46b85380ffb75f657c1afa7ebc2e778c Mon Sep 17 00:00:00 2001 From: "Sean C. Gillies" Date: Fri, 25 May 2018 11:27:50 -0600 Subject: [PATCH] Make block_shapes and files into lists --- CHANGES.txt | 2 ++ rasterio/_base.pyx | 4 ++-- tests/test_blocks.py | 2 +- tests/test_dataset.py | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index f26827ca..4e336f57 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -66,6 +66,8 @@ New features: Bug fixes: +- The block_shapes and files properties of datasets now return lists instead + of tuples. - The ``--nodata`` option of rio-merge is now passed to the output file (#1345). - The precision keyword arguments for methods in the windows and transform diff --git a/rasterio/_base.pyx b/rasterio/_base.pyx index 25c8b075..e4eafdc0 100644 --- a/rasterio/_base.pyx +++ b/rasterio/_base.pyx @@ -414,7 +414,7 @@ cdef class DatasetBase(object): GDALGetBlockSize(band, &xsize, &ysize) self._block_shapes.append((ysize, xsize)) - return tuple(self._block_shapes) + return list(self._block_shapes) def get_nodatavals(self): cdef GDALRasterBandH band = NULL @@ -1193,7 +1193,7 @@ cdef class DatasetBase(object): file_list = GDALGetFileList(h_dataset) num_items = CSLCount(file_list) try: - return tuple([file_list[i] for i in range(num_items)]) + return list([file_list[i] for i in range(num_items)]) finally: CSLDestroy(file_list) diff --git a/tests/test_blocks.py b/tests/test_blocks.py index b60dab03..e2a3a382 100644 --- a/tests/test_blocks.py +++ b/tests/test_blocks.py @@ -68,7 +68,7 @@ class RasterBlocksTest(unittest.TestCase): def test_blocks(self): with rasterio.open('tests/data/RGB.byte.tif') as s: self.assertEqual(len(s.block_shapes), 3) - self.assertEqual(s.block_shapes, ((3, 791), (3, 791), (3, 791))) + self.assertEqual(s.block_shapes, [(3, 791), (3, 791), (3, 791)]) itr = s.block_windows(1) (j, i), first = next(itr) self.assertEqual((j, i), (0, 0)) diff --git a/tests/test_dataset.py b/tests/test_dataset.py index e9cea635..05ebe7e2 100644 --- a/tests/test_dataset.py +++ b/tests/test_dataset.py @@ -15,7 +15,7 @@ def test_files(data): with open(aux, 'w'): pass with rasterio.open(tif) as src: - assert src.files == (tif, aux) + assert src.files == [tif, aux] def test_handle_closed(path_rgb_byte_tif):