Re: [Rd] [External] The finalizer of the externalPtr does not work when closing R?

2020-04-03 Thread Wang Jiefei
y your process when > it exits, cleanly or otherwise. > > Best, > > luke > > On Fri, 3 Apr 2020, Wang Jiefei wrote: > > > Hi all, > > > > I found that the finalizer of the externalPtr is not called when R is > > quitting. However, manually calling GC()

[Rd] The finalizer of the externalPtr does not work when closing R?

2020-04-03 Thread Wang Jiefei
Hi all, I found that the finalizer of the externalPtr is not called when R is quitting. However, manually calling GC() works fine. This behavior is observed on devel R 2020-04-02 r78142 on Win and R 3.6.3 on Ubuntu. I make a reproducible package here: https://github.com/Jiefei-Wang/example Here

[Rd] Inconsistant result for normalizePath on Windows

2020-03-23 Thread Wang Jiefei
Hi all, I saw a quite surprising result in the devel R when using the function *normalizePath*. If the input is a path to a folder, the function returns an absolute path with/without a slash at the end depending on the existence of the folder. I know both results are valid on Windows but this beha

Re: [Rd] R CMD INSTALL cannot recognize full path on Windows

2020-03-11 Thread Wang Jiefei
ing if installed package can be loaded from temporary location > *** arch - i386 > *** arch - x64 > ** testing if installed package can be loaded from final location > *** arch - i386 > *** arch - x64 > ** testing if installed package keeps a record of temporary installation > pat

Re: [Rd] R CMD INSTALL cannot recognize full path on Windows

2020-03-11 Thread Wang Jiefei
tates.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 That is where I am stuck, any help would be appreciated. Best, Jiefei On Wed, Mar 11, 2020 at 9:56 AM Tomas Kalibera wrote: > On 3/11/20 2:26 PM, Wang Jiefei wrote: > > Thanks,

Re: [Rd] R CMD INSTALL cannot recognize full path on Windows

2020-03-11 Thread Wang Jiefei
hat you try to narrow down your example so that it is > really minimal. Use R_HOME, not hard-coded paths, as that is what you would > use in reality anyway. Print R_HOME and check it is valid. If the problem > persists, find out why it works when invoked from the command line but not >

Re: [Rd] R CMD INSTALL cannot recognize full path on Windows

2020-03-10 Thread Wang Jiefei
Oops, I think both of us forget to cite the r-devel channel. Best, Jiefei On Tue, Mar 10, 2020 at 5:13 AM Wang Jiefei wrote: > Thanks for your quick response, Tomas. > > Yes, this is a path issue, I think the problem is related to R, not the > Rtools make. I built an example

[Rd] R CMD INSTALL cannot recognize full path on Windows

2020-03-10 Thread Wang Jiefei
Hi all, Here is a bug(or feature?) that exists at least from R 2020-02-24 r77852 to 2020-03-09 r77919 on Window. Consider this example makefile in a package ``` *test1=$(shell echo 'runif(3)'|R --vanilla --slave)test2=$(shell echo 'runif(3)'|"C:/Program Files/R/R-devel/bin/R" --vanilla --sla

Re: [Rd] What should dnorm(0, 0, -Inf) return?

2019-12-07 Thread Wang Jiefei
Good question, I cannot speak for R's developers but I would like to provide some information on the problem. Here are the first few lines of the dnorm function located at src\nmath\dnorm.c: ``` double dnorm4(double x, double mu, double sigma, int give_log) { #ifdef IEEE_754 if (ISNAN(x) || IS

Re: [Rd] Questions on the R C API

2019-11-04 Thread Wang Jiefei
Hi Morgan, My solutions might not be the best one(I believe it's not), but it should work for your question. 1. Have you considered Rf_duplicate function? If you want to change the value of `a` and reset it later, you have to have a duplication somewhere for resetting it. Instead of changing the

Re: [Rd] Unexpected behavior when using macro to loop over vector

2019-10-25 Thread Wang Jiefei
the macro. Best, Jiefei On Fri, Oct 25, 2019 at 11:13 AM Tomas Kalibera wrote: > On 10/25/19 11:01 AM, Tomas Kalibera wrote: > > On 10/23/19 6:45 AM, Wang Jiefei wrote: > >> Hi all, > >> > >> I found an unexpected behavior when I was trying to use the macro >

[Rd] Unexpected behavior when using macro to loop over vector

2019-10-22 Thread Wang Jiefei
Hi all, I found an unexpected behavior when I was trying to use the macro defined in "R_ext/Itermacros.h" to loop over an atomic vector. Here is a minimum example: C++ code ``` #include "R_ext/Itermacros.h" #define GET_REGION_BUFSIZE 2 //Redefine the macro since C++ is not happy with the implici

Re: [Rd] S4SXP type vs S4 object bit?

2019-10-22 Thread Wang Jiefei
Hi Travers, Just an additional remarks to Michael's answer, if your S4 class inherits from R's basic types, say integer, the resulting object will be an INTSXP. If your S4 class does not inherit from any class, it will be an S4SXP. You can think about this question from the object-oriented framewo

Re: [Rd] New matrix function

2019-10-11 Thread Wang Jiefei
Hi Morgan, I think there is a discussion on how developers include a function in base R in another thread: https://stat.ethz.ch/pipermail/r-devel/2019-October/078551.html Best, Jiefei On Fri, Oct 11, 2019 at 8:19 AM Morgan Morgan wrote: > On Fri, 11 Oct 2019 10:45 Duncan Murdoch, > wrote: >

Re: [Rd] What is the best way to loop over an ALTREP vector?

2019-09-23 Thread Wang Jiefei
lse ITERATE_BY_REGION_PARTIAL0(sx, px, idx, nb, etype, vtype, \ strt, nfull, expr);\ } while (0) Best, Jiefei On Mon, Sep 23, 2019 at 3:12 PM Wang Jiefei wrote: > Hi Gabriel, > > I have tried the macro and found a small issue, it seems li

Re: [Rd] What is the best way to loop over an ALTREP vector?

2019-09-23 Thread Wang Jiefei
type_free_iter(x, ptr, ind, nbatch, { for (int i = 0; i < nbatch; i++) { s = s + ptr[i]; } }); return s; } Best, Jiefei On Wed, Aug 28, 2019 at 2:32 PM Wang Jiefei wrote: > Thank you, Gabriel. The loop macr

Re: [Rd] [ALTREP] What is the meaning of the return value of Is_sorted and No_NA function?

2019-09-11 Thread Wang Jiefei
I point in the > future which asks the object *how many NAs it has.∫ˆ* If that > materializes, No_NA would just consume the answer to thatto get the > binarized version, but again there is nothing like that in there now. > > Hope that helps. > > Best, > ~G > > On Wed,

[Rd] [ALTREP] What is the meaning of the return value of Is_sorted and No_NA function?

2019-09-11 Thread Wang Jiefei
Hi, I would like to figure out the meaning of the return value of these two functions. Here are the default definitions I find from R source code: static int altreal_Is_sorted_default(SEXP x) { return UNKNOWN_SORTEDNESS; } static int altreal_No_NA_default(SEXP x) { return 0; } I guess the m

Re: [Rd] [ALTREP] What is the meaning of the return value of Is_sorted and No_NA function?

2019-09-04 Thread Wang Jiefei
used, so there is no way to return true without loop over the argument x right now. I hope this could be changed in the future. Best, Jiefei On Tue, Sep 3, 2019 at 2:49 PM Wang Jiefei wrote: > Hi, > > > > I would like to figure out the meaning of the return value of these two &g

[Rd] What is the best way to loop over an ALTREP vector?

2019-08-27 Thread Wang Jiefei
Hi devel team, I'm working on C/C++ level ALTREP compatibility for a package. The package previously used pointers to access the data of a SEXP, so it would not work for some ALTREP objects which do not have a pointer. I plan to rewrite the code and use functions like get_elt, get_region, and get_

[Rd] ALTREP package interaction with testthat

2019-08-12 Thread Wang Jiefei
Hi I found a weird problem in testthat while working with an ALTREP package. The package name is AltWrapper. My ALTREP serialize function is called even when I'm trying to serialize a non-ALTREP object. Here is an example ``` context("altrep") length_func<-function(x){ return(length(x

Re: [Rd] [External] Questions regarding ALTREP_SET_ELT APIs

2019-07-30 Thread Wang Jiefei
Hi Luke, Thanks for your quick response. I appreciate your help. Best, Jiefei On Tue, Jul 30, 2019 at 12:41 PM Tierney, Luke wrote: > On Tue, 30 Jul 2019, Wang Jiefei wrote: > > > Hi all, > > > > I'm wondering if there is any way to define a `SET_ELT` function f

[Rd] Questions regarding ALTREP_SET_ELT APIs

2019-07-30 Thread Wang Jiefei
Hi all, I'm wondering if there is any way to define a `SET_ELT` function for an ALTREP class? I see there are ` ALTINTEGER_SET_ELT` etc. functions exported in Rinternal.h, but there is no corresponding ALTREP APIs to define them. The only way to set the value of an ALTREP is through a pointer, whi