Closed lmiq closed 5 months ago
Re. the error message, this needs to be fixed in Base
(something similar to https://github.com/JuliaLang/julia/pull/41311). There is certainly scope for a much better error message here, and it's just that someone needs to do the work and submit a PR.
it would be nice if broadcasting worked in such a case
This is also prohibited by Base
at present. I doubt that there's anything inherent in OffsetArrays
that prevents this.
I guess there is the question on the nature of the indices of the returned array.
Exactly, what would be the axes of the result? In particular, if we have two offset arrays (instead of only one), what axes does the result have? I think this is the main unresolved point.
The error message seems to have improved on Julia v1.11.0-alpha1:
julia> x .+ [1,2,3]
ERROR: DimensionMismatch: arrays could not be broadcast to a common size: a has axes OffsetArrays.IdOffsetRange(values=0:2, indices=0:2) and b has axes Base.OneTo(3)
[...]
This is both a feature request and the report that the error message is not good:
First, it would be nice if broadcasting worked in such a case. Second, in any case, the error message is not good and does not point to any possible solution, if supporting broadcasting in these cases is not possible for more fundamental reasons.
I guess there is the question on the nature of the indices of the returned array.