Thanks to visit codestin.com
Credit goes to github.com

Skip to content

numpy.clip does not respect out array order #7633

Closed
@llchan

Description

@llchan

It appears that numpy.clip does not respect the out array order:

>>> import numpy as np
>>> np.__version__
'1.11.0'
>>> A = np.arange(15).reshape(5, 3)
>>> A
array([[ 0,  1,  2],
       [ 3,  4,  5],
       [ 6,  7,  8],
       [ 9, 10, 11],
       [12, 13, 14]])
>>> Af = np.zeros_like(A, order='F')
>>> Af
array([[0, 0, 0],
       [0, 0, 0],
       [0, 0, 0],
       [0, 0, 0],
       [0, 0, 0]])
>>> np.clip(A, 0, 7, out=Af)  # wrong
array([[0, 5, 7],
       [1, 6, 7],
       [2, 7, 7],
       [3, 7, 7],
       [4, 7, 7]])
>>> np.clip(A, 0, 7)  # expected
array([[0, 1, 2],
       [3, 4, 5],
       [6, 7, 7],
       [7, 7, 7],
       [7, 7, 7]])

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions