-
Notifications
You must be signed in to change notification settings - Fork 39
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
[WIP] Update for Julia 0.7 and 1.0 #96
Changes from 1 commit
dcdaac3
f67b9c1
8fe3b02
069910b
6e0d291
bc0dcb9
55a99af
754f61a
52a45c5
837daa1
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 |
---|---|---|
|
@@ -2,8 +2,8 @@ language: julia | |
os: | ||
- linux | ||
julia: | ||
- 0.5 | ||
- 0.6 | ||
- 0.7 | ||
- 1.0 | ||
- nightly | ||
notifications: | ||
email: false | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
julia 0.5 | ||
julia 0.7 | ||
Gtk | ||
GtkReactive 0.0.3 | ||
Cairo 0.5.1 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module Tree | ||
|
||
import Base: start, done, next, show | ||
import Base: iterate, show | ||
|
||
export Node, | ||
addchild, | ||
|
@@ -16,30 +16,30 @@ export Node, | |
# Any missing links (e.g., "c" does not have a sibling) link back to itself (c.sibling == c) | ||
# With this organization, no arrays need to be allocated. | ||
|
||
type Node{T} | ||
mutable struct Node{T} | ||
data::T | ||
parent::Node{T} | ||
child::Node{T} | ||
sibling::Node{T} | ||
|
||
# Constructor for the root of the tree | ||
function (::Type{Node{T}}){T}(data::T) | ||
function (::Type{Node{T}})(data::T) where T | ||
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 can change to the newer and much easier syntax, |
||
n = new{T}(data) | ||
n.parent = n | ||
n.child = n | ||
n.sibling = n | ||
n | ||
end | ||
# Constructor for all others | ||
function (::Type{Node{T}}){T}(data::T, parent::Node) | ||
function (::Type{Node{T}})(data::T, parent::Node) where T | ||
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. here too |
||
n = new{T}(data, parent) | ||
n.child = n | ||
n.sibling = n | ||
n | ||
end | ||
end | ||
Node{T}(data::T) = Node{T}(data) | ||
Node{T}(data::T, parent::Node{T}) = Node{T}(data, parent) | ||
Node(data::T) where {T} = Node{T}(data) | ||
Node(data::T, parent::Node{T}) where {T} = Node{T}(data, parent) | ||
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. Now that I know more I'd write this as Completely optional, however. |
||
|
||
function lastsibling(sib::Node) | ||
newsib = sib.sibling | ||
|
@@ -50,7 +50,7 @@ function lastsibling(sib::Node) | |
sib | ||
end | ||
|
||
function addsibling{T}(oldersib::Node{T}, data::T) | ||
function addsibling(oldersib::Node{T}, data::T) where T | ||
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. likewise here |
||
if oldersib.sibling != oldersib | ||
error("Truncation of sibling list") | ||
end | ||
|
@@ -59,7 +59,7 @@ function addsibling{T}(oldersib::Node{T}, data::T) | |
youngersib | ||
end | ||
|
||
function addchild{T}(parent::Node{T}, data::T) | ||
function addchild(parent::Node{T}, data::T) where T | ||
newc = Node(data, parent) | ||
prevc = parent.child | ||
if prevc == parent | ||
|
@@ -80,9 +80,10 @@ show(io::IO, n::Node) = print(io, n.data) | |
# for c in parent | ||
# # do something | ||
# end | ||
start(n::Node) = n.child | ||
done(n::Node, state::Node) = n == state | ||
next(n::Node, state::Node) = state, state == state.sibling ? n : state.sibling | ||
function iterate(n::Node, state = n.child) | ||
n == state && return nothing | ||
return state, state == state.sibling ? n : state.sibling | ||
end | ||
|
||
function showedges(io::IO, parent::Node, printfunc = identity) | ||
str = printfunc(parent.data) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,10 @@ function profile_test(n) | |
for i = 1:n | ||
A = randn(100,100,20) | ||
m = maximum(A) | ||
Afft = fft(A) | ||
Am = mapslices(sum, A, 2) | ||
# Afft = fft(A) | ||
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 assume 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. Agreed better not to use |
||
Am = mapslices(sum, A, dims = 2) | ||
B = A[:,:,5] | ||
Bsort = mapslices(sort, B, 1) | ||
Bsort = mapslices(sort, B, dims = 1) | ||
b = rand(100) | ||
C = B.*b | ||
end | ||
|
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.
Is it fine to drop both Julia 0.5 and 0.6 support on master? Otherwise some compatibility additions are needed.
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.
Yes, absolutely!