OffsetArrays.jl icon indicating copy to clipboard operation
OffsetArrays.jl copied to clipboard

OffsetArray of size 1 from elementwise multiplication

Open liamh opened this issue 1 year ago • 1 comments

See forum discussion with examples.

When I elementwise multiply an offset array by a regular array, I get the result I expect - the resulting array is offset properly - except when the size is 1. When the input array dimension is 6:10, for example, the multiplication result is 6:10 in the first dimension. This is as I expect, and all dimensions of size greater than 1 result in the same first dimension as the input. However, when the input array is 10:10, the multiplication result is 1:1 in the first dimension. I expect 10:10 as the first dimension, consistent with the size > 1 case.

liamh avatar Sep 09 '24 14:09 liamh

MWE:

julia> a = [1];

julia> b = OffsetArray([1], 2);

julia> Broadcast.combine_axes(axes(a,1), axes(b,1))
(3:3,)

julia> Broadcast.combine_axes(axes(b,1), axes(a,1))
(1:1,)

jishnub avatar Dec 23 '24 12:12 jishnub