Skip to content

Commit

Permalink
add test for indexing with a species name
Browse files Browse the repository at this point in the history
  • Loading branch information
mkborregaard committed Feb 5, 2020
1 parent f6e566c commit 7f2a913
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
DataFrames = "0.20"
DataFramesMeta = "0.5"
Distances = "0.8"
EcoBase = "0.1.0"
EcoBase = "0.1.1"
RandomBooleanMatrices = "0.1"
RandomNumbers = "1.4"
RecipesBase = "0.7"
Expand Down
4 changes: 2 additions & 2 deletions src/ComMatrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ nplaces(pd::PointData) = size(pd.coords, 1)
nrecords(com::AbstractComMatrix) = _nnz(occurrences(com))

const getspecies = thingoccurrences
thingoccurrences(com::AbstractComMatrix, idx) = thingoccurrences(occurrences(com), idx)
thingoccurrences(com::AbstractComMatrix, idx) = thingoccurrences(occurrences(com), asindices(idx, thingnames(com)))

const getsite = placeoccurrences
placeoccurrences(com::AbstractComMatrix, idx) = placeoccurrences(occurrences(com), idx)
placeoccurrences(com::AbstractComMatrix, idx) = placeoccurrences(occurrences(com), asindices(idx, placenames(com)))

const speciesnames = thingnames
thingnames(com::AbstractComMatrix) = com.speciesnames
Expand Down
1 change: 1 addition & 0 deletions test/ComMatrix_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ using Test
@test noccupied(cmf) == 11

@test getspecies(cmb, 3) == [false, true, true, true, true, true, true, true]
@test getspecies(cmb, "species2") == [true, true, true, true, false, true, true, true]
@test getspecies(cmi, 2) == [15, 15, 0, 2, 28, 99, 25, 29, 23, 90, 96, 7, 43]
gcm = getspecies(cmf, 6)
@test gcm[3] == 0.08724510824225518
Expand Down

2 comments on commit 7f2a913

@mkborregaard
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/8909

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if Julia TagBot is installed, or can be done manually through the github interface, or via:

git tag -a v0.9.0 -m "<description of version>" 7f2a913ee597ee0415d1230c371032a1903d2f81
git push origin v0.9.0

Please sign in to comment.