8000 DEP: Deprecated using a float index in linspace by emilienkofman · Pull Request #7328 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

DEP: Deprecated using a float index in linspace #7328

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
Mar 13, 2016

Conversation

emilienkofman
Copy link
Contributor

According to what was discussed in Issue #7289.

except TypeError:
i = int(i)
msg = "Indexing with a float is deprecated "\
"and will be removed in the future."
Copy link
Contributor

Choose a reason for hiding this comment

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

Line this up with the opening quote on the previous line.

Copy link
Member

Choose a reason for hiding this comment

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

Also, use parentheses for line continuation instead of backslashes

@njsmith
Copy link
Member
njsmith commented Feb 25, 2016

This is looking pretty good to me -- the one other thing is that we have some conventions for keeping track of deprecations so that we remember to follow up on them, and I'm not totally sure what we've been doing recently :-). You should at least add a comment like # 2016-02-25, 1.12 before the call to _index_deprecate to remind us when the deprecation happened, and I guess you should also file a followup bug targeting some milestone-or-another...

@charris @seberg -- what's the current best practice?

@madphysicist
Copy link
Contributor

Should there also probably be something in the release notes?

@seberg
Copy link
Member
seberg commented Feb 26, 2016

Frankly, not sure, Chuck probably has something he likes, I used to have follow up issues. But either Chuck did not like them, or they all outlived their deprecations, I am not sure :).

I think I would prefer to remove the word "indexing", the python error says "cannot be interpreted as an index". While "index" is more correct in the sense it includes that it is limited by ssize_t, I think "safely interpreted as an integer" or something saying integer is even clearer. "indexing" sounds too much like the square bracket notation this has nothing to do with.

@charris
Copy link
Member
charris commented Mar 2, 2016

Updated. We usually put deprecation tests in numpy/core/tests/test_deprecations.py just to have a convenient place to look. Date and numpy version, maybe the PR # for documentation.

try:
i = operator.index(i)
except TypeError:
msg = "%f cannot be safely interpreted as an integer." % i
Copy link
Member

Choose a reason for hiding this comment

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

Thanks, maybe rather "object of type {} ...".format(type(i)) or just not %f but %s/{}. The object might also be a string in principle, and things would crash rather cryptically then. I admit it is very very unlikely, but since we may want to use this function elsewhere.

Copy link
Member

Choose a reason for hiding this comment

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

Agreed with @seberg -- we still have a responsibility to provide sensible error messages for basic mistakes like np.linspace(0, 1, np.float32) (oops, user forgot to write dtype=).

@charris
Copy link
Member
charris commented Mar 7, 2016

@emilienkofman Be good to get this finished up.

@emilienkofman
Copy link
Contributor Author

Sorry for the conflicts. I don't know exactly what happened. I tried to fit the test in numpy/core/tests/test_deprecations.py instead. I was a bit discouraged but I'll try to be more reactive!

@charris
Copy link
Member
charris commented Mar 8, 2016

Conflicts happen when other PRs are merged, nothing that is your fault. You can start by squashing your commits, git rebase -i HEAD~6 and follow instructions. Then rebase on master git rebase master and fix the conflicts. You might need to read the docs or google for fixing conflicts. This also needs a note in doc/release/1.12.0-notes.rst.

@charris charris added the 56 - Needs Release Note. Needs an entry in doc/release/upcoming_changes label Mar 8, 2016
@emilienkofman
Copy link
Contributor Author

Ok, the git rebase tells me that it will rebase this:
Rebase 077b0eb..32ceaf0 onto 077b0eb
How can I rebase onto the most recent commit of the master branch instead?

@njsmith
Copy link
Member
njsmith commented Mar 8, 2016

Chuck's suggesting you do things in two stages: first "squash" your commits down into one commit, which will involve rebasing them onto the same revision they're already based on, like in the output you pasted. Then, once you've successfully done that, as a second step rebase that one commit onto the most recent commit on master branch.

The advantage of doing things this way is that if you try to rebase onto master immediately, then you have to be careful or you might find yourself resolving the same conflicts repeatedly for each of your commits, but if you have just one commit then the worst case is that you just have to resolve the conflicts once :-)

@emilienkofman
Copy link
Contributor Author

Ok I will eventually get it right at some point, I did the first rebase by squashing all my commits into one which I think worked (I can see it into gitk for instance). Then git rebase master just tells me that the current master branch is up to date. I guess it's because this master is the master of my branch (?)

Edit: I did:
git remote add upstream https://github.com/numpy/numpy.git
and then
git pull --rebase upstream master
and I think it got updated, but there is one conflict which I'm trying to fix now.

Edit: Finally got it I think. Sorry that's a bit laborious.

DEP: Deprecated using a float index in linspace

DEP: Deprecated using a float index in linspace

DEP: Deprecated using a float index in linspace

DEP: Deprecated using a float index in linspace

DEP: Deprecated using a float index in linspace

DEP: Release notes for PR#7328
@njsmith
Copy link
Member
njsmith commented Mar 8, 2016

Looks good to me. Congratulations on winning against git :-).

Tests haven't finished + I'm on mobile + @charris was looking at this most recently (for 1.11 I think) and I don't want to step on him accidentally, so will leave the merge to him (or whoever).

@@ -148,5 +148,8 @@ Deprecations

Assignment of ndarray object's ``data`` attribute
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Assigning the 'data' attribute is an inherently unsafe operation as pointed out
in gh-7083. Such a capability will be removed in the future.
Assigning the 'data' attribute is an inherently unsafe operation as pointed out in gh-7083. Such a capability will be removed in the future.
Copy link
Member

Choose a reason for hiding this comment

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

Keep lines < 80 characters long, this one is 142 ;) I'll fix it up later, but keep that in mind.

Copy link
Member

Choose a reason for hiding this comment

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

Might as well do it, as other fixes need to be made.

@emilienkofman
Copy link
Contributor Author

Do you think this could be merged or do you suggest that we investigate more on the __index__ issue? I may try to fix the related issue #7395 (since I know now the process of adding depreciated stuff).

@seberg
Copy link
Member
seberg commented Mar 12, 2016

Should be good, unless Chuck still has doubts. Will merge in a bit unless anyone has complains or beats me to it.
We are always happy about anyone looking into issues. Not to discourage you, but that one will be buried in the C api. It should not be difficult to do, but may need some tracking down the right spot, etc.

@charris
Copy link
Member
charris commented Mar 13, 2016

I don't have any substantive objections.

charris added a commit that referenced this pull request Mar 13, 2016
DEP: Deprecated using a float index in linspace
@charris charris merged commit 3eff0ae into numpy:master Mar 13, 2016
@charris
Copy link
Member
charris commented Mar 13, 2016

Thanks @emilienkofman .

@charris charris removed the 56 - Needs Release Note. Needs an entry in doc/release/upcoming_changes label Mar 13, 2016
@seberg
Copy link
Member
seberg commented Mar 14, 2016

Thanks Chuck and everyone.

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.

5 participants
0