alan-turing-institute / network-comparison

An R package implementing the NetEMD and NetDis network comparison measures
MIT License
14 stars 3 forks source link

C++ function not callable #100

Closed martintoreilly closed 6 years ago

martintoreilly commented 6 years ago

Description

When adding our first C++ function, we get an error while trying to call it. While the package build passes, the following error is encountered when running tests that rely on the new C++ code.

Failed ------------------------------------------------------------------------------------------

  1. Error: discrete_hist generates correct discrete histograms for random integer observations (@test_dhist.R#56) "netdist_counts_from_observations" not available for .Call() for package "netdist" 1: run_test() at /Users/martin/Source/Turing/network-comparison/tests/testthat/test_dhist.R:56 2: dhist_from_obs(observations) at /Users/martin/Source/Turing/network-comparison/tests/testthat/test_dhist.R:33 3: counts_from_observations(matrix(observations)) at /Users/martin/Source/Turing/network-comparison/R/dhist.R:177

Solution

Our NAMESPACE file needs to contain useDynLib(netdist) and importFrom(Rcpp, sourceCpp). However, we rely on Roxygen to build our NAMESPACE file so need to add the corresponding Roxygen tags somewhere in our comments (see Hadley Wickham's R Packages guide). By convention, these are placed in R/<packageName>.R, R/<packageName>-package.R or similar (source: https://cwcode.wordpress.com/2013/01/28/developing-r-packages-using-roxygen-and-devtools/).

martintoreilly commented 6 years ago

Should be fixed by commit 774d8e6. However, a different issue with C++11 support on Travis is causing the CI build to fail. Will close this issue once Travis CI build is passing.

martintoreilly commented 6 years ago

PR #99 successfully builds and runs tests, so closing issue.