Skip to content

Commit 9f56f12

Browse files
authored
Revert "Updates for Julia 1.0 (#102)" (#104)
This reverts commit b4a40ae.
1 parent b4a40ae commit 9f56f12

19 files changed

+140
-856
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ os:
66
- osx
77

88
julia:
9-
- 0.7
10-
- 1.0
9+
- 0.5
10+
- 0.6
1111
- nightly
1212

1313
matrix:
1414
allow_failures:
15-
- julia: nightly
15+
- julia: 0.5
1616

1717

1818
notifications:

REQUIRE

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
julia 0.7
2-
IntervalArithmetic 0.15
3-
IntervalRootFinding 0.4
4-
IntervalContractors 0.3
5-
MacroTools 0.4.4
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+

appveyor.yml

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,9 @@
11
environment:
22
matrix:
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
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"
167

178
branches:
189
only:
@@ -26,18 +17,18 @@ notifications:
2617
on_build_status_changed: false
2718

2819
install:
29-
- ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/version-1/bin/install.ps1"))
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
3026

3127
build_script:
32-
- echo "%JL_BUILD_SCRIPT%"
33-
- C:\julia\bin\julia -e "%JL_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\")"
3432

3533
test_script:
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%"
34+
- C:\projects\julia\bin\julia --check-bounds=yes -e "Pkg.test(\"ConstraintPropagation\")"

src/IntervalConstraintProgramming.jl

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@ __precompile__()
22

33
module IntervalConstraintProgramming
44

5-
using IntervalArithmetic,
6-
IntervalRootFinding,
7-
IntervalContractors
8-
9-
using Random
5+
using IntervalArithmetic,
6+
IntervalRootFinding,
7+
IntervalContractors
108

119
using MacroTools
1210

@@ -22,15 +20,9 @@ export
2220
SubPaving, Paving,
2321
pave, refine!,
2422
Vol,
25-
show_code,
26-
icp, icp!,
27-
Constraint
23+
show_code
2824

2925
const reverse_operations = IntervalContractors.reverse_operations
30-
const ARRAY_TYPES = (:AbstractArray, :AbstractVector, :AbstractMatrix, :Array, :Vector, :Matrix)
31-
const REAL_TYPES = (:Bool, :Integer, :(Irrational{:e}), :(Irrational{}), :Rational, :BigFloat, :BigInt, :AbstractFloat, :Real)
32-
const FUNCTIONS = ((:Base, :+, 2), (:Base, :/, 2), (:Base, :^, 2), (:Base, :asin, 1), (:Base, :cos, 1), (:Base, :exp, 1), (:Base, :*, 2), (:Base, :abs, 1), (:Base, :log, 1), (:Base, :-, 2), (:Base, :sqrt, 1), (:Base, :tan, 1), (:Base, :sin, 1), )
33-
# ^(x::Interval{Float64}, p::Integer) = pow(x, p)
3426

3527
include("ast.jl")
3628
include("code_generation.jl")
@@ -41,10 +33,4 @@ include("setinversion.jl")
4133
include("volume.jl")
4234
include("functions.jl")
4335

44-
include("tape/tape.jl")
45-
include("tape/Config.jl")
46-
include("tape/tracked.jl")
47-
include("tape/operations.jl")
48-
include("tape/icp.jl")
49-
5036
end # module

src/ast.jl

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const symbol_numbers = Dict{Symbol, Int}()
22

33

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

77
i = get(symbol_numbers, s, 0)
@@ -17,7 +17,7 @@ end
1717
make_symbol(c::Char) = make_symbol(Symbol(c))
1818

1919
let current_symbol = 'a'
20-
global function make_symbol()
20+
function make_symbol()
2121
current_sym = current_symbol
2222

2323
if current_sym < 'z'
@@ -36,7 +36,7 @@ function make_symbols(n::Integer)
3636
end
3737

3838
# The following function is not used
39-
"""Check if a symbol like `:a` has been uniqued to `:_a_1_`"""
39+
doc"""Check if a symbol like `:a` has been uniqued to `:_a_1_`"""
4040
function isuniqued(s::Symbol)
4141
ss = string(s)
4242
contains(ss, "_") && isdigit(ss[end-1])
@@ -46,21 +46,21 @@ end
4646

4747
# Combine Assignment and FunctionAssignment ?
4848

49-
struct Assignment
49+
immutable Assignment
5050
lhs
5151
op
5252
args
5353
end
5454

55-
struct FunctionAssignment
55+
immutable FunctionAssignment
5656
f # function name
5757
args # input arguments
5858
return_arguments
5959
intermediate # tuple of intermediate variables
6060
end
6161

6262
# Close to single assignment form
63-
mutable struct FlatAST
63+
type FlatAST
6464
top # topmost variable(s)
6565
input_variables::Set{Symbol}
6666
intermediate::Vector{Symbol} # generated vars
@@ -103,17 +103,18 @@ function flatten(ex)
103103
end
104104

105105

106-
# TODO: Parameters
107-
# numbers:
108-
109-
"""`flatten!` recursively converts a Julia expression into a "flat" (one-dimensional)
106+
doc"""`flatten!` recursively converts a Julia expression into a "flat" (one-dimensional)
110107
structure, stored in a FlatAST object. This is close to SSA (single-assignment form,
111108
https://en.wikipedia.org/wiki/Static_single_assignment_form).
112109
113110
Variables that are found are considered `input_variables`.
114111
Generated variables introduced at intermediate nodes are stored in
115112
`intermediate`.
116113
Returns the variable at the top of the current piece of the tree."""
114+
115+
# TODO: Parameters
116+
117+
# numbers:
117118
function flatten!(flatAST::FlatAST, ex)
118119
return ex # nothing to do to the AST; return the number
119120
end
@@ -126,7 +127,6 @@ end
126127

127128

128129
function flatten!(flatAST::FlatAST, ex::Expr)
129-
#@show ex
130130
local top
131131

132132
if ex.head == :$ # constants written as $a
@@ -163,6 +163,7 @@ end
163163
"""A block represents a linear sequence of Julia statements.
164164
They are processed in order.
165165
"""
166+
166167
function process_block!(flatAST::FlatAST, ex)
167168
local top
168169

src/code_generation.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
"""
1+
doc"""
22
A generated function, with the code that generated it
33
"""
4-
struct GeneratedFunction{F}
4+
immutable 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})(x...) where {F} = f.f(x...)
13+
(f::GeneratedFunction{F}){F}(x...) = f.f(x...)
1414

1515

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

181181

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

src/contractor.jl

Lines changed: 9 additions & 9 deletions
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$.
4+
Nout is the output dimension of the forward part.
25
"""
3-
`Contractor` represents a contractor from ``\\mathbb{R}^N`` to ``\\mathbb{R}^N``.
4-
`Nout` is the output dimension of the forward part.
5-
"""
6-
struct Contractor{N, Nout, F1<:Function, F2<:Function}
6+
immutable 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(io::IO, C::Contractor{N,Nout,F1,F2}) where {N,Nout,F1,F2}
35+
function Base.show{N,Nout,F1,F2}(io::IO, C::Contractor{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})(
45-
A::IntervalBox{Nout,T}, X::IntervalBox{N,T}) where {N,Nout,F1,F2,T}
44+
function (C::Contractor{N,Nout,F1,F2}){N,Nout,F1,F2,T}(
45+
A::IntervalBox{Nout,T}, X::IntervalBox{N,T})
4646

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

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

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

7272
function make_contractor(expr::Expr)
7373
# println("Entering Contractor(ex) with ex=$ex")
@@ -109,7 +109,7 @@ function make_contractor(expr::Expr)
109109
end
110110

111111

112-
"""Usage:
112+
doc"""Usage:
113113
```
114114
C = @contractor(x^2 + y^2)
115115
A = -∞..1 # the constraint interval

src/functions.jl

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11

22

3-
"""
3+
doc"""
44
A `ConstraintFunction` contains the created forward and backward
55
code
66
"""
7-
mutable struct ConstraintFunction{F<:Function, G<:Function}
7+
type 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 @@ mutable struct ConstraintFunction{F<:Function, G<:Function}
1414
expression::Expr
1515
end
1616

17-
function Base.show(io::IO, f::ConstraintFunction{F,G}) where {F,G}
17+
function Base.show{F,G}(io::IO, f::ConstraintFunction{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-
struct FunctionArguments
25+
immutable FunctionArguments
2626
input
2727
return_arguments
2828
intermediate
@@ -32,12 +32,13 @@ end
3232

3333
const registered_functions = Dict{Symbol, FunctionArguments}()
3434

35-
# TODO: This docstring doesn't work
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-
# """
35+
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+
4142
@eval macro ($(:function))(ex) # workaround to define macro @function
4243

4344
(f, args, code) = match_function(ex)
@@ -57,6 +58,8 @@ const registered_functions = Dict{Symbol, FunctionArguments}()
5758
# flatAST.intermediate = [return_arguments; flatAST.intermediate]
5859

5960

61+
62+
6063
forward, backward = forward_backward(flatAST)
6164

6265
registered_functions[f] = FunctionArguments(

0 commit comments

Comments
 (0)