Skip to content

Commit

Permalink
Merge pull request #680 from mapbox/issue-678
Browse files Browse the repository at this point in the history
resolve numpy deprection warnings
  • Loading branch information
sgillies committed May 2, 2016
2 parents b368da7 + 7f27563 commit c80b568
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions rasterio/_io.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -861,9 +861,9 @@ cdef class RasterReader(_base.DatasetReader):
roff = 0
coff = 0
if window[0][0] < 0:
roff = -window[0][0] * scaling_h
roff = int(-window[0][0] * scaling_h)
if window[1][0] < 0:
coff = -window[1][0] * scaling_w
coff = int(-window[1][0] * scaling_w)

for dst, src in zip(
out if len(out.shape) == 3 else [out],
Expand Down
15 changes: 15 additions & 0 deletions tests/test_read_boundless.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import sys

import numpy
import pytest

import rasterio

Expand Down Expand Up @@ -101,3 +102,17 @@ def test_read_boundless_noshift():
r2 = src.read(boundless=True,
window=((-1, src.shape[0] + 1), (100, 101)))[0, 0, 0:9]
assert numpy.array_equal(r1, r2)


def test_numpy_warning(recwarn):
"""Ensure no deprecation warnings
On numpy 1.11 and previous versions of rasterio you might see:
VisibleDeprecationWarning: using a non-integer number
instead of an integer will result in an error in the future
"""
import warnings
warnings.simplefilter('always')
with rasterio.open('tests/data/RGB.byte.tif') as src:
window = ((-10, 100), (-10, 100))
src.read(1, window=window, boundless=True)
assert len(recwarn) == 0

0 comments on commit c80b568

Please sign in to comment.