8000 `np.array` behaviour different when `order=None` and `order='A'` · Issue #7374 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content
np.array behaviour different when order=None and order='A' #7374
Closed
@vighneshbirodkar

Description

@vighneshbirodkar

When you refer to the documentation of np.array here
http://docs.scipy.org/doc/numpy-1.10.0/reference/generated/numpy.array.html
The page says that order='A' is default, while the function prototype indicates order=None is default. Initially I assumed that both of them give the same results, but that is not the case. See the following snippet.

>>> import numpy as np
>>> from numpy.lib.stride_tricks import as_strided
>>> a = np.array((100000,),  dtype=np.float64)
>>> b = as_strided(a, strides=[8, 512], shape=[10, 64])
>>> b.flags
  C_CONTIGUOUS : False
  F_CONTIGUOUS : False
  OWNDATA : False
  WRITEABLE : True
  ALIGNED : True
  UPDATEIFCOPY : False
>>> c = np.array(b, order=None, copy=True)
>>> c.flags  # see that C_CONTIGUOUS is False
  C_CONTIGUOUS : False
  F_CONTIGUOUS : True
  OWNDATA : True
  WRITEABLE : True
  ALIGNED : True
  UPDATEIFCOPY : False
>>> d = np.array(b, order='A', copy=True)
>>> d.flags # see that C_CONTIGUOUS is True
  C_CONTIGUOUS : True
  F_CONTIGUOUS : False
  OWNDATA : True
  WRITEABLE : True
  ALIGNED : True
  UPDATEIFCOPY : False

I expected that when order=None and copy=True the output would be C-Contiguous, since order=None is the default in the function prototype. I believe that either None should behave exactly like 'A' or the documentation of the function prototype should be changed to mention that 'A' is the default order.

Numpy Version = '1.10.2'
Python 2.7.6

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

      0