Skip to content

Commit

Permalink
Replace [range] idiom by collect(range) and int(string) by parse(Int,…
Browse files Browse the repository at this point in the history
…string)
  • Loading branch information
davidavdav committed Apr 5, 2016
1 parent e947872 commit d3d9cb4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 2 additions & 3 deletions src/sgearray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
issgearray() = haskey(ENV, "SGE_TASK_ID") && haskey(ENV, "SGE_TASK_LAST") && ENV["SGE_TASK_ID"] != "undefined"

Base.start(sge::SGEArray) = sge.start
Base.done(sge::SGEArray, state::Int) = state > length(sge.array)
Base.done(sge::SGEArray, state::Int) = state > length(sge.array)
Base.next(sge::SGEArray, state::Int) = sge.array[state], state+sge.step
Base.length(sge::SGEArray) = div(length(sge.array)-sge.start, sge.step)+1

SGEArray(r::Range) = SGEArray([r])

SGEArray(r::Range) = SGEArray(collect(r))
6 changes: 3 additions & 3 deletions src/sgetypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
## (c) 2014 David A. van Leeuwen
##

## The inner constructor returns the array itself if not running in
## The inner constructor returns the array itself if not running in
## an SGE environment. I don't know if that is the Julian way...
type SGEArray
start::Int
Expand All @@ -12,8 +12,8 @@ type SGEArray
if !issgearray()
a
else
start = int(ENV["SGE_TASK_ID"])
step = int(ENV["SGE_TASK_LAST"])
start = parse(Int, ENV["SGE_TASK_ID"])
step = parse(Int, ENV["SGE_TASK_LAST"])
l = length(a)
if step < start || start > length(a)
error("Incorrect array parameters")
Expand Down

0 comments on commit d3d9cb4

Please sign in to comment.