We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
fillnodata does not use nodata values
## Expected behavior and actual behavior.

I expected `fillnodata` to automatically use the `source.nodata` value, but it didn't. A workaround is to read the corresponding mask. (See https://github.com/mapbox/rasterio/pull/253#issuecomment-325963662 and on)

## Steps to reproduce the problem.

```
$ rio info N00E006.hgt 
{"bounds": [5.999583333333334, -0.0004166666666667318, 7.000416666666667, 1.0004166666666667], "colorinterp": ["undefined"], "count": 1, "crs": "EPSG:4326", "descriptions": [null], "driver": "SRTMHGT", "dtype": "int16", "height": 1201, "indexes": [1], "lnglat": [6.5, 0.5], "mask_flags": [["nodata"]], "nodata": -32768.0, "res": [0.0008333333333333334, 0.0008333333333333334], "shape": [1201, 1201], "tiled": false, "transform": [0.0008333333333333334, 0.0, 5.999583333333334, 0.0, -0.0008333333333333334, 1.0004166666666667, 0.0, 0.0, 1.0], "units": ["m"], "width": 1201}
$ gdalinfo N00E006.hgt 
Driver: SRTMHGT/SRTMHGT File Format
Files: N00E006.hgt
Size is 1201, 1201
Coordinate System is:
GEOGCS["WGS 84",
    DATUM["WGS_1984",
        SPHEROID["WGS 84",6378137,298.257223563,
            AUTHORITY["EPSG","7030"]],
        TOWGS84[0,0,0,0,0,0,0],
        AUTHORITY["EPSG","6326"]],
    PRIMEM["Greenwich",0,
        AUTHORITY["EPSG","8901"]],
    UNIT["degree",0.0174532925199433,
        AUTHORITY["EPSG","9108"]],
    AUTHORITY["EPSG","4326"]]
Origin = (5.999583333333334,1.000416666666667)
Pixel Size = (0.000833333333333,-0.000833333333333)
Metadata:
  AREA_OR_POINT=Point
Corner Coordinates:
Upper Left  (   5.9995833,   1.0004167) (  5d59'58.50"E,  1d 0' 1.50"N)
Lower Left  (   5.9995833,  -0.0004167) (  5d59'58.50"E,  0d 0' 1.50"S)
Upper Right (   7.0004167,   1.0004167) (  7d 0' 1.50"E,  1d 0' 1.50"N)
Lower Right (   7.0004167,  -0.0004167) (  7d 0' 1.50"E,  0d 0' 1.50"S)
Center      (   6.5000000,   0.5000000) (  6d30' 0.00"E,  0d30' 0.00"N)
Band 1 Block=1201x1 Type=Int16, ColorInterp=Undefined
  NoData Value=-32768
  Unit Type: m
$ python
Python 3.6.2 |Continuum Analytics, Inc.| (default, Jul 20 2017, 13:51:32) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import rasterio
>>> source = rasterio.open("N00E006.hgt", 'r')
>>> source.nodata
-32768.0
>>> from rasterio.fill import fillnodata
>>> data = source.read(1)
>>> source.nodata in data
True
>>> source.nodata in fillnodata(data)
True
>>> (data == fillnodata(data)).all()
True
>>> source.nodata in fillnodata(data, mask=source.read_masks(1))
False
```

## Operating system

Linux Mint, 64bit

## Rasterio version and provenance

1.0a9 manylinux1 wheel installed from PyPI using pip.

```
$ conda list rasterio
# packages in environment at /home/juanlu/.miniconda36/envs/env:
#
rasterio                  1.0a9                     <pip>
$ pip list | grep rasterio
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
rasterio (1.0a9)
$ python -q
>>> import rasterio
>>> rasterio.__version__
'1.0a9'
```

fillnodata does not use nodata values
## Expected behavior and actual behavior.

I expected `fillnodata` to automatically use the `source.nodata` value, but it didn't. A workaround is to read the corresponding mask. (See https://github.com/mapbox/rasterio/pull/253#issuecomment-325963662 and on)

## Steps to reproduce the problem.

```
$ rio info N00E006.hgt 
{"bounds": [5.999583333333334, -0.0004166666666667318, 7.000416666666667, 1.0004166666666667], "colorinterp": ["undefined"], "count": 1, "crs": "EPSG:4326", "descriptions": [null], "driver": "SRTMHGT", "dtype": "int16", "height": 1201, "indexes": [1], "lnglat": [6.5, 0.5], "mask_flags": [["nodata"]], "nodata": -32768.0, "res": [0.0008333333333333334, 0.0008333333333333334], "shape": [1201, 1201], "tiled": false, "transform": [0.0008333333333333334, 0.0, 5.999583333333334, 0.0, -0.0008333333333333334, 1.0004166666666667, 0.0, 0.0, 1.0], "units": ["m"], "width": 1201}
$ gdalinfo N00E006.hgt 
Driver: SRTMHGT/SRTMHGT File Format
Files: N00E006.hgt
Size is 1201, 1201
Coordinate System is:
GEOGCS["WGS 84",
    DATUM["WGS_1984",
        SPHEROID["WGS 84",6378137,298.257223563,
            AUTHORITY["EPSG","7030"]],
        TOWGS84[0,0,0,0,0,0,0],
        AUTHORITY["EPSG","6326"]],
    PRIMEM["Greenwich",0,
        AUTHORITY["EPSG","8901"]],
    UNIT["degree",0.0174532925199433,
        AUTHORITY["EPSG","9108"]],
    AUTHORITY["EPSG","4326"]]
Origin = (5.999583333333334,1.000416666666667)
Pixel Size = (0.000833333333333,-0.000833333333333)
Metadata:
  AREA_OR_POINT=Point
Corner Coordinates:
Upper Left  (   5.9995833,   1.0004167) (  5d59'58.50"E,  1d 0' 1.50"N)
Lower Left  (   5.9995833,  -0.0004167) (  5d59'58.50"E,  0d 0' 1.50"S)
Upper Right (   7.0004167,   1.0004167) (  7d 0' 1.50"E,  1d 0' 1.50"N)
Lower Right (   7.0004167,  -0.0004167) (  7d 0' 1.50"E,  0d 0' 1.50"S)
Center      (   6.5000000,   0.5000000) (  6d30' 0.00"E,  0d30' 0.00"N)
Band 1 Block=1201x1 Type=Int16, ColorInterp=Undefined
  NoData Value=-32768
  Unit Type: m
$ python
Python 3.6.2 |Continuum Analytics, Inc.| (default, Jul 20 2017, 13:51:32) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import rasterio
>>> source = rasterio.open("N00E006.hgt", 'r')
>>> source.nodata
-32768.0
>>> from rasterio.fill import fillnodata
>>> data = source.read(1)
>>> source.nodata in data
True
>>> source.nodata in fillnodata(data)
True
>>> (data == fillnodata(data)).all()
True
>>> source.nodata in fillnodata(data, mask=source.read_masks(1))
False
```

## Operating system

Linux Mint, 64bit

## Rasterio version and provenance

1.0a9 manylinux1 wheel installed from PyPI using pip.

```
$ conda list rasterio
# packages in environment at /home/juanlu/.miniconda36/envs/env:
#
rasterio                  1.0a9                     <pip>
$ pip list | grep rasterio
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
rasterio (1.0a9)
$ python -q
>>> import rasterio
>>> rasterio.__version__
'1.0a9'
```


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `rasterio/fill.py`
Content:
```
1 """Fill holes in raster dataset by interpolation from the edges."""
2 
3 import rasterio
4 from rasterio._fill import _fillnodata
5 from rasterio.env import ensure_env
6 
7 
8 @ensure_env
9 def fillnodata(
10         image,
11         mask=None,
12         max_search_distance=100.0,
13         smoothing_iterations=0):
14     """Fill holes in a raster dataset by interpolation from the edges.
15 
16     This algorithm will interpolate values for all designated nodata
17     pixels (marked by zeros in `mask`). For each pixel a four direction
18     conic search is done to find values to interpolate from (using
19     inverse distance weighting). Once all values are interpolated, zero
20     or more smoothing iterations (3x3 average filters on interpolated
21     pixels) are applied to smooth out artifacts.
22 
23     This algorithm is generally suitable for interpolating missing
24     regions of fairly continuously varying rasters (such as elevation
25     models for instance). It is also suitable for filling small holes
26     and cracks in more irregularly varying images (like aerial photos).
27     It is generally not so great for interpolating a raster from sparse
28     point data.
29 
30     Parameters
31     ----------
32     image : numpy ndarray
33         The source containing nodata holes.
34     mask : numpy ndarray or None
35         A mask band indicating which pixels to interpolate. Pixels to
36         interpolate into are indicated by the value 0. Values > 0
37         indicate areas to use during interpolation. Must be same shape
38         as image. If `None`, a mask will be diagnosed from the source
39         data.
40     max_search_distance : float, optional
41         The maxmimum number of pixels to search in all directions to
42         find values to interpolate from. The default is 100.
43     smoothing_iterations : integer, optional
44         The number of 3x3 smoothing filter passes to run. The default is
45         0.
46 
47     Returns
48     -------
49     out : numpy ndarray
50         The filled raster array.
51     """
52     max_search_distance = float(max_search_distance)
53     smoothing_iterations = int(smoothing_iterations)
54     return _fillnodata(
55         image, mask, max_search_distance, smoothing_iterations)
56
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/rasterio/fill.py b/rasterio/fill.py
--- a/rasterio/fill.py
+++ b/rasterio/fill.py
@@ -3,6 +3,9 @@
 import rasterio
 from rasterio._fill import _fillnodata
 from rasterio.env import ensure_env
+from rasterio import dtypes
+
+from numpy.ma import MaskedArray
 
 
 @ensure_env
@@ -11,7 +14,7 @@
         mask=None,
         max_search_distance=100.0,
         smoothing_iterations=0):
-    """Fill holes in a raster dataset by interpolation from the edges.
+    """Fill holes in raster data by interpolation
 
     This algorithm will interpolate values for all designated nodata
     pixels (marked by zeros in `mask`). For each pixel a four direction
@@ -30,13 +33,16 @@
     Parameters
     ----------
     image : numpy ndarray
-        The source containing nodata holes.
+        The source image with holes to be filled. If a MaskedArray, the
+        inverse of its mask will define the pixels to be filled --
+        unless the ``mask`` argument is not None (see below).`
     mask : numpy ndarray or None
         A mask band indicating which pixels to interpolate. Pixels to
-        interpolate into are indicated by the value 0. Values > 0
-        indicate areas to use during interpolation. Must be same shape
-        as image. If `None`, a mask will be diagnosed from the source
-        data.
+        interpolate into are indicated by the value 0. Values
+        > 0 indicate areas to use during interpolation. Must be same
+        shape as image. This array always takes precedence over the
+        image's mask (see above). If None, the inverse of the image's
+        mask will be used if available.
     max_search_distance : float, optional
         The maxmimum number of pixels to search in all directions to
         find values to interpolate from. The default is 100.
@@ -49,6 +55,16 @@
     out : numpy ndarray
         The filled raster array.
     """
+    if mask is None and isinstance(image, MaskedArray):
+        mask = ~image.mask
+    if not dtypes.is_ndarray(mask):
+        raise ValueError("An mask array is required")
+
+    if isinstance(image, MaskedArray):
+        image = image.data
+    if not dtypes.is_ndarray(image):
+        raise ValueError("An image array is required")
+
     max_search_distance = float(max_search_distance)
     smoothing_iterations = int(smoothing_iterations)
     return _fillnodata(

{"golden_diff": "diff --git a/rasterio/fill.py b/rasterio/fill.py\n--- a/rasterio/fill.py\n+++ b/rasterio/fill.py\n@@ -3,6 +3,9 @@\n import rasterio\n from rasterio._fill import _fillnodata\n from rasterio.env import ensure_env\n+from rasterio import dtypes\n+\n+from numpy.ma import MaskedArray\n \n \n @ensure_env\n@@ -11,7 +14,7 @@\n         mask=None,\n         max_search_distance=100.0,\n         smoothing_iterations=0):\n-    \"\"\"Fill holes in a raster dataset by interpolation from the edges.\n+    \"\"\"Fill holes in raster data by interpolation\n \n     This algorithm will interpolate values for all designated nodata\n     pixels (marked by zeros in `mask`). For each pixel a four direction\n@@ -30,13 +33,16 @@\n     Parameters\n     ----------\n     image : numpy ndarray\n-        The source containing nodata holes.\n+        The source image with holes to be filled. If a MaskedArray, the\n+        inverse of its mask will define the pixels to be filled --\n+        unless the ``mask`` argument is not None (see below).`\n     mask : numpy ndarray or None\n         A mask band indicating which pixels to interpolate. Pixels to\n-        interpolate into are indicated by the value 0. Values > 0\n-        indicate areas to use during interpolation. Must be same shape\n-        as image. If `None`, a mask will be diagnosed from the source\n-        data.\n+        interpolate into are indicated by the value 0. Values\n+        > 0 indicate areas to use during interpolation. Must be same\n+        shape as image. This array always takes precedence over the\n+        image's mask (see above). If None, the inverse of the image's\n+        mask will be used if available.\n     max_search_distance : float, optional\n         The maxmimum number of pixels to search in all directions to\n         find values to interpolate from. The default is 100.\n@@ -49,6 +55,16 @@\n     out : numpy ndarray\n         The filled raster array.\n     \"\"\"\n+    if mask is None and isinstance(image, MaskedArray):\n+        mask = ~image.mask\n+    if not dtypes.is_ndarray(mask):\n+        raise ValueError(\"An mask array is required\")\n+\n+    if isinstance(image, MaskedArray):\n+        image = image.data\n+    if not dtypes.is_ndarray(image):\n+        raise ValueError(\"An image array is required\")\n+\n     max_search_distance = float(max_search_distance)\n     smoothing_iterations = int(smoothing_iterations)\n     return _fillnodata(\n", "issue": "fillnodata does not use nodata values\n## Expected behavior and actual behavior.\r\n\r\nI expected `fillnodata` to automatically use the `source.nodata` value, but it didn't. A workaround is to read the corresponding mask. (See https://github.com/mapbox/rasterio/pull/253#issuecomment-325963662 and on)\r\n\r\n## Steps to reproduce the problem.\r\n\r\n```\r\n$ rio info N00E006.hgt \r\n{\"bounds\": [5.999583333333334, -0.0004166666666667318, 7.000416666666667, 1.0004166666666667], \"colorinterp\": [\"undefined\"], \"count\": 1, \"crs\": \"EPSG:4326\", \"descriptions\": [null], \"driver\": \"SRTMHGT\", \"dtype\": \"int16\", \"height\": 1201, \"indexes\": [1], \"lnglat\": [6.5, 0.5], \"mask_flags\": [[\"nodata\"]], \"nodata\": -32768.0, \"res\": [0.0008333333333333334, 0.0008333333333333334], \"shape\": [1201, 1201], \"tiled\": false, \"transform\": [0.0008333333333333334, 0.0, 5.999583333333334, 0.0, -0.0008333333333333334, 1.0004166666666667, 0.0, 0.0, 1.0], \"units\": [\"m\"], \"width\": 1201}\r\n$ gdalinfo N00E006.hgt \r\nDriver: SRTMHGT/SRTMHGT File Format\r\nFiles: N00E006.hgt\r\nSize is 1201, 1201\r\nCoordinate System is:\r\nGEOGCS[\"WGS 84\",\r\n    DATUM[\"WGS_1984\",\r\n        SPHEROID[\"WGS 84\",6378137,298.257223563,\r\n            AUTHORITY[\"EPSG\",\"7030\"]],\r\n        TOWGS84[0,0,0,0,0,0,0],\r\n        AUTHORITY[\"EPSG\",\"6326\"]],\r\n    PRIMEM[\"Greenwich\",0,\r\n        AUTHORITY[\"EPSG\",\"8901\"]],\r\n    UNIT[\"degree\",0.0174532925199433,\r\n        AUTHORITY[\"EPSG\",\"9108\"]],\r\n    AUTHORITY[\"EPSG\",\"4326\"]]\r\nOrigin = (5.999583333333334,1.000416666666667)\r\nPixel Size = (0.000833333333333,-0.000833333333333)\r\nMetadata:\r\n  AREA_OR_POINT=Point\r\nCorner Coordinates:\r\nUpper Left  (   5.9995833,   1.0004167) (  5d59'58.50\"E,  1d 0' 1.50\"N)\r\nLower Left  (   5.9995833,  -0.0004167) (  5d59'58.50\"E,  0d 0' 1.50\"S)\r\nUpper Right (   7.0004167,   1.0004167) (  7d 0' 1.50\"E,  1d 0' 1.50\"N)\r\nLower Right (   7.0004167,  -0.0004167) (  7d 0' 1.50\"E,  0d 0' 1.50\"S)\r\nCenter      (   6.5000000,   0.5000000) (  6d30' 0.00\"E,  0d30' 0.00\"N)\r\nBand 1 Block=1201x1 Type=Int16, ColorInterp=Undefined\r\n  NoData Value=-32768\r\n  Unit Type: m\r\n$ python\r\nPython 3.6.2 |Continuum Analytics, Inc.| (default, Jul 20 2017, 13:51:32) \r\n[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux\r\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\r\n>>> import rasterio\r\n>>> source = rasterio.open(\"N00E006.hgt\", 'r')\r\n>>> source.nodata\r\n-32768.0\r\n>>> from rasterio.fill import fillnodata\r\n>>> data = source.read(1)\r\n>>> source.nodata in data\r\nTrue\r\n>>> source.nodata in fillnodata(data)\r\nTrue\r\n>>> (data == fillnodata(data)).all()\r\nTrue\r\n>>> source.nodata in fillnodata(data, mask=source.read_masks(1))\r\nFalse\r\n```\r\n\r\n## Operating system\r\n\r\nLinux Mint, 64bit\r\n\r\n## Rasterio version and provenance\r\n\r\n1.0a9 manylinux1 wheel installed from PyPI using pip.\r\n\r\n```\r\n$ conda list rasterio\r\n# packages in environment at /home/juanlu/.miniconda36/envs/env:\r\n#\r\nrasterio                  1.0a9                     <pip>\r\n$ pip list | grep rasterio\r\nDEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.\r\nrasterio (1.0a9)\r\n$ python -q\r\n>>> import rasterio\r\n>>> rasterio.__version__\r\n'1.0a9'\r\n```\r\n\nfillnodata does not use nodata values\n## Expected behavior and actual behavior.\r\n\r\nI expected `fillnodata` to automatically use the `source.nodata` value, but it didn't. A workaround is to read the corresponding mask. (See https://github.com/mapbox/rasterio/pull/253#issuecomment-325963662 and on)\r\n\r\n## Steps to reproduce the problem.\r\n\r\n```\r\n$ rio info N00E006.hgt \r\n{\"bounds\": [5.999583333333334, -0.0004166666666667318, 7.000416666666667, 1.0004166666666667], \"colorinterp\": [\"undefined\"], \"count\": 1, \"crs\": \"EPSG:4326\", \"descriptions\": [null], \"driver\": \"SRTMHGT\", \"dtype\": \"int16\", \"height\": 1201, \"indexes\": [1], \"lnglat\": [6.5, 0.5], \"mask_flags\": [[\"nodata\"]], \"nodata\": -32768.0, \"res\": [0.0008333333333333334, 0.0008333333333333334], \"shape\": [1201, 1201], \"tiled\": false, \"transform\": [0.0008333333333333334, 0.0, 5.999583333333334, 0.0, -0.0008333333333333334, 1.0004166666666667, 0.0, 0.0, 1.0], \"units\": [\"m\"], \"width\": 1201}\r\n$ gdalinfo N00E006.hgt \r\nDriver: SRTMHGT/SRTMHGT File Format\r\nFiles: N00E006.hgt\r\nSize is 1201, 1201\r\nCoordinate System is:\r\nGEOGCS[\"WGS 84\",\r\n    DATUM[\"WGS_1984\",\r\n        SPHEROID[\"WGS 84\",6378137,298.257223563,\r\n            AUTHORITY[\"EPSG\",\"7030\"]],\r\n        TOWGS84[0,0,0,0,0,0,0],\r\n        AUTHORITY[\"EPSG\",\"6326\"]],\r\n    PRIMEM[\"Greenwich\",0,\r\n        AUTHORITY[\"EPSG\",\"8901\"]],\r\n    UNIT[\"degree\",0.0174532925199433,\r\n        AUTHORITY[\"EPSG\",\"9108\"]],\r\n    AUTHORITY[\"EPSG\",\"4326\"]]\r\nOrigin = (5.999583333333334,1.000416666666667)\r\nPixel Size = (0.000833333333333,-0.000833333333333)\r\nMetadata:\r\n  AREA_OR_POINT=Point\r\nCorner Coordinates:\r\nUpper Left  (   5.9995833,   1.0004167) (  5d59'58.50\"E,  1d 0' 1.50\"N)\r\nLower Left  (   5.9995833,  -0.0004167) (  5d59'58.50\"E,  0d 0' 1.50\"S)\r\nUpper Right (   7.0004167,   1.0004167) (  7d 0' 1.50\"E,  1d 0' 1.50\"N)\r\nLower Right (   7.0004167,  -0.0004167) (  7d 0' 1.50\"E,  0d 0' 1.50\"S)\r\nCenter      (   6.5000000,   0.5000000) (  6d30' 0.00\"E,  0d30' 0.00\"N)\r\nBand 1 Block=1201x1 Type=Int16, ColorInterp=Undefined\r\n  NoData Value=-32768\r\n  Unit Type: m\r\n$ python\r\nPython 3.6.2 |Continuum Analytics, Inc.| (default, Jul 20 2017, 13:51:32) \r\n[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux\r\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\r\n>>> import rasterio\r\n>>> source = rasterio.open(\"N00E006.hgt\", 'r')\r\n>>> source.nodata\r\n-32768.0\r\n>>> from rasterio.fill import fillnodata\r\n>>> data = source.read(1)\r\n>>> source.nodata in data\r\nTrue\r\n>>> source.nodata in fillnodata(data)\r\nTrue\r\n>>> (data == fillnodata(data)).all()\r\nTrue\r\n>>> source.nodata in fillnodata(data, mask=source.read_masks(1))\r\nFalse\r\n```\r\n\r\n## Operating system\r\n\r\nLinux Mint, 64bit\r\n\r\n## Rasterio version and provenance\r\n\r\n1.0a9 manylinux1 wheel installed from PyPI using pip.\r\n\r\n```\r\n$ conda list rasterio\r\n# packages in environment at /home/juanlu/.miniconda36/envs/env:\r\n#\r\nrasterio                  1.0a9                     <pip>\r\n$ pip list | grep rasterio\r\nDEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.\r\nrasterio (1.0a9)\r\n$ python -q\r\n>>> import rasterio\r\n>>> rasterio.__version__\r\n'1.0a9'\r\n```\r\n\n", "before_files": [{"content": "\"\"\"Fill holes in raster dataset by interpolation from the edges.\"\"\"\n\nimport rasterio\nfrom rasterio._fill import _fillnodata\nfrom rasterio.env import ensure_env\n\n\n@ensure_env\ndef fillnodata(\n        image,\n        mask=None,\n        max_search_distance=100.0,\n        smoothing_iterations=0):\n    \"\"\"Fill holes in a raster dataset by interpolation from the edges.\n\n    This algorithm will interpolate values for all designated nodata\n    pixels (marked by zeros in `mask`). For each pixel a four direction\n    conic search is done to find values to interpolate from (using\n    inverse distance weighting). Once all values are interpolated, zero\n    or more smoothing iterations (3x3 average filters on interpolated\n    pixels) are applied to smooth out artifacts.\n\n    This algorithm is generally suitable for interpolating missing\n    regions of fairly continuously varying rasters (such as elevation\n    models for instance). It is also suitable for filling small holes\n    and cracks in more irregularly varying images (like aerial photos).\n    It is generally not so great for interpolating a raster from sparse\n    point data.\n\n    Parameters\n    ----------\n    image : numpy ndarray\n        The source containing nodata holes.\n    mask : numpy ndarray or None\n        A mask band indicating which pixels to interpolate. Pixels to\n        interpolate into are indicated by the value 0. Values > 0\n        indicate areas to use during interpolation. Must be same shape\n        as image. If `None`, a mask will be diagnosed from the source\n        data.\n    max_search_distance : float, optional\n        The maxmimum number of pixels to search in all directions to\n        find values to interpolate from. The default is 100.\n    smoothing_iterations : integer, optional\n        The number of 3x3 smoothing filter passes to run. The default is\n        0.\n\n    Returns\n    -------\n    out : numpy ndarray\n        The filled raster array.\n    \"\"\"\n    max_search_distance = float(max_search_distance)\n    smoothing_iterations = int(smoothing_iterations)\n    return _fillnodata(\n        image, mask, max_search_distance, smoothing_iterations)\n", "path": "rasterio/fill.py"}], "after_files": [{"content": "\"\"\"Fill holes in raster dataset by interpolation from the edges.\"\"\"\n\nimport rasterio\nfrom rasterio._fill import _fillnodata\nfrom rasterio.env import ensure_env\nfrom rasterio import dtypes\n\nfrom numpy.ma import MaskedArray\n\n\n@ensure_env\ndef fillnodata(\n        image,\n        mask=None,\n        max_search_distance=100.0,\n        smoothing_iterations=0):\n    \"\"\"Fill holes in raster data by interpolation\n\n    This algorithm will interpolate values for all designated nodata\n    pixels (marked by zeros in `mask`). For each pixel a four direction\n    conic search is done to find values to interpolate from (using\n    inverse distance weighting). Once all values are interpolated, zero\n    or more smoothing iterations (3x3 average filters on interpolated\n    pixels) are applied to smooth out artifacts.\n\n    This algorithm is generally suitable for interpolating missing\n    regions of fairly continuously varying rasters (such as elevation\n    models for instance). It is also suitable for filling small holes\n    and cracks in more irregularly varying images (like aerial photos).\n    It is generally not so great for interpolating a raster from sparse\n    point data.\n\n    Parameters\n    ----------\n    image : numpy ndarray\n        The source image with holes to be filled. If a MaskedArray, the\n        inverse of its mask will define the pixels to be filled --\n        unless the ``mask`` argument is not None (see below).`\n    mask : numpy ndarray or None\n        A mask band indicating which pixels to interpolate. Pixels to\n        interpolate into are indicated by the value 0. Values\n        > 0 indicate areas to use during interpolation. Must be same\n        shape as image. This array always takes precedence over the\n        image's mask (see above). If None, the inverse of the image's\n        mask will be used if available.\n    max_search_distance : float, optional\n        The maxmimum number of pixels to search in all directions to\n        find values to interpolate from. The default is 100.\n    smoothing_iterations : integer, optional\n        The number of 3x3 smoothing filter passes to run. The default is\n        0.\n\n    Returns\n    -------\n    out : numpy ndarray\n        The filled raster array.\n    \"\"\"\n    if mask is None and isinstance(image, MaskedArray):\n        mask = ~image.mask\n    if not dtypes.is_ndarray(mask):\n        raise ValueError(\"An mask array is required\")\n\n    if isinstance(image, MaskedArray):\n        image = image.data\n    if not dtypes.is_ndarray(image):\n        raise ValueError(\"An image array is required\")\n\n    max_search_distance = float(max_search_distance)\n    smoothing_iterations = int(smoothing_iterations)\n    return _fillnodata(\n        image, mask, max_search_distance, smoothing_iterations)\n", "path": "rasterio/fill.py"}]}