Error message: AttributeError: module 'numpy' has no attribute 'flip'
I can't understand why it's giving me this error, I've googled and made sure I'm up to the latest version of numpy. I definitely don't have another file called numpy in my working directory. Any help would be greatly appreciated!
np.flip
has been introduced for versions v.1.12.0 and beyond. For older versions, you can consider usingnp.fliplr
andnp.flipud
.Alternatively, upgrade your numpy version using
pip install --user --upgrade numpy
.Yes,
flip
is new, but there isn't anything magical about it. Here's the code:The essence of the action is that it indexes your array with one or more instances of
::-1
(theslice(None,None,-1)
).flipud/lr
do the same thing.With this
x
,flip
does:One can reshape 1-D array apply
fliplr
and then get 1-D array back. That is possible to go from 1-Dx
to 2-D by using, e.g.x.reshape(1,x.size)
or[x]
.