Skip to content
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

Broadcasting with IdOffsetRange seems wrong #104

Closed
yha opened this issue Mar 23, 2020 · 3 comments
Closed

Broadcasting with IdOffsetRange seems wrong #104

yha opened this issue Mar 23, 2020 · 3 comments

Comments

@yha
Copy link
Contributor

yha commented Mar 23, 2020

This seems fine, although the error message is a bit odd:

oa = OffsetArray(1:4,1)
axes(oa .+ 1)  # (2:5)
oa .+ (1:4)   # 
DimensionMismatch("arrays could not be broadcast to a common size; got a dimension with lengths 4 and 4")

But:

oa_axes = axes(oa)[1]  # 2:5
axes(oa_axes)  # (2:5)
axes(oa_axes .+ 1)  # (Base.OneTo(4))
oa_axes .+ (1:4)  #  3:2:9

I would expect oa_axes to behaves like oa in broadcasting.

@johnnychen94
Copy link
Member

+-*/ of two IdentityUnitRange isn't an IdentityUnitRange anymore, and that's the same fact for IdOffsetRange.

julia> Base.IdentityUnitRange(2:5) .+ (1:4)
3:2:9

But oa_axes .+ 1 should preserve the offset. #105 fixes this.

@timholy
Copy link
Member

timholy commented Mar 23, 2020

See JuliaLang/julia#30950. That was starting to go a in a scary breaking direction, that effort needs to be restarted with a more careful design.

@yha
Copy link
Contributor Author

yha commented Sep 29, 2020

Closing since this is fixed by #114.

@yha yha closed this as completed Sep 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants