-
Notifications
You must be signed in to change notification settings - Fork 28
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
Support julia 0.5 #135
Support julia 0.5 #135
Changes from 2 commits
2cf4a48
df09781
072a82c
1c04180
23f0068
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ os: | |
- linux | ||
julia: | ||
- 0.4 | ||
- nightly | ||
notifications: | ||
email: false | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
julia 0.4 | ||
Compat | ||
DataFrames | ||
Distributions | ||
DocOpt | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,9 +72,10 @@ function subtract_kl!{NumType <: Number}( | |
mp::ModelParams{NumType}, accum::SensitiveFloat{CanonicalParams, NumType}; | ||
calculate_derivs::Bool=true, calculate_hessian::Bool=true) | ||
|
||
|
||
# The KL divergence as a function of the active source variational parameters. | ||
function subtract_kl_value_wrapper{NumType <: Number}(vp_vec::Vector{NumType}) | ||
elbo_val = zero(NumType) | ||
function subtract_kl_value_wrapper{NumType2 <: Number}(vp_vec::Vector{NumType2}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was causing a seg fault in 0.5, rather than an error |
||
elbo_val = zero(NumType2) | ||
vp_active = reshape(vp_vec, length(CanonicalParams), length(mp.active_sources)) | ||
for sa in 1:length(mp.active_sources) | ||
vs = vp_active[:, sa] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
#!/usr/bin/env julia | ||
|
||
if VERSION > v"0.5.0-dev" | ||
Pkg.checkout("Optim") | ||
Pkg.checkout("DataFrames") | ||
Pkg.rm("GaussianMixtures") | ||
Pkg.clone("https://github.com/jeff-regier/GaussianMixtures.jl.git") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These run-time changes to which packages are installed seem like a bad idea. Better to document in the README the requirements for running on v0.5. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (and for travis, add these commands to |
||
end | ||
|
||
using Celeste: Types, SampleData, Transform | ||
import Celeste.Synthetic | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,9 @@ else | |
end | ||
end | ||
|
||
const datadir = joinpath(Pkg.dir("Celeste"), "test", "data") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I might be redefining a constant here, but it's nice to run just one file or tests without having to run all the tests. (Is there a better way?) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, just remove this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh I see, I can call runtests with ARGS now. |
||
|
||
|
||
println("Running hessian tests.") | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,12 +4,14 @@ using DataFrames | |
import SloanDigitalSkySurvey: SDSS, WCSUtils, PSF | ||
|
||
using Celeste: Types, SampleData | ||
import Celeste: ModelInit, SkyImages, ElboDeriv | ||
import Celeste: ModelInit, SkyImages, ElboDeriv, Synthetic | ||
|
||
|
||
println("Running SkyImages tests.") | ||
|
||
field_dir = joinpath(dat_dir, "sample_field") | ||
const datadir = joinpath(Pkg.dir("Celeste"), "test", "data") | ||
|
||
field_dir = joinpath(datadir, "sample_field") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's no There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's weird we have both There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I agree. Probably SampleData.jl should eventually be moved to tests, as its |
||
run_num = "003900" | ||
camcol_num = "6" | ||
field_num = "0269" | ||
|
@@ -191,7 +193,7 @@ function test_set_patch_size() | |
end | ||
|
||
srand(1) | ||
blob0 = SkyImages.load_stamp_blob(dat_dir, "164.4311-39.0359"); | ||
blob0 = SkyImages.load_stamp_blob(datadir, "164.4311-39.0359"); | ||
img_size = 150 | ||
for b in 1:5 | ||
blob0[b].H, blob0[b].W = img_size, img_size | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ using Base.Test | |
|
||
using Celeste: Types, SampleData, Transform, SensitiveFloats | ||
import Celeste: ModelInit, ElboDeriv | ||
|
||
using Compat | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry for removing all the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removing them before seemed like a good thing to do...I didn't realize how soon we'd need them again |
||
|
||
function test_transform_sensitive_float() | ||
blob, mp, body, tiled_blob = gen_two_body_dataset(); | ||
|
@@ -280,13 +280,13 @@ function test_transform_simplex_functions() | |
this_scale * Transform.unsimplexify_parameter(param, unscaled_simplex_box)) | ||
|
||
# Test the bound checking | ||
@test_throws(Exception, | ||
@test_throws(AssertionError, | ||
Transform.unsimplexify_parameter([ lb - 1e-6, 1 - lb + 1e-6 ], simplex_box)) | ||
@test_throws(Exception, | ||
@test_throws(AssertionError, | ||
Transform.unsimplexify_parameter([ 0.3, 0.8 ], simplex_box)) | ||
@test_throws(Exception, | ||
@test_throws(AssertionError, | ||
Transform.unsimplexify_parameter([ 0.2, 0.3, 0.5 ], simplex_box)) | ||
@test_throws(Exception, Transform.simplexify_parameter([ 1., 2. ], simplex_box)) | ||
@test_throws(AssertionError, Transform.simplexify_parameter([ 1., 2. ], simplex_box)) | ||
end | ||
end | ||
|
||
|
@@ -315,9 +315,9 @@ function test_transform_box_functions() | |
this_scale * Transform.unbox_parameter(param, unscaled_param_box)) | ||
|
||
# Test the bound checking | ||
@test_throws Exception Transform.unbox_parameter(lb - 1.0, param_box) | ||
@test_throws AssertionError Transform.unbox_parameter(lb - 1.0, param_box) | ||
ub < Inf && | ||
@test_throws Exception Transform.unbox_parameter(ub + 1.0, param_box) | ||
@test_throws AssertionError Transform.unbox_parameter(ub + 1.0, param_box) | ||
end | ||
end | ||
|
||
|
@@ -361,7 +361,7 @@ function test_enforce_bounds() | |
mp.vp[2][ids.r1[2]] = transform.bounds[2][:r1][1].upper_bound + 1.0 | ||
mp.vp[3][ids.k[1, 1]] = transform.bounds[3][:k][1, 1].lower_bound - 0.00001 | ||
|
||
@test_throws Exception transform.from_vp(mp.vp) | ||
@test_throws AssertionError transform.from_vp(mp.vp) | ||
Transform.enforce_bounds!(mp, transform) | ||
transform.from_vp(mp.vp) # Check that it now works | ||
|
||
|
@@ -375,15 +375,15 @@ function test_enforce_bounds() | |
mp.vp[sa][ids.r1[2]] = transform.bounds[1][:r1][1].upper_bound + 1.0 | ||
mp.vp[sa][ids.k[1, 1]] = transform.bounds[1][:k][1, 1].lower_bound - 0.00001 | ||
|
||
@test_throws Exception transform.from_vp(mp.vp) | ||
@test_throws AssertionError transform.from_vp(mp.vp) | ||
Transform.enforce_bounds!(mp, transform) | ||
transform.from_vp(mp.vp) # Check that it now works | ||
|
||
end | ||
|
||
|
||
test_transform_sensitive_float() | ||
test_transform_box_functions() | ||
test_transform_sensitive_float() | ||
test_box_derivatives() | ||
test_box_simplex_derivatives() | ||
test_simplex_derivatives() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably didn't mean to compare a boolean to an int before, but for whatever reason 0.4 doesn't complain, while 0.5 stops.