You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
BUG: flatten method does not validate its argument. #6598
According to the docstring of the flatten method, the argument should be one of 'C', 'F' or 'A'. I would expect a ValueError to be raised if the argument is not one of those values. However, it appears to ignore invalid arguments.
For example,
In [1]: import numpy as np
In [2]: np.__version__
Out[2]: '1.11.0.dev0+78d9628'
In [3]: x = np.zeros((3, 5))
In [4]: x.flatten(np.pi) # Give flatten() a nonsense argument, and it doesn't complain.
Out[4]:
array([ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0.])
I noticed this while editing the "NumPy for Matlab Users" guide, where y = x.flatten(1) was suggested as the NumPy version of the Matlab code y = x(:). (The guide has been fixed.)
@WarrenWeckesser : Sure thing! Your issue actually had ramifications for several other functions whose underlying functionality was tied to that order parameter. So it was good that you caught this.
Activity
gfyoung commentedon Dec 11, 2015
From what I can tell, I believe the bug traces to code in the
PyArray_OrderConvertermethod in this file here. I'll have a PR up for that soon!WarrenWeckesser commentedon Dec 18, 2015
@gfyoung Thanks for fixing this.
gfyoung commentedon Dec 18, 2015
@WarrenWeckesser : Sure thing! Your issue actually had ramifications for several other functions whose underlying functionality was tied to that
orderparameter. So it was good that you caught this.DEP: Stricter arg checking for array ordering