-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
improve deprecation warning for non-integer indexing #14049
Conversation
This strikes me as though it would be actively confusing any time you get this warning from something unrelated to division. |
@tkelman, it does say "if you are doing division" ... is there a way to make that more obvious? Maybe "It may be that your non-integer index came from ...."? The thing is, in discussions of this topic there have been literally zero real-world examples of non-integer |
c9e0704
to
9004756
Compare
@tkelman, I've attempted to clarify the warning. |
9004756
to
8a94e6a
Compare
It's just a really long warning to always give for this - you could have almost anything in an indexing expression. Without actually looking at the expression at the parser level this seems inaccurate at best. |
@tkelman, I'm not sure why the length is a concern? You could have almost anything in theory, but in practice you don't. Do you have any counter-examples from real applications? In contrast, integer division is extremely common in indexing calculations (for strided data, divide-and-conquer algorithms, etc.). |
If length were never a concern, we could print the entire contents of the manual on every warning or error message... Though I believe most packages have moved away from this due to the deprecation, ApproxFun and a few other places had been overloading getfield with floating-point inputs for function approximation or interpolation. |
@tkelman, we are talking about two sentences here. Hyperbole about printing the whole manual is not helpful. The question is, why is the length of two sentences a concern? The ApproxFun case and similar interpolation software that overloads |
If it's needing to take 3 lines at default terminal widths, it's probably too long for a warning? Especially since this warning can come from trying to do something as simple as |
We have other warnings and messages that are a couple lines long, e.g the exception message for And the point is that people are very unlikely to type The question is not whether something is too long or too short, but rather whether shorter or longer would be more helpful. Spitting out pages-long warnings are not helpful because they are too long to quickly digest, especially if you have a lot of them. But just saying |
I also like this new message. I've personally used |
I'm not objecting all that strongly, just doesn't seem like this is the most effective or accurate place to convey the information that |
I think you are generally right that this is only a very specific use case of This is also not matlab user specific, I tried The edit: For the python3 case, it doesn't inform the user about the right way to do integer truncated division in the indexing error message (not a warning) but it is less of an issue for them since the breakage from python2 to python3 is the division and not indexing so the users usually already know what they are looking for (2to3 might handle this too?). |
(It's also useful for people coming from C, where It's not like we are limited to only talking about |
…ng i/j with i÷j (see JuliaLang#10458)
8a94e6a
to
d2ad66c
Compare
Got rid of the "equivalent to |
improve deprecation warning for non-integer indexing
It seems that 99% of the real-world usages of floating-point indexes (deprecated in #10458) arise because people are using
/
for integer division when they really want÷
, but the latter is not very intuitive or discoverable.See also the julia-users discussion.
This simply includes a suggestion to replace
i/j
withi÷j
in the deprecation warning. Probably should be backported to 0.4.