8000 np.array does not always return the order asked for · Issue #465 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

np.array does not always return the order asked for #465

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
GaelVaroquaux opened this issue Sep 29, 2012 · 5 comments
Closed

np.array does not always return the order asked for #465

GaelVaroquaux opened this issue Sep 29, 2012 · 5 comments

Comments

@GaelVaroquaux
Copy link
Contributor

Is the behavior below expected? It looks like a bug to me:

>>> a = np.ones(10,)
>>> np.array(a, order='C', copy=False, ndmin=2).flags
  C_CONTIGUOUS : False
  F_CONTIGUOUS : True
  OWNDATA : False
  WRITEABLE : True
  ALIGNED : True
  UPDATEIFCOPY : False
>>> np.array(a, order='C', copy=True, ndmin=2).flags
  C_CONTIGUOUS : False
  F_CONTIGUOUS : True
  OWNDATA : False
  WRITEABLE : True
  ALIGNED : True
  UPDATEIFCOPY : False
@njsmith
Copy link
Member
njsmith commented Sep 29, 2012
  1. what version of numpy is this?

  2. Despite the claims of .flags, the returned array must in fact be C_CONTIGUOUS and F_CONTIGUOUS, since it's an Nx1 array. So this looks like a bug in the flag setting code. Probably related to Reset flags when Axes are removed. Array might now be 1D, or removed axe... #420 or something? @seberg, any ideas?

@GaelVaroquaux
Copy link
Contributor Author
  1. what version of numpy is this?

Git master.

  1. Despite the claims of .flags, the returned array must in fact be
    C_CONTIGUOUS and F_CONTIGUOUS, since it's an Nx1 array. So this looks like a
    bug in the flag setting code.

Probably. That said, it triggers the cython checks for ordering, so we
cannot bypass it, eventhough its harmless.

@seberg
Copy link
Member
seberg commented Sep 29, 2012

I don't think it is related to 420, but I will have a look, must have something to do directly with the ndmin mechanism is my guess, the second stride should be set according to the order but they seem to be always set to the element size.

@njsmith The returned array must not be C- and F-Contiguous though, its just not how numpy rolls at the moment (that is exactly the change I proposed in that cflags branch), and if it was, numpy would currently explode.

@GaelVaroquaux
Copy link
Contributor Author

Thanks to you guys for taking care of this!

seberg added a commit to seberg/numpy that referenced this issue Sep 29, 2012
Closes "Issue numpy#465", strides need to be set according
to the requested contiguous flags.
teoliphant pushed a commit to ContinuumIO/numpy that referenced this issue Nov 6, 2012
Closes "Issue numpy#465", strides need to be set according
to the requested contiguous flags.
@seberg
Copy link
Member
seberg commented Jan 18, 2013

This has been fixed in 1.7. with PR gh-466

@seberg seberg closed this as completed Jan 18, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
0