internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: rasterio/rasterio

Issue:
rasterio.features.rasterize crashes (segfault) when out_shape has more than two dimensions
I just spent an embarassing amount of time trying to debug a segfault in rasterize, and the cause ended up being that I passed `out_shape` as a 3-d array (e.g. `(1, 21, 18)`), when it should be 2-d (e.g. `(21, 18)`).

The error-causing shape was the same as an array I read from rasterio itself, using dataset.read() with the `window` kwarg set. That is, I had a `band = dataset.read(window=some_window)`, and passed `band.shape` to `rasterize()`.

Should `rasterize()` ever accept a shape with more than two elements? If not, maybe rasterio could fail early with a descriptive message, like it already does if you pass a wrong `dtype`, for example.



Discussion:

Resolving patch:
diff --git a/rasterio/features.py b/rasterio/features.py
--- a/rasterio/features.py
+++ b/rasterio/features.py
@@ -164,7 +164,7 @@ def rasterize(
     shapes : iterable of (geometry, value) pairs or iterable over
         geometries. `geometry` can either be an object that implements
         the geo interface or GeoJSON-like object.
-    out_shape : tuple or list
+    out_shape : tuple or list with 2 integers
         Shape of output numpy ndarray.
     fill : int or float, optional
         Used as fill value for all areas not covered by input
@@ -271,6 +271,10 @@ def format_cast_error(param, dtype):
             raise ValueError(format_cast_error('shape values', out.dtype.name))
 
     elif out_shape is not None:
+
+        if len(out_shape) != 2:
+            raise ValueError('Invalid out_shape, must be 2D')
+
         out = np.empty(out_shape, dtype=dtype)
         out.fill(fill)
 


Test patch:
diff --git a/tests/test_features.py b/tests/test_features.py
--- a/tests/test_features.py
+++ b/tests/test_features.py
@@ -136,6 +136,18 @@ def test_rasterize_invalid_shapes():
         assert 'Invalid geometry object' in str(ex.value)
 
 
+def test_rasterize_invalid_out_shape(basic_geometry):
+    """output array shape must be 2D."""
+    with rasterio.Env():
+        with pytest.raises(ValueError) as ex:
+            rasterize([basic_geometry], out_shape=(1, 10, 10))
+        assert 'Invalid out_shape' in str(ex.value)
+
+        with pytest.raises(ValueError) as ex:
+            rasterize([basic_geometry], out_shape=(10,))
+        assert 'Invalid out_shape' in str(ex.value)
+
+
 def test_rasterize_default_value(basic_geometry, basic_image_2x2):
     """All shapes should rasterize to the default value."""
     default_value = 2
Repository: rasterio/rasterio

Issue:
Single int indexes param in sample method
According to docs the `indexes` param in the `sample` method can be a "list of ints or a single int".

However passing a single int raises this exception: `IndexError: too many indices for array`.



Discussion:

Resolving patch:
diff --git a/rasterio/sample.py b/rasterio/sample.py
--- a/rasterio/sample.py
+++ b/rasterio/sample.py
@@ -3,6 +3,10 @@
 def sample_gen(dataset, xy, indexes=None):
     index = dataset.index
     read = dataset.read
+
+    if isinstance(indexes, int):
+        indexes = [indexes]
+
     for x, y in xy:
         r, c = index(x, y)
         window = ((r, r+1), (c, c+1))


Test patch:
diff --git a/tests/test_sampling.py b/tests/test_sampling.py
--- a/tests/test_sampling.py
+++ b/tests/test_sampling.py
@@ -19,6 +19,12 @@ def test_sampling_indexes():
         assert list(data) == [25]
 
 
+def test_sampling_single_index():
+    with rasterio.open('tests/data/RGB.byte.tif') as src:
+        data = next(src.sample([(220650.0, 2719200.0)], indexes=2))
+        assert list(data) == [25]
+
+
 def test_sampling_type():
     """See https://github.com/mapbox/rasterio/issues/378."""
     with rasterio.open('tests/data/RGB.byte.tif') as src:
Repository: rasterio/rasterio

Issue:
rio overview --ls should not modify file
Currently running `rio overview --ls` to inspect the overviews modifies the file. We could detect the `--ls` option and open in read-only mode. 



Discussion:

Resolving patch:
diff --git a/rasterio/rio/overview.py b/rasterio/rio/overview.py
--- a/rasterio/rio/overview.py
+++ b/rasterio/rio/overview.py
@@ -67,9 +67,8 @@ def overview(ctx, input, build, ls, rebuild, resampling):
 
     """
     with ctx.obj['env']:
-        with rasterio.open(input, 'r+') as dst:
-
-            if ls:
+        if ls:
+            with rasterio.open(input, 'r') as dst:
                 resampling_method = dst.tags(
                     ns='rio_overview').get('resampling') or 'unknown'
 
@@ -77,8 +76,8 @@ def overview(ctx, input, build, ls, rebuild, resampling):
                 for idx in dst.indexes:
                     click.echo("  Band %d: %s (method: '%s')" % (
                         idx, dst.overviews(idx) or 'None', resampling_method))
-
-            elif rebuild:
+        elif rebuild:
+            with rasterio.open(input, 'r+') as dst:
                 # Build the same overviews for all bands.
                 factors = reduce(
                     operator.or_,
@@ -91,8 +90,13 @@ def overview(ctx, input, build, ls, rebuild, resampling):
                 dst.build_overviews(
                     list(factors), Resampling[resampling_method])
 
-            elif build:
+        elif build:
+            with rasterio.open(input, 'r+') as dst:
                 dst.build_overviews(build, Resampling[resampling])
 
                 # Save the resampling method to a tag.
                 dst.update_tags(ns='rio_overview', resampling=resampling)
+
+        else:
+            raise click.UsageError(
+                "Please specify --ls, --rebuild, or --build ...")


Test patch:
diff --git a/tests/test_rio_overview.py b/tests/test_rio_overview.py
--- a/tests/test_rio_overview.py
+++ b/tests/test_rio_overview.py
@@ -66,3 +66,11 @@ def test_rebuild_ls(data):
 
     expected = "  Band 1: [2, 4, 8] (method: 'cubic')\n  Band 2: [2, 4, 8] (method: 'cubic')\n  Band 3: [2, 4, 8] (method: 'cubic')\n"
     assert result.output.endswith(expected)
+
+
+def test_no_args(data):
+    runner = CliRunner()
+    inputfile = str(data.join('RGB.byte.tif'))
+    result = runner.invoke(cli, ['overview', inputfile])
+    assert result.exit_code == 2
+    assert "Please specify --ls, --rebuild, or --build ..." in result.output
Repository: rasterio/rasterio

Issue:
Allow type annotation support for rasterio data types
Recently I've been adding PEP 484 type annotations to my projects and rasterio has proved quite ugly to use as is, the main annoyance being that `rasterio.open` may return objects belonging to three classes (`DatasetReader`, `DatasetWriter` and `BufferedDatasetWriter`) with a non-public base `DatasetBase`, so right now the only option to annotate a generic dataset is:
```
from typing import Union
from rasterio import io

def myfunc(
        ds: Union[io.DatasetReader, io.DatasetWriter, io.BufferedDatasetWriter]
) -> None:
    pass
```

Something like exposing the DatasetBase class inside rasterio would make the above much more readable:
```
import rasterio

def myfunc(ds: rasterio.DatasetBase) -> None:
    pass
```

Would you consider restructuring a bit the dataset classes so that they are easier to use in type annotations? I guess I'm the first one having such a need :)


Discussion:
Seems like a good idea to me. Thanks for the explanation!


Resolving patch:
diff --git a/rasterio/io.py b/rasterio/io.py
--- a/rasterio/io.py
+++ b/rasterio/io.py
@@ -9,7 +9,7 @@
 import warnings
 
 from rasterio._base import (
-    get_dataset_driver, driver_can_create, driver_can_create_copy)
+    DatasetBase, get_dataset_driver, driver_can_create, driver_can_create_copy)
 from rasterio._io import (
     DatasetReaderBase, DatasetWriterBase, BufferedDatasetWriterBase,
     MemoryFileBase)


Test patch:
Repository: rasterio/rasterio

Issue:
Remove dataset's ul method
It's been deprecated since June 2016 (0.36).


Discussion:

Resolving patch:
diff --git a/rasterio/io.py b/rasterio/io.py
--- a/rasterio/io.py
+++ b/rasterio/io.py
@@ -57,17 +57,6 @@ def xy(self, row, col, offset="center"):
         """
         return xy(self.transform, row, col, offset=offset)
 
-    def ul(self, row, col):
-        """Returns the coordinates (x, y) of the upper left corner of a
-        pixel at `row` and `col` in the units of the dataset's
-        coordinate reference system.
-
-        Deprecated; Use `xy(row, col, offset='ul')` instead.
-        """
-        warnings.warn("ul method is deprecated. Use xy(row, col, offset='ul')",
-                      DeprecationWarning)
-        return xy(self.transform, row, col, offset='ul')
-
     def index(self, x, y, op=math.floor, precision=6):
         """
         Returns the (row, col) index of the pixel containing (x, y) given a


Test patch:
Repository: rasterio/rasterio

Issue:
Call GDALOpen() in __init__(), not in start()
In doing so, we fail faster, and won't have semi-functional dataset objects.


Discussion:

Resolving patch:
diff --git a/rasterio/__init__.py b/rasterio/__init__.py
--- a/rasterio/__init__.py
+++ b/rasterio/__init__.py
@@ -280,7 +280,6 @@ def fp_writer(fp):
             else:
                 raise ValueError(
                     "mode must be one of 'r', 'r+', or 'w', not %s" % mode)
-            s.start()
             return s
 
 
diff --git a/rasterio/io.py b/rasterio/io.py
--- a/rasterio/io.py
+++ b/rasterio/io.py
@@ -263,15 +263,13 @@ def open(self, driver=None, width=None, height=None, count=None, crs=None,
         if self.closed:
             raise IOError("I/O operation on closed file.")
         if self.exists():
-            s = DatasetReader(vsi_path, 'r+')
+            return DatasetReader(vsi_path, 'r+')
         else:
             writer = get_writer_for_driver(driver)
-            s = writer(vsi_path, 'w', driver=driver, width=width,
-                       height=height, count=count, crs=crs,
-                       transform=transform, dtype=dtype,
-                       nodata=nodata, **kwargs)
-        s.start()
-        return s
+            return writer(vsi_path, 'w', driver=driver, width=width,
+                          height=height, count=count, crs=crs,
+                          transform=transform, dtype=dtype,
+                          nodata=nodata, **kwargs)
 
     def __enter__(self):
         return self
@@ -308,9 +306,7 @@ def open(self, path):
 
         if self.closed:
             raise IOError("I/O operation on closed file.")
-        s = DatasetReader(vsi_path, 'r')
-        s.start()
-        return s
+        return DatasetReader(vsi_path, 'r')
 
 
 def get_writer_for_driver(driver):


Test patch:
Repository: rasterio/rasterio

Issue:
query params in https url is not working
Hi 

I wanted to use rasterio with a https url that has query-params, for example: https://.....?a=a&b=b
First I wanted to see if gdal supports that kind of url and gdal does, so I looked for the code in rasterio that is responsible for cutting the url, 

It can be found here:
https://github.com/mapbox/rasterio/blob/master/rasterio/vfs.py#L32

I added in my env the following code:
```
          if parts.query:  
             path += "?" + parts.query       
```

and it solved the issue, 

Is there a reason for cutting the querystring?



Thanks, Guy

query params in https url is not working
Hi 

I wanted to use rasterio with a https url that has query-params, for example: https://.....?a=a&b=b
First I wanted to see if gdal supports that kind of url and gdal does, so I looked for the code in rasterio that is responsible for cutting the url, 

It can be found here:
https://github.com/mapbox/rasterio/blob/master/rasterio/vfs.py#L32

I added in my env the following code:
```
          if parts.query:  
             path += "?" + parts.query       
```

and it solved the issue, 

Is there a reason for cutting the querystring?



Thanks, Guy



Discussion:
Would you accept a pull request fixing this?
@Juanlu001 yes, gratefully!
Would you accept a pull request fixing this?
@Juanlu001 yes, gratefully!

Resolving patch:
diff --git a/rasterio/vfs.py b/rasterio/vfs.py
--- a/rasterio/vfs.py
+++ b/rasterio/vfs.py
@@ -41,6 +41,8 @@ def parse_path(uri, vfs=None):
         parts = urlparse(path)
         scheme = parts.scheme
         path = parts.path
+        if parts.query:
+            path += "?" + parts.query
         if parts.netloc and parts.netloc != 'localhost':
             path = parts.netloc + path
         # There are certain URI schemes we favor over GDAL's names.


Test patch:
diff --git a/tests/test_vfs.py b/tests/test_vfs.py
--- a/tests/test_vfs.py
+++ b/tests/test_vfs.py
@@ -92,3 +92,9 @@ def test_update_vfs(tmpdir, mode):
     profile.update(count=1, width=1, height=1)
     with pytest.raises(TypeError):
         rasterio.open('zip://{0}'.format(tmpdir), mode, **profile)
+
+
+def test_parse_path_accept_get_params():
+    # See https://github.com/mapbox/rasterio/issues/1121
+    assert parse_path('http://example.com/index?a=1') == (
+        'example.com/index?a=1', None, 'http')
Repository: rasterio/rasterio

Issue:
Support C++11
Relates to https://github.com/sgillies/frs-wheel-builds/issues/25 and https://github.com/Toblerity/Fiona/issues/514

GDAL 2.3 will [require C++11](https://trac.osgeo.org/gdal/changeset/40984).  Attempting to install Rasterio after this change fails with a bunch of warnings like:

```
/home/travis/gdalinstall/gdal-trunk/include/ogr_geometry.h:974:9: warning: override controls (override/final) only available with -std=c++11 or -std=gnu++11 [enabled by default]
             const CPL_OVERRIDE;
             ^
```

The [Travis builds against GDAL trunk](https://travis-ci.org/mapbox/rasterio/jobs/315171560) are currently failing with the same issues.


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -197,6 +197,20 @@ def run(self):
     ext_options['extra_compile_args'] = ['-Wno-unused-parameter',
                                          '-Wno-unused-function']
 
+
+# GDAL 2.3 and newer requires C++11
+if (gdal_major_version, gdal_minor_version) >= (2, 3):
+    cpp11_flag = '-std=c++11'
+
+    # 'extra_compile_args' may not be defined
+    eca = ext_options.get('extra_compile_args', [])
+    eca.append(cpp11_flag)
+    ext_options['extra_compile_args'] = eca
+
+    # Link args are always defined
+    ext_options['extra_link_args'].append(cpp11_flag)
+
+
 cythonize_options = {}
 if os.environ.get('CYTHON_COVERAGE'):
     cythonize_options['compiler_directives'] = {'linetrace': True}


Test patch:
Repository: rasterio/rasterio

Issue:
examples/total.py won't run in Python3
The line `total /= 3` should read instead, `total = total / 3`.



Discussion:

Resolving patch:
diff --git a/examples/sieve.py b/examples/sieve.py
--- a/examples/sieve.py
+++ b/examples/sieve.py
@@ -27,7 +27,7 @@
 
     # Write out the sieved raster.
     kwargs = src.meta
-    kwargs['transform'] = kwargs.pop('affine')
+    kwargs['transform'] = rasterio.transform.guard_transform(kwargs['transform'])
     with rasterio.open('example-sieved.tif', 'w', **kwargs) as dst:
         dst.write(sieved, indexes=1)
 
diff --git a/examples/total.py b/examples/total.py
--- a/examples/total.py
+++ b/examples/total.py
@@ -1,3 +1,4 @@
+from __future__ import division
 import numpy as np
 import rasterio
 import subprocess
@@ -15,7 +16,7 @@
     total = np.zeros(r.shape, dtype=rasterio.uint16)
     for band in (r, g, b):
         total += band
-    total /= 3
+    total = total // 3
 
     # Write the product as a raster band to a new 8-bit file. For keyword
     # arguments, we start with the meta attributes of the source file, but


Test patch:
Repository: rasterio/rasterio

Issue:
Get AttributeError: 'str' object has no attribute 'value' when merge_alg passed as a string in rasterize()
## Expected behavior and actual behavior.

As (still) stated in comments / documentation, one should be able to use a `str` (`'REPLACE` or `ADD`) to characterize the merge algorithms in `features.rasterize()`.
However, the following error is thrown if a string is passed:

`AttributeError: 'str' object has no attribute 'value'`

It seems that from rasterio 1.0b1, `_features/_rasterize.pyx`, features need to be as follows:
```
    merge_alg : str, required  # confusing
        Merge algorithm to use.  One of:
            MergeAlg.replace (default): the new value will overwrite the
                existing value.
            MergeAlg.add: the new value will be added to the existing raster.
```

Switching to one of `MergeAlg.replace`, `MergeAlg.add` solves the problem.

However, it might be interesting to keep the strings for retro-compatibility ?

I guess that a check on the type of the passed argument could raise a more useful warning, and doc should be updated ? I just switched to 1.0b1, so I'm unsure about where the issue should be handled (`.py` or `.pyx`).

## Steps to reproduce the problem.

`rasterize(dataset, merge_alg="REPLACE")`

## Operating system

Ubuntu / Conda

## Rasterio version and provenance

1.0b1



Discussion:

Resolving patch:
diff --git a/rasterio/features.py b/rasterio/features.py
--- a/rasterio/features.py
+++ b/rasterio/features.py
@@ -188,7 +188,7 @@ def rasterize(
         If True, all pixels touched by geometries will be burned in.  If
         false, only pixels whose center is within the polygon or that
         are selected by Bresenham's line algorithm will be burned in.
-    merge_alg : str, optional
+    merge_alg : MergeAlg, optional
         Merge algorithm to use.  One of:
             MergeAlg.replace (default): the new value will overwrite the
                 existing value.


Test patch:
Repository: rasterio/rasterio

Issue:
1.0 RC 1
Hey all, if there aren't any reports of show-stopping bugs in 1.0b4, I'd like to put out a release candidate on Wednesday 6/27.


Discussion:

Resolving patch:
diff --git a/rasterio/__init__.py b/rasterio/__init__.py
--- a/rasterio/__init__.py
+++ b/rasterio/__init__.py
@@ -42,8 +42,8 @@ def emit(self, record):
 import rasterio.path
 
 
-__all__ = ['band', 'open', 'pad']
-__version__ = "1.0b4"
+__all__ = ['band', 'open', 'pad', 'Env']
+__version__ = "1.0rc1"
 __gdal_version__ = gdal_version()
 
 # Rasterio attaches NullHandler to the 'rasterio' logger and its


Test patch:
diff --git a/tests/test_env.py b/tests/test_env.py
--- a/tests/test_env.py
+++ b/tests/test_env.py
@@ -9,7 +9,7 @@
 
 import rasterio
 from rasterio._env import del_gdal_config, get_gdal_config, set_gdal_config
-from rasterio.env import Env, defenv, delenv, getenv, setenv, ensure_env
+from rasterio.env import Env, defenv, delenv, getenv, setenv, ensure_env, ensure_env_credentialled
 from rasterio.env import GDALVersion, require_gdal_version
 from rasterio.errors import EnvError, RasterioIOError, GDALVersionError
 from rasterio.rio.main import main_group
@@ -113,6 +113,24 @@ def f():
     assert f() is True
 
 
+def test_ensure_env_credentialled_decorator(monkeypatch, gdalenv):
+    """Credentialization is ensured by wrapper"""
+    monkeypatch.setenv('AWS_ACCESS_KEY_ID', 'id')
+    monkeypatch.setenv('AWS_SECRET_ACCESS_KEY', 'key')
+    monkeypatch.setenv('AWS_SESSION_TOKEN', 'token')
+
+    @ensure_env_credentialled
+    def f(path):
+        return getenv()
+
+    config = f('s3://foo/bar')
+    assert config['AWS_ACCESS_KEY_ID'] == 'id'
+    assert config['AWS_SECRET_ACCESS_KEY'] == 'key'
+    assert config['AWS_SESSION_TOKEN'] == 'token'
+
+    monkeypatch.undo()
+
+
 def test_no_aws_gdal_config(gdalenv):
     """Trying to set AWS-specific GDAL config options fails."""
     with pytest.raises(EnvError):
Repository: rasterio/rasterio

Issue:
reproject() loses _reproject()'s dst_alpha keyword argument
See `dst_alpa` at https://github.com/mapbox/rasterio/blob/master/rasterio/warp.py#L294.


Discussion:

Resolving patch:
diff --git a/rasterio/warp.py b/rasterio/warp.py
--- a/rasterio/warp.py
+++ b/rasterio/warp.py
@@ -291,7 +291,7 @@ def reproject(source, destination, src_transform=None, gcps=None,
     _reproject(
         source, destination, src_transform=src_transform, gcps=gcps,
         src_crs=src_crs, src_nodata=src_nodata, dst_transform=dst_transform,
-        dst_crs=dst_crs, dst_nodata=dst_nodata, dst_alpa=dst_alpha,
+        dst_crs=dst_crs, dst_nodata=dst_nodata, dst_alpha=dst_alpha,
         src_alpha=src_alpha, resampling=resampling,
         init_dest_nodata=init_dest_nodata, num_threads=num_threads,
         warp_mem_limit=warp_mem_limit, **kwargs)


Test patch:
diff --git a/tests/test_warp.py b/tests/test_warp.py
--- a/tests/test_warp.py
+++ b/tests/test_warp.py
@@ -1247,3 +1247,24 @@ def test_issue1401():
             dst_crs=dst_crs,
             resampling=Resampling.nearest,
             warp_mem_limit=4000)
+
+
+def test_reproject_dst_alpha(path_rgb_msk_byte_tif):
+    """Materialization of external mask succeeds"""
+
+    with rasterio.open(path_rgb_msk_byte_tif) as src:
+
+        nrows, ncols = src.shape
+
+        dst_arr = np.zeros((src.count + 1, nrows, ncols), dtype=np.uint8)
+
+        reproject(
+            rasterio.band(src, src.indexes),
+            dst_arr,
+            src_transform=src.transform,
+            src_crs=src.crs,
+            dst_transform=DST_TRANSFORM,
+            dst_crs={'init': 'EPSG:3857'},
+            dst_alpha=4)
+
+        assert dst_arr[3].any()
Repository: rasterio/rasterio

Issue:
Support bilinear resampling for overviews
GDAL docs omit mention of bilinear for GDALBuildOverviews (https://www.gdal.org/classGDALDataset.html#a2aa6f88b3bbc840a5696236af11dde15) but @vincentsarago found it is supported here: https://github.com/OSGeo/gdal/blob/b68d31418f4826402dc44b52152c0493b682fea8/gdal/gcore/overview.cpp#L2252-L2253.


Discussion:

Resolving patch:
diff --git a/rasterio/__init__.py b/rasterio/__init__.py
--- a/rasterio/__init__.py
+++ b/rasterio/__init__.py
@@ -43,7 +43,7 @@ def emit(self, record):
 
 
 __all__ = ['band', 'open', 'pad', 'Env']
-__version__ = "1.0.3.post1"
+__version__ = "1.0.4"
 __gdal_version__ = gdal_version()
 
 # Rasterio attaches NullHandler to the 'rasterio' logger and its
diff --git a/rasterio/rio/overview.py b/rasterio/rio/overview.py
--- a/rasterio/rio/overview.py
+++ b/rasterio/rio/overview.py
@@ -38,7 +38,7 @@ def build_handler(ctx, param, value):
               is_flag=True, default=False)
 @click.option('--resampling', help="Resampling algorithm.",
               type=click.Choice(
-                  [it.name for it in Resampling if it.value in [0, 2, 5, 6, 7]]),
+                  [it.name for it in Resampling if it.value in [0, 1, 2, 3, 4, 5, 6, 7]]),
               default='nearest', show_default=True)
 @click.pass_context
 def overview(ctx, input, build, ls, rebuild, resampling):


Test patch:
diff --git a/tests/test_overviews.py b/tests/test_overviews.py
--- a/tests/test_overviews.py
+++ b/tests/test_overviews.py
@@ -8,9 +8,9 @@
 
 import rasterio
 from rasterio.enums import Resampling
+from rasterio.env import GDALVersion
 
-
-logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)
+gdal_version = GDALVersion()
 
 
 def test_count_overviews_zero(data):
@@ -40,6 +40,18 @@ def test_build_overviews_two(data):
         assert src.overviews(2) == [2, 4]
         assert src.overviews(3) == [2, 4]
 
+@pytest.mark.xfail(
+    gdal_version < GDALVersion.parse('2.0'),
+    reason="Bilinear resampling not supported by GDAL < 2.0")
+def test_build_overviews_bilinear(data):
+    inputfile = str(data.join('RGB.byte.tif'))
+    with rasterio.open(inputfile, 'r+') as src:
+        overview_factors = [2, 4]
+        src.build_overviews(overview_factors, resampling=Resampling.bilinear)
+        assert src.overviews(1) == [2, 4]
+        assert src.overviews(2) == [2, 4]
+        assert src.overviews(3) == [2, 4]
+
 
 def test_build_overviews_average(data):
     inputfile = str(data.join('RGB.byte.tif'))