Skip to content

Off by one error in ndimage.map_coordinate when mode='wrap' #2640

@rainwoodman

Description

@rainwoodman

The interpolation coordinate is off by one in 'wrap' mode.

Test case:
a = array([0, 1, 0, -1.])
x = linspace(0, 8, 8, endpoint=False)
y = map_coordinate(a, [x], mode='wrap')
ynp = numpy.take(a, int64(x), mode='wrap')

Because x is strictly on a grid, one would expect y and ynp to be rather close.

The result is not:
y , ynp
(9.8982237337064127e-15, 0.0),
(0.99999999999999256, 1.0),
(2.2376848637928326e-15, 0.0),
(-0.99999999999999967, -1.0),
(0.99999999999999256, 0.0),
(2.2376848637928326e-15, 1.0),
(9.8982237337064127e-15, 0.0),
(0.99999999999999256, -1.0)

From y[4] it appears to be off by one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    defectA clear bug or issue that prevents SciPy from being installed or used as expectedscipy.ndimage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions