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

Support julia 0.5 #135

Merged
merged 5 commits into from
Mar 6, 2016
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ os:
- linux
julia:
- 0.4
- nightly
notifications:
email: false

Expand Down
1 change: 1 addition & 0 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
julia 0.4
Compat
DataFrames
Distributions
DocOpt
Expand Down
2 changes: 1 addition & 1 deletion src/ModelInit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ function limit_to_object_data(
# Get the sources that overlap with this object.
relevant_sources = Int[]
for b = 1:length(blob), tile_sources in mp.tile_sources[b]
if s_original in tile_sources > 0
if s_original in tile_sources
Copy link
Owner Author

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.

relevant_sources = union(relevant_sources, tile_sources);
end
end
Expand Down
1 change: 1 addition & 0 deletions src/Transform.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export DataTransform, ParamBounds, ParamBox, SimplexBox,
get_mp_transform, generate_valid_parameters, enforce_bounds!



################################
# Elementary functions.

Expand Down
5 changes: 3 additions & 2 deletions src/elbo_kl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Copy link
Owner Author

Choose a reason for hiding this comment

The 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]
Expand Down
7 changes: 7 additions & 0 deletions test/runtests.jl
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")
Copy link
Collaborator

Choose a reason for hiding this comment

The 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.

Copy link
Collaborator

Choose a reason for hiding this comment

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

(and for travis, add these commands to .travis.yml)

end

using Celeste: Types, SampleData, Transform
import Celeste.Synthetic

Expand Down
3 changes: 3 additions & 0 deletions test/test_derivatives.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ else
end
end

const datadir = joinpath(Pkg.dir("Celeste"), "test", "data")
Copy link
Owner Author

Choose a reason for hiding this comment

The 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?)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, just remove this. datadir is already defined in runtests.jl. All the test_*.jl files are included into that file, so they'll be in the same namespace/scope as datadir already: including just a subset of the test_*.jl files doesn't affect this.

Copy link
Owner Author

Choose a reason for hiding this comment

The 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.")


Expand Down
8 changes: 5 additions & 3 deletions test/test_images.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Copy link
Collaborator

Choose a reason for hiding this comment

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

There's no sample_field subdirectory in test/data anymore; the files are all in test/data.

Copy link
Owner Author

Choose a reason for hiding this comment

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

It's weird we have both dat_dir defined in SampleData.jl and datadir defined runtests.jl. SampleData.jl probably shouldn't know about the test data's location.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's weird we have both dat_dir defined in SampleData.jl and datadir
defined runtests.jl. SampleData.jl probably shouldn't know about the test
data's location.

I agree. Probably SampleData.jl should eventually be moved to tests, as its
not necessary for the core functionality in the app. This is something to
think about after SC though!

run_num = "003900"
camcol_num = "6"
field_num = "0269"
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/test_misc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ using Base.Test
import SloanDigitalSkySurvey: SDSS, WCSUtils

using Celeste: Types, SampleData
import Celeste: SkyImages, Util, ModelInit
import Celeste: SkyImages, Util, ModelInit, Synthetic


println("Running misc tests.")
Expand Down
20 changes: 10 additions & 10 deletions test/test_transforms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ using Base.Test

using Celeste: Types, SampleData, Transform, SensitiveFloats
import Celeste: ModelInit, ElboDeriv

using Compat
Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry for removing all the using Compats in #134! I figured most were for 0.3->0.4 changes and thus no longer needed.

Copy link
Owner Author

Choose a reason for hiding this comment

The 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();
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand All @@ -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()
Expand Down