-
Notifications
You must be signed in to change notification settings - Fork 373
Fix BoundsError messages #2069
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
Fix BoundsError messages #2069
Conversation
Co-Authored-By: Milan Bouchet-Valat <nalimilan@club.fr>
|
Unfortunately |
|
I'd say it's OK. Though maybe call it |
|
Now we would have another problem 😢. Sometimes in very similar expressions we call different code paths that either would throw Do you have any other idea? |
|
Are there many examples like this? It doesn't sound very user-friendly to throw an error about an underlying vector rather than printing a more explicit error. EDIT: can you point to some examples? Anyway I'd rather throw different exception types than less explicit errors. |
|
I would have to review the whole code base. For sure it is the case with |
|
I have analyzed this and it would be a lot of work for little gain IMO. if this is acceptable I will finalize this PR in this way (we can do a major overhaul of thrown error types after 1.0 release if we want I think). |
|
Sounds OK, except for the one mentioning There's also this which isn't super nice: julia> df[1:10, :]
ERROR: BoundsError: attempt to access 2×3 DataFrame
at index [1:10, Colon()]Though it's even worse for julia> rand(2, 2)[1:10, :]
ERROR: BoundsError: attempt to access 2×2 Array{Float64,2} at index [1:10, Base.Slice(Base.OneTo(2))]I've filed JuliaLang/julia#34217 to improve this in Base. BTW, this looks like it could be improved at some point (though it's somewhat orthogonal to this PR): julia> df[:, 1:10]
ERROR: BoundsError: attempt to access 3-element Array{AbstractArray{T,1} where T,1} at index [1:10] |
|
This is doable. I have just two questions to you and one comment. Thank you.
Yes - we can make
I can fix it to print
Yes, agreed - but this is exactly this class of problems that require a significant redesign of indexing, which I think can be done later (it has to be benchmarked very carefully before making such changes). |
Clever. Yeah, why not, if catching the error before or after to throw a better error isn't possible.
We could use |
So this is what I will implement now. In order to improve things - as noted earlier - we would need to reimplement all
I have just checked the implementation in Julia you have proposed. Essentially the best thing would be to move it entirely. So maybe let us just leave things here as is and follow that Julia prints by default. |
|
OK, changed. The error messages now look like this: |
|
OK, sounds good! Can you add tests for |
|
OK - added. I have added tests with and without Also this means that I have added a test for Here is one small issue we could discuss. When displaying and we give both dimensions of the parent. However, in summary we give: indicating the length of the iterable. I thought it is OK to do this this way, but maybe you feel we should make it consistent (in which case I would change what we print in |
|
CI produces ❌ due to coveralls |
|
Thanks. Ideally I'd prefer showing both dimensions for consistency and because they are both relevant, but that would be misleading when printing |
This was exactly my thinking (i.e. it is an |
We were using wrong syntax for
BoundsErrorin the whole package (it does not allow a custom message). This PR fixes this.