-
-
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
Promote_shape dimension mismatch print. #40118
Comments
I don't see that, can you please demonstrate? If your issue is with the error message, that does not necessarily require a specialized method for |
I feel like I am here to point a mistake but I also added a solution, that I measured. I text the method here. My solution does both. Better compilation speed + better printing. The code to check:
The solution mentioned above, but the code that was used to test speed:
0.118728 seconds (354.34 k allocations: 19.999 MiB, 99.88% compilation time) While the original method gives:
0.135897 seconds (382.31 k allocations: 21.848 MiB, 99.86% compilation time) And we could get worse results if there is some method invalidation... but still better. So I hope this is enough. |
Why would we see ranges when we talk about "dims". Even in the error message we talk about "dims" and the programmer expect dim also. I don't see the point why do we want to see a range in case of an Array at all, can you explain? |
What I meant is that an axis Note that your benchmarks are timing |
No, 99.88% compilation time. If you run the aritmetic second time you get fractional time, the + isn't significant. Please, check it if you don't believe me. I noted the problem. Sorry for not having more time to discuss this in more detail. I don't mind if it doesn't get into the repo, I can't spend more time with this. I will have my own overloading on this funciton till it doesn't get into the master or solved in an other way from now. |
Again, you are timing a lot of unrelated things to the claim in this issue (eg compile time for |
Sorry to say but you are not right. 99.88% compilation time. Even if we time some runtime it is under 0.2%. If we believe to the @time command. Also please check where are the @time , we don't measure any randn. But of course we are definitely measure some allocation and an operation due to the + operation. But as I said, compilation time is +99.8%. |
@Cvikli: I regret to say that I don't understand what you are talking about here. Julia has AOT compilation, so for trivial operations you see almost purely compilation time the first time you run it. This is normal. In any case, I am preparing a PR to fix the printing issue. (Incindentally, please quote macros with backticks, as in |
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]>
@tpapp we should wait someone who check this thread, so he could understand the problem and solve the confusion here, I guess. Also I realised the "Normalize indices in promote_shape error messages" doesn't solve the issue mentioned here. |
@Cvikli: please clarify what the issue is then from your perspective. Eg
|
I will push a PR later I think. The problem is this: In case of this code:
Error as mentioned earlier, (@tpapp improved on this already a little bit):
Like in the case: So I will just add a PR by time to the code:
Thank you for all the discussion. |
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]>
I just created the above mentioned solution. See details in the pull request #41303 One line solution to resolve a very important error message for every data scientist using this julia. |
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]>
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]>
Seeing implementation details like `Base.OneTo` in error messages may be confusing to some users (cf discussion in #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 size (2, 3), b has size (3, 2), mismatch at 1") ``` Fixes #40118. (This is basically #40124, but redone because I made a mess rebasing). --------- Co-authored-by: Jameson Nash <[email protected]>
Hey Julianners,
I faced with dimension errors a lot of time during my workflow.
ERROR: LoadError: DimensionMismatch("dimensions must match: a has dims (Base.OneTo(3), Base.OneTo(2)), b has dims (Base.OneTo(3), Base.OneTo(4)), mismatch at 2")
I checked the source code why is this happening and I see this is a little bit too general solution to catch the error in case of Array:
We have the function that could handle the "Array{T}" specific case:
promote_shape(size(a), size(b))
We had a open discussion about this here: julia discourse on promote_shape
I would ask if it is possible to change the code to this which is cleaner and has better prompt, also it is considered a little bit faster at compilation even if it is minor:
the error from this:
ERROR: LoadError: DimensionMismatch("dimensions must match: a has dims (Base.OneTo(3), Base.OneTo(2)), b has dims (Base.OneTo(3), Base.OneTo(4)), mismatch at 2")
to this:
ERROR: LoadError: DimensionMismatch("dimensions must match: a has dims (3, 2), b has dims (3, 4)")
I think it is cleaner and help each new developer to handle dimension problems more easily.
To reproduce the issue:
The text was updated successfully, but these errors were encountered: