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

Fix depwarns on julia 0.6 & Optim 0.7.5 #38

Merged
merged 1 commit into from
Feb 13, 2017

Conversation

yuyichao
Copy link
Contributor

A Optim.jl PR is also ready and will be submitted after JuliaLang/Compat.jl#326 is tagged (Hopefully tomorrow).

@@ -1,6 +1,6 @@
let
# fitting noisy data to an exponential model
model(x, p) = p[1]*exp(-x.*p[2])
model(x, p) = @compat p[1] .* exp.((-).(x) .* p[2])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-x really doesn't work anymore??

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you've overdone it here... it should be sufficient to just vectorize the call to exp so it is:

p[1] * exp.(-x .* p[2])

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This just make the whole expression a single broadcast.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but it does it at the expense of readability. We've made various choices in LsqFit to sacrifice a small amount of performance in the name of readability. In this case, I find (-).(x) to be extraordinarily obtuse. So, please... let's use the easier to read version.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd always make the opposite sacrifice for a 2x reduction of allocation especially for non-public API but I guess this is only the test so I don't care. I changed it to the slower version and left TODO's for how to update it in the future.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

@tkelman
Copy link
Contributor

tkelman commented Feb 21, 2017

Weren't dot calls in Compat 0.7.15? JuliaLang/Compat.jl@03fd3eb

@yuyichao
Copy link
Contributor Author

I usually use JuliaLang/Compat.jl@fbf0173 in order to not having to check if the case was supported correctly by 0.4 broadcast.

@tkelman
Copy link
Contributor

tkelman commented Feb 21, 2017

do the tests fail with earlier versions?

@yuyichao
Copy link
Contributor Author

I don't have an old version so I don't know. It's a behavioral change though so I see 0.9.1 as the first version this is properly implemented.

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 this pull request may close these issues.

3 participants