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

Changed meaning of .+= in Julia 0.5 #1

Closed
stevengj opened this issue Jul 21, 2016 · 4 comments
Closed

Changed meaning of .+= in Julia 0.5 #1

stevengj opened this issue Jul 21, 2016 · 4 comments

Comments

@stevengj
Copy link

Your code uses x .+= y, so you should know that in Julia 0.5 this has changed meaning to be equivalent to broadcast!(identity, x, x .+ y), so that it mutates the x array (see JuliaLang/julia#17510 … in Julia 0.6 the whole operation will occur in-place without temporaries). So .+ should only be used if the left-hand side is a mutable array, and you don't mind mutating it.

At first glance, this looks like it is okay for you, because you use it in pl.profit .+= plbu.profit and similar cases where it looks like you want to work in-place anyway? But if it were a problem you could always change it to +=.

@mkriele
Copy link
Owner

mkriele commented Jul 21, 2016

Many thanks for the heads up! I also don't think it is an issue for me but I will look out for it once I switch to 0.5

@tkelman
Copy link
Contributor

tkelman commented Jul 22, 2016

Looks like you do have an ambiguity failure in your tests now http://pkg.julialang.org/logs/ValueOrientedRiskManagementInsurance_0.5.log

@stevengj
Copy link
Author

Similarly for .*=. In particular, looking at code like β[:prem] .*= product.prem_norm, I'm wondering if you mean *=, depending on what β[:prem] is?

After JuliaLang/julia#17546 is merged, this will turn into broadcast!(identity, view(β, :prem), β[:prem] .* product.prem_norm), and probably view(β, :prem) will throw a MethodError. So, probably you will need to change this to *= anyway.

@mkriele
Copy link
Owner

mkriele commented Sep 27, 2016

Any such errors have been corrected in the current code

@mkriele mkriele closed this as completed Sep 27, 2016
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

3 participants