mirror of
https://github.com/rasterio/rasterio.git
synced 2025-12-08 17:36:12 +00:00
xfail some pixel value senstivie tests when gdal < 2
This commit is contained in:
parent
b8b5df23b9
commit
d7ea5bfbfe
@ -234,7 +234,7 @@ cdef class DatasetReaderBase(DatasetBase):
|
|||||||
self.height, self.width)
|
self.height, self.width)
|
||||||
|
|
||||||
int_window = windows.int_reshape(window)
|
int_window = windows.int_reshape(window)
|
||||||
win_shape += (int_window.num_rows, int_window.num_cols)
|
win_shape += (int(int_window.num_rows), int(int_window.num_cols))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
win_shape += self.shape
|
win_shape += self.shape
|
||||||
@ -472,7 +472,7 @@ cdef class DatasetReaderBase(DatasetBase):
|
|||||||
self.height, self.width)
|
self.height, self.width)
|
||||||
|
|
||||||
int_window = windows.int_reshape(window)
|
int_window = windows.int_reshape(window)
|
||||||
win_shape += (int_window.num_rows, int_window.num_cols)
|
win_shape += (int(int_window.num_rows), int(int_window.num_cols))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
win_shape += self.shape
|
win_shape += self.shape
|
||||||
|
|||||||
@ -26,7 +26,7 @@ def warn_window_deprecation():
|
|||||||
"""Standard warning about range tuple deprecation"""
|
"""Standard warning about range tuple deprecation"""
|
||||||
warnings.warn(
|
warnings.warn(
|
||||||
"Range tuple window are deprecated. Please switch to Window class",
|
"Range tuple window are deprecated. Please switch to Window class",
|
||||||
DeprecationWarning, stacklevel=2)
|
DeprecationWarning)
|
||||||
|
|
||||||
|
|
||||||
def iter_args(function):
|
def iter_args(function):
|
||||||
|
|||||||
@ -1,12 +1,18 @@
|
|||||||
"""Unittests for rasterio.mask"""
|
"""Unittests for rasterio.mask"""
|
||||||
|
|
||||||
|
from packaging.version import parse
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
import rasterio
|
import rasterio
|
||||||
from rasterio.mask import mask as mask_tool
|
from rasterio.mask import mask as mask_tool
|
||||||
|
|
||||||
|
|
||||||
|
# Custom markers.
|
||||||
|
xfail_pixel_sensitive_gdal2 = pytest.mark.xfail(
|
||||||
|
parse(rasterio.__gdal_version__) < parse('2.0dev'),
|
||||||
|
reason="This test is sensitive to pixel values and requires GDAL 2.0+")
|
||||||
|
|
||||||
|
|
||||||
def test_nodata(basic_image_file, basic_geometry):
|
def test_nodata(basic_image_file, basic_geometry):
|
||||||
nodata_val = 0
|
nodata_val = 0
|
||||||
geometries = [basic_geometry]
|
geometries = [basic_geometry]
|
||||||
@ -24,6 +30,7 @@ def test_no_nodata(basic_image_file, basic_geometry):
|
|||||||
assert(masked.data.all() == default_nodata_val)
|
assert(masked.data.all() == default_nodata_val)
|
||||||
|
|
||||||
|
|
||||||
|
@xfail_pixel_sensitive_gdal2
|
||||||
def test_crop(basic_image, basic_image_file, basic_geometry):
|
def test_crop(basic_image, basic_image_file, basic_geometry):
|
||||||
geometries = [basic_geometry]
|
geometries = [basic_geometry]
|
||||||
with rasterio.open(basic_image_file, "r") as src:
|
with rasterio.open(basic_image_file, "r") as src:
|
||||||
@ -37,6 +44,7 @@ def test_crop(basic_image, basic_image_file, basic_geometry):
|
|||||||
assert (masked[0] == image[2:5, 2:5]).all()
|
assert (masked[0] == image[2:5, 2:5]).all()
|
||||||
|
|
||||||
|
|
||||||
|
@xfail_pixel_sensitive_gdal2
|
||||||
def test_crop_all_touched(basic_image, basic_image_file, basic_geometry):
|
def test_crop_all_touched(basic_image, basic_image_file, basic_geometry):
|
||||||
geometries = [basic_geometry]
|
geometries = [basic_geometry]
|
||||||
with rasterio.open(basic_image_file, "r") as src:
|
with rasterio.open(basic_image_file, "r") as src:
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import warnings
|
|||||||
|
|
||||||
from affine import Affine
|
from affine import Affine
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
from packaging.version import parse
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
import rasterio
|
import rasterio
|
||||||
@ -19,6 +20,12 @@ DEFAULT_SHAPE = (10, 10)
|
|||||||
logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)
|
logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)
|
||||||
|
|
||||||
|
|
||||||
|
# Custom markers.
|
||||||
|
xfail_without_gdal2 = pytest.mark.xfail(
|
||||||
|
parse(rasterio.__gdal_version__) < parse('2.0dev'),
|
||||||
|
reason="This test is sensitive to pixel values and requires GDAL 2.0+")
|
||||||
|
|
||||||
|
|
||||||
def bbox(*args):
|
def bbox(*args):
|
||||||
return ' '.join([str(x) for x in args])
|
return ' '.join([str(x) for x in args])
|
||||||
|
|
||||||
@ -169,6 +176,7 @@ def test_mask_invalid_geojson(runner, tmpdir, pixelated_image_file):
|
|||||||
assert 'Invalid GeoJSON' in result.output
|
assert 'Invalid GeoJSON' in result.output
|
||||||
|
|
||||||
|
|
||||||
|
@xfail_without_gdal2
|
||||||
def test_mask_crop(runner, tmpdir, basic_feature, pixelated_image):
|
def test_mask_crop(runner, tmpdir, basic_feature, pixelated_image):
|
||||||
"""
|
"""
|
||||||
In order to test --crop option, we need to use a transform more similar to
|
In order to test --crop option, we need to use a transform more similar to
|
||||||
@ -206,6 +214,7 @@ def test_mask_crop(runner, tmpdir, basic_feature, pixelated_image):
|
|||||||
out.read(1, masked=True).filled(0))
|
out.read(1, masked=True).filled(0))
|
||||||
|
|
||||||
|
|
||||||
|
@xfail_without_gdal2
|
||||||
def test_mask_crop_inverted_y(runner, tmpdir, basic_feature, pixelated_image_file):
|
def test_mask_crop_inverted_y(runner, tmpdir, basic_feature, pixelated_image_file):
|
||||||
"""
|
"""
|
||||||
--crop option should also work if raster has a positive y pixel size
|
--crop option should also work if raster has a positive y pixel size
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import sys
|
|||||||
|
|
||||||
import click
|
import click
|
||||||
from click.testing import CliRunner
|
from click.testing import CliRunner
|
||||||
from packaging.version import Version
|
from packaging.version import Version, parse
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
import rasterio
|
import rasterio
|
||||||
@ -13,9 +13,6 @@ from rasterio.rio.edit_info import (
|
|||||||
from rasterio.rio.main import main_group
|
from rasterio.rio.main import main_group
|
||||||
|
|
||||||
|
|
||||||
logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)
|
|
||||||
|
|
||||||
|
|
||||||
def test_delete_nodata_exclusive_opts(data):
|
def test_delete_nodata_exclusive_opts(data):
|
||||||
"""--unset-nodata and --nodata can't be used together"""
|
"""--unset-nodata and --nodata can't be used together"""
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
@ -34,8 +31,8 @@ def test_delete_crs_exclusive_opts(data):
|
|||||||
assert result.exit_code == 2
|
assert result.exit_code == 2
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.xfail(
|
@pytest.mark.skip(
|
||||||
Version(rasterio.__gdal_version__) < Version('1.10'),
|
parse(rasterio.__gdal_version__) < parse('1.10'),
|
||||||
reason='GDAL version >= 1.10 required')
|
reason='GDAL version >= 1.10 required')
|
||||||
def test_unset_crs(data):
|
def test_unset_crs(data):
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
@ -48,7 +45,7 @@ def test_unset_crs(data):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.skip(
|
@pytest.mark.skip(
|
||||||
Version(rasterio.__gdal_version__) >= Version('1.10'),
|
parse(rasterio.__gdal_version__) >= parse('1.10'),
|
||||||
reason='Test applies to GDAL version < 1.10')
|
reason='Test applies to GDAL version < 1.10')
|
||||||
def test_unset_crs_gdal19(data):
|
def test_unset_crs_gdal19(data):
|
||||||
"""unsetting crs doesn't work for geotiff and gdal 1.9
|
"""unsetting crs doesn't work for geotiff and gdal 1.9
|
||||||
@ -59,7 +56,7 @@ def test_unset_crs_gdal19(data):
|
|||||||
orig_crs = src.crs
|
orig_crs = src.crs
|
||||||
with pytest.warns(UserWarning):
|
with pytest.warns(UserWarning):
|
||||||
result = runner.invoke(main_group,
|
result = runner.invoke(main_group,
|
||||||
['edit-info', inputfile, '--unset-crs'])
|
['edit-info', inputfile, '--unset-crs'])
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
with rasterio.open(inputfile) as src:
|
with rasterio.open(inputfile) as src:
|
||||||
assert src.crs == orig_crs # nochange
|
assert src.crs == orig_crs # nochange
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import logging
|
|||||||
import affine
|
import affine
|
||||||
from click.testing import CliRunner
|
from click.testing import CliRunner
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
from packaging.version import parse
|
||||||
from pytest import fixture
|
from pytest import fixture
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
@ -17,7 +18,10 @@ from rasterio.rio.main import main_group
|
|||||||
from rasterio.transform import Affine
|
from rasterio.transform import Affine
|
||||||
|
|
||||||
|
|
||||||
logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)
|
# Custom markers.
|
||||||
|
xfail_pixel_sensitive_gdal2 = pytest.mark.xfail(
|
||||||
|
parse(rasterio.__gdal_version__) < parse('2.0dev'),
|
||||||
|
reason="This test is sensitive to pixel values and requires GDAL 2.0+")
|
||||||
|
|
||||||
|
|
||||||
# Fixture to create test datasets within temporary directory
|
# Fixture to create test datasets within temporary directory
|
||||||
@ -95,6 +99,7 @@ def test_merge_with_colormap(test_data_dir_1):
|
|||||||
assert cmap[255] == (0, 0, 0, 255)
|
assert cmap[255] == (0, 0, 0, 255)
|
||||||
|
|
||||||
|
|
||||||
|
@xfail_pixel_sensitive_gdal2
|
||||||
def test_merge_with_nodata(test_data_dir_1):
|
def test_merge_with_nodata(test_data_dir_1):
|
||||||
outputname = str(test_data_dir_1.join('merged.tif'))
|
outputname = str(test_data_dir_1.join('merged.tif'))
|
||||||
inputs = [str(x) for x in test_data_dir_1.listdir()]
|
inputs = [str(x) for x in test_data_dir_1.listdir()]
|
||||||
@ -125,6 +130,7 @@ def test_merge_warn(test_data_dir_1):
|
|||||||
assert os.path.exists(outputname)
|
assert os.path.exists(outputname)
|
||||||
|
|
||||||
|
|
||||||
|
@xfail_pixel_sensitive_gdal2
|
||||||
def test_merge_without_nodata(test_data_dir_2):
|
def test_merge_without_nodata(test_data_dir_2):
|
||||||
outputname = str(test_data_dir_2.join('merged.tif'))
|
outputname = str(test_data_dir_2.join('merged.tif'))
|
||||||
inputs = [str(x) for x in test_data_dir_2.listdir()]
|
inputs = [str(x) for x in test_data_dir_2.listdir()]
|
||||||
@ -268,6 +274,10 @@ def test_data_dir_float(tmpdir):
|
|||||||
return tmpdir
|
return tmpdir
|
||||||
|
|
||||||
|
|
||||||
|
@xfail_pixel_sensitive_gdal2
|
||||||
|
@pytest.mark.xfail(
|
||||||
|
os.environ.get('GDALVERSION', 'a.b.c').startswith('1.9'),
|
||||||
|
reason="GDAL 1.9 doesn't catch this error")
|
||||||
def test_merge_float(test_data_dir_float):
|
def test_merge_float(test_data_dir_float):
|
||||||
outputname = str(test_data_dir_float.join('merged.tif'))
|
outputname = str(test_data_dir_float.join('merged.tif'))
|
||||||
inputs = [str(x) for x in test_data_dir_float.listdir()]
|
inputs = [str(x) for x in test_data_dir_float.listdir()]
|
||||||
@ -371,6 +381,7 @@ def test_merge_tiny_output_opt(tiffs):
|
|||||||
assert data[0][3][0] == 40
|
assert data[0][3][0] == 40
|
||||||
|
|
||||||
|
|
||||||
|
@xfail_pixel_sensitive_gdal2
|
||||||
def test_merge_tiny_res_bounds(tiffs):
|
def test_merge_tiny_res_bounds(tiffs):
|
||||||
outputname = str(tiffs.join('merged.tif'))
|
outputname = str(tiffs.join('merged.tif'))
|
||||||
inputs = [str(x) for x in tiffs.listdir()]
|
inputs = [str(x) for x in tiffs.listdir()]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user