mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-21 12:50:27 +08:00
Use safe_as_int to check provided output shape
This commit is contained in:
@@ -3,7 +3,7 @@ import numpy as np
|
||||
__all__ = ['_safe_as_int']
|
||||
|
||||
|
||||
def _safe_as_int(val, atol=1e-7):
|
||||
def safe_as_int(val, atol=1e-3):
|
||||
"""
|
||||
Attempt to safely cast values to integer format.
|
||||
|
||||
@@ -5,8 +5,10 @@ import sys
|
||||
import six
|
||||
|
||||
from ._warnings import all_warnings
|
||||
from ._safe_as_int import safe_as_int
|
||||
|
||||
__all__ = ['deprecated', 'get_bound_method_class', 'all_warnings']
|
||||
__all__ = ['deprecated', 'get_bound_method_class', 'all_warnings',
|
||||
'safe_as_int']
|
||||
|
||||
|
||||
class skimage_deprecation(Warning):
|
||||
|
||||
@@ -4,7 +4,7 @@ import warnings
|
||||
import numpy as np
|
||||
from scipy import ndimage, spatial
|
||||
|
||||
from skimage._shared.utils import get_bound_method_class
|
||||
from skimage._shared.utils import get_bound_method_class, safe_as_int
|
||||
from skimage.util import img_as_float
|
||||
from ._warps_cy import _warp_fast
|
||||
|
||||
@@ -1078,7 +1078,7 @@ def warp(image, inverse_map=None, map_args={}, output_shape=None, order=1,
|
||||
if output_shape is None:
|
||||
output_shape = ishape
|
||||
else:
|
||||
output_shape = np.array(output_shape, dtype=int)
|
||||
output_shape = safe_as_int(output_shape)
|
||||
|
||||
|
||||
out = None
|
||||
|
||||
@@ -250,7 +250,11 @@ def test_inverse():
|
||||
|
||||
def test_slow_warp_nonint_oshape():
|
||||
image = np.random.random((5, 5))
|
||||
warp(image, lambda xy: xy, output_shape=(13.1, 19.5))
|
||||
|
||||
assert_raises(ValueError, warp, image, lambda xy: xy,
|
||||
output_shape=(13.1, 19.5))
|
||||
|
||||
warp(image, lambda xy: xy, output_shape=(13.0001, 19.9999))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user