8000 DEP: Add back `ndarray.__[sg]etslice__`, but deprecate it by eric-wieser · Pull Request #8953 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

DEP: Add back ndarray.__[sg]etslice__, but deprecate it #8953

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

Merged
merged 2 commits into from
Apr 19, 2017

Conversation

eric-wieser
Copy link
Member
@eric-wieser eric-wieser commented Apr 16, 2017

This is added in a way that means that CPython will not call these for
normal indexing.

This partially undoes #8592, and is a competing approach to #8943.

Other removals in #8592:

Based on #8887, it's possible this causes a problem on pypy (in that a[1:2] causes a deprecation warning) - can anyone test this?

@charris
Copy link
Member
charris commented Apr 17, 2017

Looks like indexing ends up calling {get,set}slice by default if they are there. I'd just remove the deprecation and wait until we drop 2.7. The main point here is to reuse the code for {get,set} item. After that, looks like one test failure will remain.

@eric-wieser
Copy link
Member Author

@charris: Am I right in thinking that it makes sense to put this in __dict__ but not tp_mapping? My thoughts are that this avoids an extra roundtrip from PyObject* to int and back,

@eric-wieser eric-wieser force-pushed the remove-setslice branch 2 times, most recently from 3d72098 to 90204cd Compare April 17, 2017 21:54
@charris charris added this to the 1.13.0 release milestone Apr 18, 2017
@charris
Copy link
Member
charris commented Apr 18, 2017

I think you want this in numpy/testing/nosetester.py ~line 423.

+                sup.filter(DeprecationWarning, message="in 3\.x, __setslice__")
+                sup.filter(DeprecationWarning, message="in 3\.x, __getslice__")

I suspect you removed that yourself ;)

@charris
Copy link
Member
charris commented Apr 18, 2017

Am I right in thinking that it makes sense to put this in dict but not tp_mapping?

I think that should work...

@charris
Copy link
Member
charris commented Apr 19, 2017

Just needs the nosetester fix and I think it is ready to go.

@charris charris self-assigned this Apr 19, 2017
@@ -2417,6 +2417,44 @@ array_complex(PyArrayObject *self, PyObject *NPY_UNUSED(args))
return c;
}

static PyObject *
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these need to be in an ifndef NPY_PY3K

These now delegate to __getitem__, so subclasses no longer need to define them
@eric-wieser
Copy link
Member Author
eric-wieser commented Apr 19, 2017 8000

@charris: Done, and with a more accurate commit message

@charris charris merged commit 187cea4 into numpy:master Apr 19, 2017
@charris
Copy link
Member
charris commented Apr 19, 2017

Merged. Thanks Eric.

@juliantaylor
Copy link
Contributor

please rebase instead of merging master back in for these small branches.

@eric-wieser
Copy link
Member Author
eric-wieser commented Apr 19, 2017

@juliantaylor: The merge here was deliberate - I wanted the parent of this commit to be the previous (merged) PR, so that it was easy to check what the sum total of changes was.

@charris
Copy link
Member
charris commented Apr 19, 2017

Wouldn't a rebase have done as well? What am I missing?

@eric-wieser
Copy link
Member Author

@charris: If I rebased, there would be no way to ask for a diff between this change and the one that it undoes, without getting everything in the middle (unless I rebased the already-merged PR, which would be weird, and create duplicate commits)

@charris
Copy link
Member
charris commented Apr 19, 2017

Are you sure? What you would see would be the difference from current master head, which would look, IIANM, exactly like this does except with a cleaner history.

B260
@eric-wieser
Copy link
Member Author
eric-wieser commented Apr 19, 2017

Nothing. The difference would be what you see as a diff between f031cdf (the last non-merge commit in this PR) and 98b3127 (the commit before __getslice__ was removed)

Github comparison link: 98b3127...f031cdf

Had I rebased, that diff would include every intermediate commit on master.

Of course, ideally I wouldn't have had to merge in the first place, and would have left it to github - but #8847 meant that a clean merge is not possible

@charris charris changed the title DEP: Add back ndarray.__[sg]etslice__, but deprecate it DEP: Add back ndarray.__[sg]etslice__, but deprecate it May 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0