Skip to content

Commit 627b15f

Browse files
authored
Update to Julia 1.0 (#105)
* Remove doc from docstrings * Immutable -> struct * Fix some more deprecations * Remove seemingly extra esc * Remove @show * Fix more tests * Fix constraints with functions; tests pass on Julia 1.0 * Remove all ICP and tape stuff * Remove doc in docstrings * immutable -> struct * Fix 1.0 deprecations * Fix more 1.0 deprecations; tests pass locally * Update .travis.yml and appveyor.yml * Modernise .travis.yml * Remove docstring that doesn't work
1 parent 9f56f12 commit 627b15f

12 files changed

+136
-129
lines changed

.travis.yml

+12-13
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
1-
# Documentation: http://docs.travis-ci.com/user/languages/julia/
21
language: julia
32

3+
sudo: required
4+
5+
services:
6+
- docker
7+
48
os:
59
- linux
610
- osx
711

812
julia:
9-
- 0.5
10-
- 0.6
13+
- 0.7
14+
- 1.0
1115
- nightly
1216

13-
matrix:
14-
allow_failures:
15-
- julia: 0.5
16-
17+
# matrix:
18+
# allow_failures:
19+
# - julia: nightly
1720

1821
notifications:
1922
email: false
2023

21-
# uncomment the following lines to override the default test script
22-
#script:
23-
# - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
24-
# - julia -e 'Pkg.clone(pwd()); Pkg.build("ConstraintPropagation"); Pkg.test("ConstraintPropagation"; coverage=true)'
25-
2624
after_success:
27-
- julia -e 'Pkg.add("Documenter")'
25+
- julia -e 'using Pkg; Pkg.add("Documenter")'
2826
- julia -e 'cd(Pkg.dir("IntervalConstraintProgramming")); include(joinpath("docs", "make.jl"))'
27+
- julia -e 'cd(Pkg.dir("IntervalConstraintProgramming")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder()); Codecov.submit(process_folder())'

REQUIRE

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
julia 0.6 0.7
2-
IntervalArithmetic 0.9 0.14
3-
IntervalRootFinding 0.2 0.3
4-
IntervalContractors 0.2 0.3
5-
MacroTools 0.3
6-
1+
julia 0.7
2+
IntervalArithmetic 0.15
3+
IntervalRootFinding 0.4
4+
IntervalContractors 0.3
5+
MacroTools 0.4

appveyor.yml

+24-15
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
environment:
22
matrix:
3-
- JULIAVERSION: "julialang/bin/winnt/x86/0.4/julia-0.4-latest-win32.exe"
4-
- JULIAVERSION: "julialang/bin/winnt/x64/0.4/julia-0.4-latest-win64.exe"
5-
- JULIAVERSION: "julianightlies/bin/winnt/x86/julia-latest-win32.exe"
6-
- JULIAVERSION: "julianightlies/bin/winnt/x64/julia-latest-win64.exe"
3+
- julia_version: 0.7
4+
- julia_version: 1
5+
- julia_version: nightly
6+
7+
platform:
8+
- x86 # 32-bit
9+
- x64 # 64-bit
10+
11+
# # Uncomment the following lines to allow failures on nightly julia
12+
# # (tests will run but not make your overall status red)
13+
# matrix:
14+
# allow_failures:
15+
# - julia_version: nightly
716

817
branches:
918
only:
@@ -17,18 +26,18 @@ notifications:
1726
on_build_status_changed: false
1827

1928
install:
20-
# Download most recent Julia Windows binary
21-
- ps: (new-object net.webclient).DownloadFile(
22-
$("http://s3.amazonaws.com/"+$env:JULIAVERSION),
23-
"C:\projects\julia-binary.exe")
24-
# Run installer silently, output to C:\projects\julia
25-
- C:\projects\julia-binary.exe /S /D=C:\projects\julia
29+
- ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/version-1/bin/install.ps1"))
2630

2731
build_script:
28-
# Need to convert from shallow to complete for Pkg.clone to work
29-
- IF EXIST .git\shallow (git fetch --unshallow)
30-
- C:\projects\julia\bin\julia -e "versioninfo();
31-
Pkg.clone(pwd(), \"ConstraintPropagation\"); Pkg.build(\"ConstraintPropagation\")"
32+
- echo "%JL_BUILD_SCRIPT%"
33+
- C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%"
3234

3335
test_script:
34-
- C:\projects\julia\bin\julia --check-bounds=yes -e "Pkg.test(\"ConstraintPropagation\")"
36+
- echo "%JL_TEST_SCRIPT%"
37+
- C:\julia\bin\julia -e "%JL_TEST_SCRIPT%"
38+
39+
# # Uncomment to support code coverage upload. Should only be enabled for packages
40+
# # which would have coverage gaps without running on Windows
41+
# on_success:
42+
# - echo "%JL_CODECOV_SCRIPT%"
43+
# - C:\julia\bin\julia -e "%JL_CODECOV_SCRIPT%"

src/ast.jl

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
const symbol_numbers = Dict{Symbol, Int}()
22

3-
4-
doc"""Return a new, unique symbol like _z3_"""
3+
"""Return a new, unique symbol like _z3_"""
54
function make_symbol(s::Symbol) # default is :z
65

76
i = get(symbol_numbers, s, 0)
@@ -17,7 +16,7 @@ end
1716
make_symbol(c::Char) = make_symbol(Symbol(c))
1817

1918
let current_symbol = 'a'
20-
function make_symbol()
19+
global function make_symbol()
2120
current_sym = current_symbol
2221

2322
if current_sym < 'z'
@@ -36,7 +35,7 @@ function make_symbols(n::Integer)
3635
end
3736

3837
# The following function is not used
39-
doc"""Check if a symbol like `:a` has been uniqued to `:_a_1_`"""
38+
"""Check if a symbol like `:a` has been uniqued to `:_a_1_`"""
4039
function isuniqued(s::Symbol)
4140
ss = string(s)
4241
contains(ss, "_") && isdigit(ss[end-1])
@@ -46,21 +45,21 @@ end
4645

4746
# Combine Assignment and FunctionAssignment ?
4847

49-
immutable Assignment
48+
struct Assignment
5049
lhs
5150
op
5251
args
5352
end
5453

55-
immutable FunctionAssignment
54+
struct FunctionAssignment
5655
f # function name
5756
args # input arguments
5857
return_arguments
5958
intermediate # tuple of intermediate variables
6059
end
6160

6261
# Close to single assignment form
63-
type FlatAST
62+
mutable struct FlatAST
6463
top # topmost variable(s)
6564
input_variables::Set{Symbol}
6665
intermediate::Vector{Symbol} # generated vars
@@ -103,7 +102,7 @@ function flatten(ex)
103102
end
104103

105104

106-
doc"""`flatten!` recursively converts a Julia expression into a "flat" (one-dimensional)
105+
"""`flatten!` recursively converts a Julia expression into a "flat" (one-dimensional)
107106
structure, stored in a FlatAST object. This is close to SSA (single-assignment form,
108107
https://en.wikipedia.org/wiki/Static_single_assignment_form).
109108

src/code_generation.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
doc"""
1+
"""
22
A generated function, with the code that generated it
33
"""
4-
immutable GeneratedFunction{F}
4+
struct GeneratedFunction{F}
55
f::F
66
code::Expr
77
end
@@ -10,7 +10,7 @@ end
1010

1111
# GeneratedFunction(code::Expr) = GeneratedFunction(eval(code), code)
1212

13-
(f::GeneratedFunction{F}){F}(x...) = f.f(x...)
13+
(f::GeneratedFunction{F})(x...) where {F} = f.f(x...)
1414

1515

1616
function make_tuple(args)
@@ -179,7 +179,7 @@ function forward_backward(flatAST::FlatAST)
179179
end
180180

181181

182-
doc"""
182+
"""
183183
Generate code for an anonymous function with given
184184
input arguments, output arguments, and code block.
185185
"""

src/contractor.jl

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11

2-
doc"""
3-
`Contractor` represents a `Contractor` from $\mathbb{R}^N$ to $\mathbb{R}^N$.
2+
"""
3+
`Contractor` represents a `Contractor` from ``\\mathbb{R}^N`` to ``\\mathbb{R}^N``.
44
Nout is the output dimension of the forward part.
55
"""
6-
immutable Contractor{N, Nout, F1<:Function, F2<:Function}
6+
struct Contractor{N, Nout, F1<:Function, F2<:Function}
77
variables::Vector{Symbol} # input variables
88
forward::GeneratedFunction{F1}
99
backward::GeneratedFunction{F2}
@@ -32,7 +32,7 @@ function Contractor(variables::Vector{Symbol}, top, forward, backward, expressio
3232
Contractor{N, Nout, typeof(forward.f), typeof(backward.f)}(variables, forward, backward, expression)
3333
end
3434

35-
function Base.show{N,Nout,F1,F2}(io::IO, C::Contractor{N,Nout,F1,F2})
35+
function Base.show(io::IO, C::Contractor{N,Nout,F1,F2}) where {N,Nout,F1,F2}
3636
println(io, "Contractor in $(N) dimensions:")
3737
println(io, " - forward pass contracts to $(Nout) dimensions")
3838
println(io, " - variables: $(C.variables)")
@@ -41,8 +41,8 @@ end
4141

4242

4343

44-
function (C::Contractor{N,Nout,F1,F2}){N,Nout,F1,F2,T}(
45-
A::IntervalBox{Nout,T}, X::IntervalBox{N,T})
44+
function (C::Contractor{N,Nout,F1,F2})(
45+
A::IntervalBox{Nout,T}, X::IntervalBox{N,T}) where {N,Nout,F1,F2,T}
4646

4747
output, intermediate = C.forward(X)
4848

@@ -67,7 +67,8 @@ function (C::Contractor{N,Nout,F1,F2}){N,Nout,F1,F2,T}(
6767
end
6868

6969
# allow 1D contractors to take Interval instead of IntervalBox for simplicty:
70-
(C::Contractor{N,1,F1,F2}){N,F1,F2,T}(A::Interval{T}, X::IntervalBox{N,T}) = C(IntervalBox(A), X)
70+
71+
(C::Contractor{N,1,F1,F2})(A::Interval{T}, X::IntervalBox{N,T}) where {N,F1,F2,T} = C(IntervalBox(A), X)
7172

7273
function make_contractor(expr::Expr)
7374
# println("Entering Contractor(ex) with ex=$ex")
@@ -109,7 +110,7 @@ function make_contractor(expr::Expr)
109110
end
110111

111112

112-
doc"""Usage:
113+
"""Usage:
113114
```
114115
C = @contractor(x^2 + y^2)
115116
A = -∞..1 # the constraint interval

src/functions.jl

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11

22

3-
doc"""
3+
"""
44
A `ConstraintFunction` contains the created forward and backward
55
code
66
"""
7-
type ConstraintFunction{F <: Function, G <: Function}
7+
mutable struct ConstraintFunction{F <: Function, G <: Function}
88
input::Vector{Symbol} # input arguments for forward function
99
output::Vector{Symbol} # output arguments for forward function
1010
forward::F
@@ -14,15 +14,15 @@ type ConstraintFunction{F <: Function, G <: Function}
1414
expression::Expr
1515
end
1616

17-
function Base.show{F,G}(io::IO, f::ConstraintFunction{F,G})
17+
function Base.show(io::IO, f::ConstraintFunction{F,G}) where {F,G}
1818
println(io, "ConstraintFunction:")
1919
println(io, " - input arguments: $(f.input)")
2020
println(io, " - output arguments: $(f.output)")
2121
print(io, " - expression: $(MacroTools.striplines(f.expression))")
2222
end
2323

2424

25-
immutable FunctionArguments
25+
struct FunctionArguments
2626
input
2727
return_arguments
2828
intermediate
@@ -33,12 +33,11 @@ end
3333
const registered_functions = Dict{Symbol, FunctionArguments}()
3434

3535

36-
@doc """
37-
`@function` registers a function to be used in forwards and backwards mode.
38-
39-
Example: `@function f(x, y) = x^2 + y^2`
40-
""" # this docstring does not work!
41-
36+
# """
37+
# `@function` registers a function to be used in forwards and backwards mode.
38+
#
39+
# Example: `@function f(x, y) = x^2 + y^2`
40+
# """ # this docstring does not work!
4241
@eval macro ($(:function))(ex) # workaround to define macro @function
4342

4443
(f, args, code) = match_function(ex)

src/paving.jl

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
typealias SubPaving{N,T} Vector{IntervalBox{N,T}}
1+
const SubPaving{N,T} = Vector{IntervalBox{N,T}}
22

3-
type Paving{N,T}
3+
struct Paving{N,T}
44
separator::Separator # parametrize!
55
inner::SubPaving{N,T}
66
boundary::SubPaving{N,T}
77
ϵ::Float64
88
end
99

1010

11-
function setdiff{N,T}(x::IntervalBox{N,T}, subpaving::SubPaving{N,T})
11+
function setdiff(x::IntervalBox{N,T}, subpaving::SubPaving{N,T}) where {N,T}
1212
working = [x]
1313
new_working = IntervalBox{N,T}[]
1414

@@ -37,16 +37,16 @@ function setdiff{N,T}(x::IntervalBox{N,T}, subpaving::SubPaving{N,T})
3737

3838
end
3939

40-
setdiff{N,T}(X::SubPaving{N,T}, Y::SubPaving{N,T}) = vcat([setdiff(x, Y) for x in X]...)
40+
setdiff(X::SubPaving{N,T}, Y::SubPaving{N,T}) where {N,T} = vcat([setdiff(x, Y) for x in X]...)
4141

42-
function setdiff{N,T}(x::IntervalBox{N,T}, paving::Paving{N,T})
42+
function setdiff(x::IntervalBox{N,T}, paving::Paving{N,T}) where {N,T}
4343
Y = setdiff(x, paving.inner)
4444
Z = setdiff(Y, paving.boundary)
4545
return Z
4646
end
4747

4848

49-
function show{N,T}(io::IO, p::Paving{N,T})
49+
function show(io::IO, p::Paving{N,T}) where {N,T}
5050
print(io, """Paving:
5151
- tolerance ϵ = $(p.ϵ)
5252
- inner approx. of length $(length(p.inner))

0 commit comments

Comments
 (0)