Skip to content

Commit

Permalink
Merge pull request #41 from EcoJulia/cleanup
Browse files Browse the repository at this point in the history
Remove pre-julia 0.7 code
  • Loading branch information
richardreeve committed Aug 2, 2021
2 parents ddd4083 + 9654d40 commit 41992a6
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 58 deletions.
35 changes: 0 additions & 35 deletions src/Iterators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,6 @@ function TypeIterator(meta::M) where M <: AbstractMetacommunity
return TypeIterator(getabundance, meta)
end

if VERSION < v"0.7.0-"
import Base.start, Base.next, Base.done
function start(ti::TypeIterator)
return 1
end

function next(ti::TypeIterator, state)
return (ti.viewfn(ti.metacommunity, state), state + 1)
end

function done(ti::TypeIterator, state)
return state > counttypes(ti.metacommunity)
end

else
import Base.iterate
function iterate(ti::TypeIterator, state = 1)
if state > counttypes(ti.metacommunity)
Expand All @@ -48,8 +33,6 @@ function iterate(ti::TypeIterator, state = 1)
return ti.viewfn(ti.metacommunity, state), state + 1
end

end

function IteratorSize(ti::Type{TypeIterator})
return HasLength()
end
Expand Down Expand Up @@ -89,31 +72,13 @@ function SubcommunityIterator(meta::M) where M <: AbstractMetacommunity
return SubcommunityIterator(getabundance, meta)
end

if VERSION < v"0.7.0-"
function start(si::SubcommunityIterator)
return 1
end

function next(si::SubcommunityIterator, state)
return (si.viewfn(si.metacommunity, state), state + 1)
end

function done(si::SubcommunityIterator, state)
return state > countsubcommunities(si.metacommunity)
end

else

function iterate(si::SubcommunityIterator, state = 1)
if state > countsubcommunities(si.metacommunity)
return nothing
end
return si.viewfn(si.metacommunity, state), state + 1
end

end


function IteratorSize(si::Type{SubcommunityIterator})
return HasLength()
end
Expand Down
10 changes: 2 additions & 8 deletions test/pkg_RCall.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,14 @@ module ValidateRCall
mustCrossvalidate = haskey(ENV, "JULIA_MUST_CROSSVALIDATE") && ENV["JULIA_MUST_CROSSVALIDATE"] == "1"

# Only run R on unix or when R is installed because JULIA_MUST_CROSSVALIDATE is set to 1
global skipR = !mustCrossvalidate &&
!((VERSION < v"0.7.0-" && is_unix()) ||
(VERSION >= v"0.7.0-" && Sys.isunix()))
global skipR = !mustCrossvalidate && !Sys.isunix()
try
skipR && error("Skipping R testing...")
using RCall
global skipR = false
catch
global skipR = true
if mustCrossvalidate && VERSION < v"0.7.0-"
error("R not installed, but JULIA_MUST_CROSSVALIDATE is set")
else
@warn "R or appropriate Phylo package not installed, skipping R cross-validation."
end
@warn "R or appropriate Phylo package not installed, skipping R cross-validation."
end

!skipR && include("run_rcall.jl")
Expand Down
10 changes: 0 additions & 10 deletions test/test_EffectiveNumbers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,6 @@ end
for i in 1:size(manyweights, 2)
@test qD(manyweights[:,i], [0]) numspecies * ones((1, size(manyweights[:,i], 2)))
end

# Diversities are not normalised, so generate an error
if VERSION < v"0.7.0-"
@test_warn "Abundances not normalised to 1, correcting..." qD([0.1, 0.1], 1)
end
end

@testset "qDZ" begin
Expand All @@ -80,11 +75,6 @@ end
ones((size(manyweights[:,i], 1),
size(manyweights[:,i], 1)))) ones((4, size(manyweights[:,i], 2)))
end

if VERSION < v"0.7.0-"
# Diversities are not normalised, so generate an warning
@test_warn "Abundances not normalised to 1, correcting..." qDZ([0.1, 0.1], 1)
end
end

end
5 changes: 0 additions & 5 deletions test/test_Metacommunity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,6 @@ g2 = GeneralTypes(Matrix(1.0I, 2, 2))
@test !ismissing(meta.ordinariness)
@test getabundance(Metacommunity(ab3, g2, sc))
getabundance(Metacommunity(abf, g2, sc))
if VERSION < v"0.7.0-"
@test_warn "not normalised" Metacommunity(ab3 * 1.0, Matrix(1.0I, 2, 2))
@test_warn "not normalised" Metacommunity([1.0, 2.0], Matrix(1.0I, 2, 2))
@test_warn "not normalised" Metacommunity(ab3 * 1.0, meta2)
end
@test_nowarn Metacommunity([0.5, 0.5], Matrix(1.0I, 2, 2))
@test_throws ErrorException Metacommunity(abf, ms, sc)
@test_throws DimensionMismatch Metacommunity([1, 2, 3]/6, meta2)
Expand Down

0 comments on commit 41992a6

Please sign in to comment.