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

Documentation for broadcasted addition assignment not matching implementation #38897

Closed
albheim opened this issue Dec 15, 2020 · 1 comment
Closed

Comments

@albheim
Copy link
Contributor

albheim commented Dec 15, 2020

The docstring for .+= says that it is a synonym for x = x .+ y but seems to rather be a synonym for x .= x .+ y. I'm not sure what I think the correct way should be (leaning towards the implementation being correct), but either implementation or documentation should be updated to match behavior and description.

Ran this on Julia 1.5.3

Example with array:

a = b = [1, 2]
c = [3, 4]
a .+= c # a and b both change
a .= a .+ c # a and b both change
a = a .+ c # only a change

Example with tuple:

(a, b) = (2, 3)
(a, b) = (a, b) .+ (1, 2) # Works as expected
(a, b) .+= (1, 2) # Error copyto!(::Tuple...)
(a, b) .= (a, b) .+ (1, 2) # Error copyto!(::Tuple...)
@albheim albheim changed the title Documentation for broadcasted addition assignment not true to how it works Documentation for broadcasted addition assignment not matching implementation Dec 15, 2020
mbauman added a commit that referenced this issue Dec 15, 2020
Also change "equivalent to" to a more rough "akin to" since `x .op y` isn't always identical to `broadcast(op, x, y)`.
@mbauman
Copy link
Member

mbauman commented Dec 15, 2020

Thanks; you're right the implementation is what we want. Doc fix in #38898.

@Keno Keno closed this as completed in 74a08fe Dec 15, 2020
KristofferC pushed a commit that referenced this issue Dec 17, 2020
Also change "equivalent to" to a more rough "akin to" since `x .op y` isn't always identical to `broadcast(op, x, y)`.

(cherry picked from commit 74a08fe)
staticfloat pushed a commit that referenced this issue Jan 15, 2021
Also change "equivalent to" to a more rough "akin to" since `x .op y` isn't always identical to `broadcast(op, x, y)`.

(cherry picked from commit 74a08fe)
ElOceanografo pushed a commit to ElOceanografo/julia that referenced this issue May 4, 2021
Also change "equivalent to" to a more rough "akin to" since `x .op y` isn't always identical to `broadcast(op, x, y)`.
staticfloat pushed a commit that referenced this issue Dec 23, 2022
Also change "equivalent to" to a more rough "akin to" since `x .op y` isn't always identical to `broadcast(op, x, y)`.

(cherry picked from commit 74a08fe)
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

No branches or pull requests

2 participants