Skip to content

Commit

Permalink
since rpy2 3.5.12 invisible r objects are no longer returned
Browse files Browse the repository at this point in the history
  • Loading branch information
MalteKurz committed Dec 22, 2023
1 parent b7e3a49 commit f73f2f1
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions vineknockoffs/_utils_kde1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,39 @@


r_kde1d_fit = robjects.r('''
kde_fit <- function(x) {
function(x) {
return(kde1d::kde1d(x))
}
''')

r_kde1d_discrete_fit = robjects.r('''
kde_fit <- function(x, levels) {
function(x, levels) {
x <- ordered(x, levels=levels)
return(kde1d::kde1d(x))
}
''')

r_kde1d_cdf_eval = robjects.r('''
cdf_eval <- function(kde_fit, x) {
function(kde_fit, x) {
return(kde1d::pkde1d(x, kde_fit))
}
''')

r_kde1d_invcdf_eval = robjects.r('''
invcdf_eval <- function(kde_fit, x) {
function(kde_fit, x) {
return(kde1d::qkde1d(x, kde_fit))
}
''')

r_kde1d_discrete_invcdf_eval = robjects.r('''
invcdf_eval <- function(kde_fit, x) {
function(kde_fit, x) {
res <- kde1d::qkde1d(x, kde_fit)
return(as.numeric(levels(res)[res]))
}
''')

r_kde1d_pdf_eval = robjects.r('''
pdf_eval <- function(kde_fit, x) {
function(kde_fit, x) {
return(kde1d::dkde1d(x, kde_fit))
}
''')
Expand Down
2 changes: 1 addition & 1 deletion vineknockoffs/_utils_knockoffs.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


cv_glmnet_r = robjects.r('''
cv_glmnet <- function(x, y, s) {
function(x, y, s) {
fit <- glmnet::cv.glmnet(x, y)
return(as.numeric(coef(fit, s=s)))
}
Expand Down
4 changes: 2 additions & 2 deletions vineknockoffs/_utils_vine_copulas.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
if _has_rpy2:
_has_r_tsp = robjects.r('library("TSP", quietly=TRUE, logical.return=TRUE)')[0]
r_solve_tsp = robjects.r('''
solve_tsp <- function(one_m_tau_mat) {
function(one_m_tau_mat) {
hamilton = TSP::insert_dummy(TSP::TSP(one_m_tau_mat), label = "cut")
sol = TSP::solve_TSP(hamilton, method = "repetitive_nn")
order = TSP::cut_tour(sol, "cut")
Expand Down Expand Up @@ -53,7 +53,7 @@ def d_vine_structure_select(u, tsp_method='r_tsp'):
if not (_has_rpy2 and _has_r_tsp):
raise ImportError('To determine the D-vine structure with method r_tsp the python package rpy2 and the R '
'package TSP are required.')
permutation = r_solve_tsp(tau_mat)-1
permutation = np.array(r_solve_tsp(tau_mat))-1
else:
assert tsp_method == 'py_tsp'
permutation, _ = solve_tsp_dynamic_programming(tau_mat)
Expand Down
2 changes: 1 addition & 1 deletion vineknockoffs/tests/_utils_py_vs_r_vinecopula.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def py_copula_funs_eval(data, cop_obj, fun_type):

r_copula_funs_eval = robjects.r('''
library(VineCopula)
copula_funs_eval <- function(u, v, family, par, type) {
function(u, v, family, par, type) {
if (type == 'cdf'){
res = BiCopCDF(u, v, family, par)
Expand Down

0 comments on commit f73f2f1

Please sign in to comment.