Skip to content

Commit

Permalink
Use Missing instead of nullable:
Browse files Browse the repository at this point in the history
- Fix Nullable{T} to Union{T, Missing} for ordinariness.
- Test requirement update for RCall to 0.10.0, which also uses Missing.
  • Loading branch information
richardreeve committed Jan 18, 2018
1 parent cba95b5 commit 79cecfc
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
- v0.4.1
- Fix Nullable{T} to Union{T, Missing}
- Other minor updates for Julia 0.7
- v0.4.0
- Add in phylogenetic diversity
- Create a formal API (in `API.jl`) for extending to new types of diversity
Expand Down
1 change: 1 addition & 0 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
julia 0.6
DataFrames 0.9.0
Phylo 0.2.0
Missings
9 changes: 5 additions & 4 deletions src/Metacommunity.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using DataFrames
using Missings

"""
Metacommunity{FP, ARaw, AProcessed, Part, Sim}
Expand Down Expand Up @@ -40,7 +41,7 @@ mutable struct Metacommunity{FP, ARaw, AProcessed, Sim, Part} <:
scale::FP
types::Sim
partition::Part
ordinariness::Nullable{AProcessed}
ordinariness::Union{AProcessed, Missing}

function Metacommunity{FP, ARaw, AProcessed,
Sim, Part}(abundances::ARaw,
Expand All @@ -54,7 +55,7 @@ mutable struct Metacommunity{FP, ARaw, AProcessed, Sim, Part} <:
"partition and type list")
processedabundances, scale = _calcabundance(types, matrix)
new{FP, ARaw, AProcessed, Sim, Part}(abundances, processedabundances, scale,
types, part, Nullable{AProcessed}())
types, part, missing)
end
end

Expand Down Expand Up @@ -148,10 +149,10 @@ end

import Diversity.API._getordinariness!
function _getordinariness!(meta::Metacommunity)
if isnull(meta.ordinariness)
if ismissing(meta.ordinariness)
meta.ordinariness = _calcordinariness(meta.types, meta.processedabundances, meta.scale)
end
get(meta.ordinariness)
meta.ordinariness
end

import Diversity.API._getscale
Expand Down
2 changes: 1 addition & 1 deletion test/REQUIRE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Distances 0.3.2
StatsBase 0.10.0
RCall 0.7.3
RCall 0.10.0
Compat 0.33.0
5 changes: 3 additions & 2 deletions test/test_Metacommunity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ using Compat.Test
using Diversity
using Diversity.API
using DataFrames
using Missings

three = [0.3
0.3
Expand Down Expand Up @@ -62,9 +63,9 @@ g2 = GeneralTypes(eye(2))
@testset "Metacommunity" begin
@test gettypes(meta) == ms
@test getpartition(meta) == oc_count
@test isnull(meta.ordinariness)
@test ismissing(meta.ordinariness)
@test getordinariness!(meta) [0.3, 0.6, 1.0]
@test !isnull(meta.ordinariness)
@test !ismissing(meta.ordinariness)
@test getabundance(Metacommunity(ab3, g2, sc))
getabundance(Metacommunity(abf, g2, sc))
@test_warn "not normalised" Metacommunity(ab3 * 1.0, eye(2))
Expand Down

0 comments on commit 79cecfc

Please sign in to comment.