Skip to content

Commit 728e58e

Browse files
Merge pull request #17 from simonschoelly/fixes_for_v1.0
Fixes for Julia version 0.7 and 1.0
2 parents 07f3960 + 06df354 commit 728e58e

File tree

12 files changed

+231
-202
lines changed

12 files changed

+231
-202
lines changed

.travis.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,22 @@ language: julia
33
os:
44
- linux
55
- osx
6+
67
julia:
7-
- 0.6
8+
- 0.7
9+
- 1.0
10+
- nightly
11+
12+
matrix:
13+
allow_failures:
14+
- julia: nightly
15+
816
notifications:
917
email: false
18+
1019
# uncomment the following lines to override the default test script
1120
script:
1221
- if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
13-
- julia -e 'Pkg.clone(pwd()); Pkg.build("NetworkLayout"); Pkg.checkout("GeometryTypes"); Pkg.clone("LightGraphs"); Pkg.test("NetworkLayout"; coverage=true)'
22+
- julia -e 'using Pkg; Pkg.clone(pwd()); Pkg.build("NetworkLayout"); Pkg.clone("LightGraphs"); Pkg.test("NetworkLayout"; coverage=true)'
1423
after_success:
15-
- julia -e 'cd(Pkg.dir("NetworkLayout")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(process_folder()); Codecov.submit(process_folder())'
24+
- julia -e 'using Pkg; cd(Pkg.dir("NetworkLayout")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(process_folder()); Codecov.submit(process_folder())'

REQUIRE

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
julia 0.6-
1+
julia 0.7
22
GeometryTypes
3-
Compat 0.8.6
4-
StaticArrays

appveyor.yml

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
environment:
22
matrix:
3-
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6-latest-win32.exe"
4-
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.6/julia-0.6-latest-win64.exe"
5-
#- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
6-
#- JULIA_URL: "https://julialangnightlies-s3.julialang.org/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,19 +26,19 @@ notifications:
1726
on_build_status_changed: false
1827

1928
install:
20-
- ps: "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12"
21-
# Download most recent Julia Windows binary
22-
- ps: (new-object net.webclient).DownloadFile(
23-
$env:JULIA_URL,
24-
"C:\projects\julia-binary.exe")
25-
# Run installer silently, output to C:\projects\julia
26-
- 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"))
2730

2831
build_script:
2932
# Need to convert from shallow to complete for Pkg.clone to work
3033
- IF EXIST .git\shallow (git fetch --unshallow)
31-
- C:\projects\julia\bin\julia -e "versioninfo();
32-
Pkg.clone(pwd(), \"NetworkLayout\"); Pkg.build(\"NetworkLayout\"); Pkg.checkout(\"GeometryTypes\")"
34+
- C:\julia\bin\julia -e "using InteractiveUtils, Pkg; versioninfo();
35+
Pkg.clone(pwd(), \"NetworkLayout\"); Pkg.build(\"NetworkLayout\")"
3336

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

src/buchheim.jl

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@ tree Adjacency List that represents the given tree
1010
Returns
1111
positions co-ordinates of the layout
1212
"""
13-
1413
module Buchheim
1514

1615
using GeometryTypes
1716

18-
immutable Tree{A<:AbstractVector,P<:AbstractVector,F}
17+
struct Tree{A<:AbstractVector,P<:AbstractVector,F}
1918
nodes::A
2019
mod::F
2120
thread::Vector{Int}
@@ -27,49 +26,50 @@ immutable Tree{A<:AbstractVector,P<:AbstractVector,F}
2726
nodesize::F
2827
end
2928

30-
function Tree{T}(tree::AbstractVector{T}, nodesize)
31-
mod = zeros(length(tree))
32-
thread = zeros(Int,length(tree))
33-
prelim = zeros(length(tree))
34-
shift = zeros(length(tree))
35-
change = zeros(length(tree))
36-
ancestor = [i for i in 1:length(tree)]
29+
function Tree(tree::AbstractVector, nodesize)
30+
len = length(tree)
31+
mod = zeros(len)
32+
thread = zeros(Int, len)
33+
prelim = zeros(len)
34+
shift = zeros(len)
35+
change = zeros(len)
36+
ancestor = collect(1:len)
3737
nodes = copy(tree)
38-
positions = zeros(Point{2,Float64},length(tree))
39-
t = Tree(nodes,mod,thread,ancestor,prelim,shift,change,positions,nodesize)
38+
positions = zeros(Point{2,Float64}, len)
39+
t = Tree(nodes, mod, thread, ancestor, prelim, shift, change, positions, nodesize)
4040
return t
4141
end
4242

43-
function layout{T}(t::AbstractVector{T}; nodesize=ones(length(t)))
44-
layout!(t,nodesize)
43+
function layout(t::AbstractVector; nodesize=ones(length(t)))
44+
layout!(t, nodesize)
4545
end
4646

47-
function layout!{T}(t::AbstractVector{T}, nodesize)
48-
tree = Tree(t,nodesize)
49-
first_walk(1,tree)
50-
second_walk(1,-tree.prelim[1],0.0,tree)
47+
function layout!(t::AbstractVector, nodesize)
48+
tree = Tree(t, nodesize)
49+
first_walk(1, tree)
50+
second_walk(1, -tree.prelim[1], 0.0, tree)
5151
return tree.positions
5252
end
5353

54-
function parent{T}(v::T,t::Tree)
54+
function parent(v, t::Tree)
5555
tree = t.nodes
5656
for i in 1:length(tree)
57-
y = find(x->(x==v),tree[i])
58-
if length(y)!=0
57+
y = findall(x -> (x==v), tree[i])
58+
if length(y) != 0
5959
return i
6060
end
6161
end
6262
return nothing
6363
end
6464

65-
function first_walk{T}(v::T,t::Tree)
65+
function first_walk(v, t::Tree)
6666
prelim = t.prelim
6767
mod = t.mod
6868
tree = t.nodes
6969
nodesize = t.nodesize
7070
p = parent(v,t)
7171
if p != nothing
72-
index = find(x->(x==v),tree[p])[1]
72+
index = findall(x -> (x==v), tree[p])[1]
7373
else
7474
index = 1
7575
end
@@ -83,51 +83,51 @@ function first_walk{T}(v::T,t::Tree)
8383
defaultAncestor = tree[v][1]
8484
for w in tree[v]
8585
first_walk(w,t)
86-
defaultAncestor = apportion(w,defaultAncestor,t)
86+
defaultAncestor = apportion(w, defaultAncestor, t)
8787
end
88-
execute_shifts(v,t)
88+
execute_shifts(v, t)
8989
midpoint = (prelim[tree[v][1]] + prelim[tree[v][end]]) / 2
9090
if index > 1
9191
w = tree[p][index-1]
92-
prelim[v] = prelim[w] + (nodesize[w]+1.0)
92+
prelim[v] = prelim[w] + (nodesize[w] + 1.0)
9393
mod[v] = prelim[v] - midpoint
9494
else
9595
prelim[v] = midpoint
9696
end
9797
end
9898
end
9999

100-
function apportion{T}(v::T,defaultAncestor::T,t::Tree)
100+
function apportion(v::T, defaultAncestor::T, t::Tree) where {T}
101101
tree = t.nodes
102102
ancestor = t.ancestor
103103
prelim = t.prelim
104104
mod = t.mod
105105
thread = t.thread
106-
p = parent(v,t)
106+
p = parent(v, t)
107107
nodesize = t.nodesize
108108
if p != nothing
109-
index = find(x->(x==v),tree[p])[1]
109+
index = findall(x-> (x==v), tree[p])[1]
110110
else
111111
index = 1
112112
end
113113
if index > 1
114114
w = tree[p][index-1]
115115
v_in_right = v_out_right = v
116116
v_in_left = w
117-
v_out_left = tree[parent(v_in_right,t)][1]
117+
v_out_left = tree[parent(v_in_right, t)][1]
118118
s_in_right = mod[v_in_right]
119119
s_out_right = mod[v_out_right]
120120
s_in_left = mod[v_in_left]
121121
s_out_left = mod[v_out_left]
122-
while next_right(v_in_left,t)!=0 && next_left(v_in_right,t)!=0
123-
v_in_left = next_right(v_in_left,t)
124-
v_in_right = next_left(v_in_right,t)
125-
v_out_left = next_left(v_out_left,t)
126-
v_out_right = next_right(v_out_right,t)
122+
while next_right(v_in_left, t)!=0 && next_left(v_in_right, t)!=0
123+
v_in_left = next_right(v_in_left, t)
124+
v_in_right = next_left(v_in_right, t)
125+
v_out_left = next_left(v_out_left, t)
126+
v_out_right = next_right(v_out_right, t)
127127
ancestor[v_out_right] = v
128128
shift = (prelim[v_in_left] + s_in_left) - (prelim[v_in_right] + s_in_right) + (nodesize[v_in_left])
129129
if shift > 0
130-
move_subtree(find_ancestor(v_in_left,v,defaultAncestor,t),v,shift,t)
130+
move_subtree(find_ancestor(v_in_left, v, defaultAncestor,t), v,shift, t)
131131
s_in_right += shift
132132
s_out_right += shift
133133
end
@@ -136,12 +136,12 @@ function apportion{T}(v::T,defaultAncestor::T,t::Tree)
136136
s_out_left += mod[v_out_left]
137137
s_out_right += mod[v_out_right]
138138
end
139-
if next_right(v_in_left,t)!=0 && next_right(v_out_right,t)==0
140-
thread[v_out_right] = next_right(v_in_left,t)
139+
if next_right(v_in_left, t) != 0 && next_right(v_out_right, t) == 0
140+
thread[v_out_right] = next_right(v_in_left, t)
141141
mod[v_out_right] += s_in_left - s_out_right
142142
else
143-
if next_left(v_in_right,t)!=0 next_left(v_out_left,t)==0
144-
thread[v_out_left] = next_left(v_in_right,t)
143+
if next_left(v_in_right,t) != 0 && next_left(v_out_left,t) == 0
144+
thread[v_out_left] = next_left(v_in_right, t)
145145
mod[v_out_left] += s_in_right - s_out_left
146146
defaultAncestor = v
147147
end
@@ -150,20 +150,20 @@ function apportion{T}(v::T,defaultAncestor::T,t::Tree)
150150
return defaultAncestor
151151
end
152152

153-
function number{T}(v::T,t::Tree)
154-
p = parent(v,t)
155-
index = find(x->(x==v),t.nodes[p])[1]
153+
function number(v, t::Tree)
154+
p = parent(v, t)
155+
index = findall(x -> (x==v), t.nodes[p])[1]
156156
return index
157157
end
158158

159-
function move_subtree{T}(w_left::T,w_right::T,shift::Float64,t::Tree)
159+
function move_subtree(w_left::T, w_right::T, shift::Float64, t::Tree) where {T}
160160
change = t.change
161161
prelim = t.prelim
162162
tree = t.nodes
163163
shifttree = t.shift
164164
mod = t.mod
165-
n_wl = number(w_left,t)
166-
n_wr = number(w_right,t)
165+
n_wl = number(w_left, t)
166+
n_wr = number(w_right, t)
167167
subtrees = n_wr - n_wl
168168
change[w_right] -= shift / subtrees
169169
shifttree[w_right] += shift
@@ -172,32 +172,32 @@ function move_subtree{T}(w_left::T,w_right::T,shift::Float64,t::Tree)
172172
mod[w_right] += shift
173173
end
174174

175-
function second_walk{T}(v::T,m::Float64,depth::Float64,t::Tree)
175+
function second_walk(v, m::Float64, depth::Float64, t::Tree)
176176
prelim = t.prelim
177177
mod = t.mod
178178
positions = t.positions
179179
nodesize = t.nodesize
180-
positions[v] = Point(prelim[v]+m,-depth)
181-
if length(t.nodes[v])!=0
180+
positions[v] = Point(prelim[v]+m, -depth)
181+
if length(t.nodes[v]) != 0
182182
maxdist = maximum([nodesize[i] for i in t.nodes[v]])
183183
else
184184
maxdist = 0
185185
end
186186
for w in t.nodes[v]
187-
second_walk(w,m+mod[v],Float64(depth+1+maxdist),t)
187+
second_walk(w, m+mod[v], Float64(depth + 1 + maxdist), t)
188188
end
189189
end
190190

191-
function find_ancestor{T}(w::T,v::T,defaultAncestor::T,tree::Tree)
191+
function find_ancestor(w::T, v::T, defaultAncestor::T, tree::Tree) where {T}
192192
ancestor = tree.ancestor
193-
if ancestor[w] in tree.nodes[parent(v,tree)]
193+
if ancestor[w] in tree.nodes[parent(v, tree)]
194194
return ancestor[w]
195195
else
196196
return defaultAncestor
197197
end
198198
end
199199

200-
function execute_shifts{T}(v::T,t::Tree)
200+
function execute_shifts(v, t::Tree)
201201
tree = t.nodes
202202
shift = t.shift
203203
change = t.change
@@ -213,7 +213,7 @@ function execute_shifts{T}(v::T,t::Tree)
213213
end
214214
end
215215

216-
function next_left{T}(v::T,t::Tree)
216+
function next_left(v, t::Tree)
217217
tree = t.nodes
218218
thread = t.thread
219219
if length(tree[v]) != 0
@@ -223,7 +223,7 @@ function next_left{T}(v::T,t::Tree)
223223
end
224224
end
225225

226-
function next_right{T}(v::T,t::Tree)
226+
function next_right(v, t::Tree)
227227
tree = t.nodes
228228
thread = t.thread
229229
if length(tree[v]) != 0

src/circular.jl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,20 @@ julia> g = simple_house_graph()
1414
julia> locs_x, locs_y = circular_layout(g)
1515
```
1616
"""
17-
1817
module Circular
1918

2019
using GeometryTypes
2120

22-
function layout{M<:AbstractMatrix}(adj_matrix::M)
21+
function layout(adj_matrix::AbstractMatrix)
2322
layout!(adj_matrix)
2423
end
2524

26-
function layout!{M<:AbstractMatrix}(adj_matrix::M)
25+
function layout!(adj_matrix::AbstractMatrix)
2726
if size(adj_matrix,1) == 1
28-
return Point{2,Float64}[Point(0.0,0.0)]
27+
return Point{2,Float64}[Point(0.0, 0.0)]
2928
else
3029
# Discard the extra angle since it matches 0 radians.
31-
θ = linspace(0, 2pi, size(adj_matrix,1) + 1)[1:end-1]
30+
θ = range(0, stop=2pi, length=size(adj_matrix,1) + 1)[1:end-1]
3231
return Point{2,Float64}[(cos(o), sin(o)) for o in θ]
3332
end
3433
end

0 commit comments

Comments
 (0)