I tested it in my local environment. I am on 1.6.0.rc1.
using Base: promote_shape
function Base.promote_shape(a::Array{A}, b::Array{B}) where {A,B}
promote_shape(size(a), size(b))
end
q=randn(3,4)
p=randn(3,2)
p+q
For me it is really clean.
The stacktrace changed from:
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 checked some @btime and @time which shows a very slight improvment on the compilation part (10%) and runtime (0-4%) as we could expect it.
Compilation @time info:
from: (8.3% gc time can be substracted)
# 0.118740 seconds (382.40 k allocations: 21.776 MiB, 8.31% gc time, 99.89% compilation time)
to:
# 0.093647 seconds (354.44 k allocations: 19.927 MiB, 99.89% compilation time)
@btime info:
from: # 7.093 μs (2 allocations: 93.83 KiB)
to: # 6.975 μs (2 allocations: 93.83 KiB)
Do you think I should open a pull request to or an issue to ellaborate on it?