RcppArmadillo sample.h 包检查错误
RcppArmadillo sample.h error in package check
我使用 RcppArmadillo 编写了一个 R 包。在我的源文件中,我有
#include <RcppArmadilloExtensions/sample.h>
第一行,为了使用函数示例。
该包在我的 Windows 机器上编译和检查,并提交给 CRAN。但它没有检查风格:r-patched-solaris-sparc、r-patched-solaris-x86 安装错误。
日志文件显示
In file included from sim12.cpp:1:0:
/home/R/Lib32/RcppArmadillo/include/RcppArmadilloExtensions/sample.h: In function ‘void Rcpp::RcppArmadillo::ProbSampleReplace(arma::uvec&, int, int, arma::vec&)’:
/home/R/Lib32/RcppArmadillo/include/RcppArmadilloExtensions/sample.h:149:55: warning: ‘const arma::mtOp arma::sort_index(const arma::Base&, arma::uword) [with T1 = arma::Mat; typename T1::elem_type = double; arma::uword = unsigned int]’ is deprecated [-Wdeprecated-declarations]
arma::uvec perm = arma::sort_index(prob, 1); //descending sort of index
^
In file included from /home/R/Lib32/RcppArmadillo/include/armadillo:449:0,
from /home/R/Lib32/RcppArmadillo/include/RcppArmadilloForward.h:46,
from /home/R/Lib32/RcppArmadillo/include/RcppArmadillo.h:31,
from /home/R/Lib32/RcppArmadillo/include/RcppArmadilloExtensions/fixprob.h:25,
from /home/R/Lib32/RcppArmadillo/include/RcppArmadilloExtensions/sample.h:30,
from sim12.cpp:1:
/home/R/Lib32/RcppArmadillo/include/armadillo_bits/fn_sort_index.hpp:37:1: note: declared here
sort_index
^
和类似的警告。
为了找出如何解决这个问题,我用谷歌搜索了部分错误消息并找到了这个页面(c-style 和 arma api 更改编译警告 #203):
https://github.com/SMAC-Group/gmwm/issues/203
我认为安装错误不是由于我的代码中第一行之后的任何特定行造成的
#include <RcppArmadilloExtensions/sample.h>
但我不确定如何解决这个问题。如果有任何建议,我将不胜感激。
好吧,当您自己的 GitHub 问题之一出现在 SO 上时,这总是很有趣...
首先,这并不是一个错误,只是一个警告,需要尽快处理并且需要在上游完成。
基本上,RcppArmadilloExtensions/sample.h
API has to be updated because Armadillo's sort( X , sort_direction )
and sort_index( X , sort_direction)
函数已经不再用整数指定 sort_direction
参数(例如 0
= ascend,1
= descend),取而代之的是字符串接口(例如 "ascend"
、"descend"
)。
# Old
arma::sort_index(prob, 1);
# New
arma::sort_index(prob, "descend");
话虽如此,我会提出 PR 请求并进行必要的更改 Dirk 会 make an issue and then submit a PR that fixes it。如果您想要最新的测试,请获取最新的开发版本。可能,这将在大约一个月内滚动到 CRAN。
我使用 RcppArmadillo 编写了一个 R 包。在我的源文件中,我有
#include <RcppArmadilloExtensions/sample.h>
第一行,为了使用函数示例。 该包在我的 Windows 机器上编译和检查,并提交给 CRAN。但它没有检查风格:r-patched-solaris-sparc、r-patched-solaris-x86 安装错误。
日志文件显示
In file included from sim12.cpp:1:0: /home/R/Lib32/RcppArmadillo/include/RcppArmadilloExtensions/sample.h: In function ‘void Rcpp::RcppArmadillo::ProbSampleReplace(arma::uvec&, int, int, arma::vec&)’: /home/R/Lib32/RcppArmadillo/include/RcppArmadilloExtensions/sample.h:149:55: warning: ‘const arma::mtOp arma::sort_index(const arma::Base&, arma::uword) [with T1 = arma::Mat; typename T1::elem_type = double; arma::uword = unsigned int]’ is deprecated [-Wdeprecated-declarations] arma::uvec perm = arma::sort_index(prob, 1); //descending sort of index ^ In file included from /home/R/Lib32/RcppArmadillo/include/armadillo:449:0, from /home/R/Lib32/RcppArmadillo/include/RcppArmadilloForward.h:46, from /home/R/Lib32/RcppArmadillo/include/RcppArmadillo.h:31, from /home/R/Lib32/RcppArmadillo/include/RcppArmadilloExtensions/fixprob.h:25, from /home/R/Lib32/RcppArmadillo/include/RcppArmadilloExtensions/sample.h:30, from sim12.cpp:1: /home/R/Lib32/RcppArmadillo/include/armadillo_bits/fn_sort_index.hpp:37:1: note: declared here sort_index ^
和类似的警告。
为了找出如何解决这个问题,我用谷歌搜索了部分错误消息并找到了这个页面(c-style 和 arma api 更改编译警告 #203):
https://github.com/SMAC-Group/gmwm/issues/203
我认为安装错误不是由于我的代码中第一行之后的任何特定行造成的
#include <RcppArmadilloExtensions/sample.h>
但我不确定如何解决这个问题。如果有任何建议,我将不胜感激。
好吧,当您自己的 GitHub 问题之一出现在 SO 上时,这总是很有趣...
首先,这并不是一个错误,只是一个警告,需要尽快处理并且需要在上游完成。
基本上,RcppArmadilloExtensions/sample.h
API has to be updated because Armadillo's sort( X , sort_direction )
and sort_index( X , sort_direction)
函数已经不再用整数指定 sort_direction
参数(例如 0
= ascend,1
= descend),取而代之的是字符串接口(例如 "ascend"
、"descend"
)。
# Old
arma::sort_index(prob, 1);
# New
arma::sort_index(prob, "descend");
话虽如此,我会提出 PR 请求并进行必要的更改 Dirk 会 make an issue and then submit a PR that fixes it。如果您想要最新的测试,请获取最新的开发版本。可能,这将在大约一个月内滚动到 CRAN。