Skip to content
This repository

np.copy should have order='K' by default for backward compatibility #469

Closed
GaelVaroquaux opened this Issue September 30, 2012 · 5 comments

3 participants

Gael Varoquaux Ondřej Čertík Charles Harris
Gael Varoquaux

In current tree:

>>> a = np.ones((10, 10))
>>> np.copy(a.T).flags
  C_CONTIGUOUS : True
  F_CONTIGUOUS : False
  OWNDATA : True
  WRITEABLE : True
  ALIGNED : True
  UPDATEIFCOPY : False

In numpy 1.6

>>> a = np.ones((10, 10))
>>> np.copy(a.T).flags
  C_CONTIGUOUS : False
  F_CONTIGUOUS : True
  OWNDATA : True
  WRITEABLE : True
  ALIGNED : True
  UPDATEIFCOPY : False

I suggest to put "order='K'" by default in numpy 1.7 (maybe with a FutureWarning) to ensure backward compat.

Charles Harris
Owner

@njsmith I believe you fixed this.

Ondřej Čertík
Collaborator

The current master does:

>>> import numpy as np
>>> a = np.ones((10, 10))
>>> np.copy(a.T).flags
  C_CONTIGUOUS : False
  F_CONTIGUOUS : True
  OWNDATA : True
  WRITEABLE : True
  ALIGNED : True
  UPDATEIFCOPY : False

So I think it's fixed.

Ondřej Čertík
Collaborator

The 1.7.x branch still says however:

>>> import numpy as np
>>> a = np.ones((10, 10))
>>> np.copy(a.T).flags
  C_CONTIGUOUS : True
  F_CONTIGUOUS : False
  OWNDATA : True
  WRITEABLE : True
  ALIGNED : True
  UPDATEIFCOPY : False

So I need to find the commit which fixed it and backport it.

Ondřej Čertík
Collaborator

So I ran:

git bisect start
git bisect bad c5ccca92c5f136833ad85614feb2aa4f5bd8b7c3
git bisect good eb730a50467b9708260f6e2602bf8a8b4a2b1b67
git bisect run ./run.sh

with run.sh:

#! /bin/sh
set -e
python setup.py install
cd /tmp/a
python a.py

and /tmp/a/a.py:

import sys
import numpy as np
a = np.ones((10, 10))
print np.copy(a.T).flags
if np.copy(a.T).flags["F_CONTIGUOUS"] == True:
    print "bisect bad"
    sys.exit(1)
else:
    print "bisect good"
    sys.exit(0)

and it gave 1a71edc as the first "bad" commit (introduced in #476). Pretty cool! I am going to backport it now.

Ondřej Čertík certik closed this December 16, 2012
Ondřej Čertík
Collaborator

Backported in #2839.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.