-
-
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
Normalize indices in promote_shape error messages (take 2) #41311
Normalize indices in promote_shape error messages (take 2) #41311
Conversation
Might be cleaner just to say "a has size (2, 3)" when axes are Also, if changing things, could we kill the repetition in "DimensionMismatch("dimensions must match" ? It looks like a mistake although, when compared to |
That is indeed shorter, but at the same time I think the language should encourage people to think in terms of generalized indexing all the time since it is part of the
done, thanks. |
My concern isn't brevity, it's more that |
I think the error message is pretty clear about these axes; I am not quite sure how Also, what should happen for two arrays with axes eg |
My point is that, for axes, What should be printed in cases where some but not all of the axes in play are Base.OneTo, that's less obvious. If you're complaining that mixing size & axes in one message would be odd, then I agree, we shouldn't do that. This is certainly quite a mouthful at present:
Maybe printing something like |
Sorry, I don't understand how values that are I think that |
I thought I gave lots of examples. One more, on a fresh session:
|
Ping, this is still grating and would be great to fix. Reading up the discussion, it seems that @mcabbott 's objection is that we need to carefully distinguish different types of axes, but it seems to me that it would be OK to have a simpler (possibly different) error message in the common cases of "standard" axes. @mcabbott do you think that's acceptable? If yes, any thoughts as to how to proceed? |
@antoine-levitt: if triage gives a clear direction, I would be happy to update this PR. FWIW, I would leave it as is: the only documented methods of |
Seeing implementation like `Base.OneTo` in error messages may be confusing to some users (cf discussion in JuliaLang#39242, [discourse](https://discourse.julialang.org/t/promote-shape-dimension-mismatch/57529/)). This PR turns ```julia julia> ones(2, 3) + ones(3, 2) ERROR: DimensionMismatch("dimensions must match: a has dims (Base.OneTo(2), Base.OneTo(3)), b has dims (Base.OneTo(3), Base.OneTo(2)), mismatch at 1") ``` into ```julia julia> ones(2, 3) + ones(3, 2) ERROR: DimensionMismatch("dimensions must match: a has axes (1:2, 1:3), b has axes (1:3, 1:2), mismatch at 1") ``` Fixes JuliaLang#40118. Acked-by: Tamas K. Papp <[email protected]>
- avoid assuming the tuples have the same eltype - coerce the inputs to simpler representations before printing, if unambiguous - update a couple more error messages with the same text - use string builder, instead of repeated concatenation
4f66ee5
to
ce7a16e
Compare
I have tried to take the feedback of the discussion into account, so now it reads, and I think should be ready to merge:
|
Seeing implementation like
Base.OneTo
in error messages may be confusing to some users (cf discussion in #39242,discourse).
This PR turns
into
Fixes #40118.
(This is basically #40124, but redone because I made a mess rebasing).