profile
viewpoint
If you are wondering where the data of this site comes from, please visit https://api.github.com/users/mattfidler/events. GitMemory does not store any data, but only uses NGINX to cache data for a period of time. The idea behind GitMemory is simply to give users a better reading experience.
Matthew Fidler mattfidler Also a Novartis employee; Can reach me at my Novartis email: matt.fidler@novartis.com

mattfidler/auto-indent-mode.el 44

Automatically Indent Emacs Code

ggPMXdevelopment/ggPMX 22

ggPMX R package

mattfidler/el-autoyas.el 6

Automatically create YaSnippets in emacs-lisp-mode

mattfidler/csl-mode 2

Mode for editing CSL-files (acsl)

mattfidler/el-get 2

Manage the external elisp bits and pieces upon which you depend!

mattfidler/Emacs-Speaks-NONMEM 2

Emacs Speaks NONMEM

mattfidler/dparser-R 1

R port of dparser

Pull request review commentmetrumresearchgroup/bbi

WIP: params function

+// Copyright © 2016 Devin Pastoor <devin.pastoor@gmail.com>+//+// Licensed under the Apache License, Version 2.0 (the "License");+// you may not use this file except in compliance with the License.+// You may obtain a copy of the License at+//+//     http://www.apache.org/licenses/LICENSE-2.0+//+// Unless required by applicable law or agreed to in writing, software+// distributed under the License is distributed on an "AS IS" BASIS,+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+// See the License for the specific language governing permissions and+// limitations under the License.++package cmd++import (+	"encoding/json"+	"fmt"+	parser "github.com/metrumresearchgroup/babylon/parsers/nmparser"+	"github.com/metrumresearchgroup/babylon/utils"+	"github.com/scylladb/go-set/strset"+	log "github.com/sirupsen/logrus"+	"github.com/spf13/cobra"+	"github.com/spf13/viper"+	"io/ioutil"+	"path/filepath"+	"runtime"+	"strings"+)++const paramsLongDescription string = `summarize model(s), for example: +bbi nonmem params run001+bbi nonmem params run001+bbi nonmem params run001+ `++// runCmd represents the run command+var paramsCmd = &cobra.Command{+	Use:   "params",+	Short: "get the parameters of model(s)",+	Long: paramsLongDescription,+	Run: params,+}++var (+	noParamNames bool+	dir string+)++func printParamHeader(results parser.ExtFastData) {+	for i, s := range results.ParameterNames {+		results.ParameterNames[i] = strings.ReplaceAll(s, ",", "_")+	}+	fmt.Println("dir," + strings.Join(results.ParameterNames, ","))+}+++func params(cmd *cobra.Command, args []string) {+	if debug {+		viper.Debug()+	}+	var modelDirs []string+	if dir != "" {+		fi, err := ioutil.ReadDir(dir)
        exdir, _ := homedir.Expand(dir)
		fi, err := ioutil.ReadDir(exdir)
dpastoor

comment created time in 2 hours

created tagnanhung/pksensi

tagv1.2.1

An R package for applying global sensitivity analysis in physiologically based kinetic modeling

created time in 2 hours

push eventnanhung/pksensi

Nan-Hung Hsieh

commit sha c083d299f76ab55c8abd627b8a0e07cfd3673008

typo

view details

push time in 4 hours

push eventsymengine/symengine.R

GitHub Actions

commit sha a10916cdbdb0f6299da1347df3016a8f52bd7ef6

Built site for symengine: 0.1.5@0382ec6

view details

push time in 4 hours

pull request commentsymengine/symengine.R

Change sed to be more robust on certain systems

Thanks for the PR

mattfidler

comment created time in 5 hours

push eventsymengine/symengine.R

Matthew Fidler

commit sha 768c9d9f5bb8f6b68fd2f9de28521c37a4edf175

Change sed to be more robust on certain systems Hi, In rehat the package gives the following error: ```sh

view details

Marlin

commit sha 0382ec67b9345308d2f09cc72f487817db37a8cf

Merge pull request #108 from mattfidler/patch-1 Change sed to be more robust on certain systems

view details

push time in 5 hours

PR merged symengine/symengine.R

Change sed to be more robust on certain systems

Hi,

In rehat the package gives the following error:

== generating src/Makevars
sed: -e expression #1, char 80: unknown option to `s'

By changing the character from | to : it works on rehat too.

+3 -3

0 comment

1 changed file

mattfidler

pr closed time in 5 hours

push eventnanhung/pksensi

Nan-Hung Hsieh

commit sha 63009a2de0d769c1a9bbb85add7cc4ea24616f64

prepare to release

view details

Nan-Hung Hsieh

commit sha 84b4213fcb10692a1494c54e3ea2611c113c4217

Merge branch 'master' of github.com:nanhung/pksensi into master

view details

push time in 5 hours

push eventRdatatable/data.table

Philippe Chataignon

commit sha 7212de1ab22bbcea38812f0df95a30fbde2467a6

Much simpler formula

view details

push time in 7 hours

push eventRdatatable/data.table

Matt Dowle

commit sha 3fa8b20435d33b3d4b5c26fd9b0ac14c10b98800

.dev-only: revdep tweaks

view details

Jan Gorecki

commit sha 85adf09e3463838d547977ae9bc75e3b37f9cbaf

Internal class aware coerceAs. Already used in nafill and froll (#4491)

view details

Matt Dowle

commit sha fbbf8c43cadd32c8db4ae8035029c251f37c18d0

NEWS-only: publish date in 1.14.0 heading

view details

Hadley Wickham

commit sha 788c585586798107f9eeb3263928f718ca1db81e

Clarify status of reshape2 (#4908)

view details

Jan Gorecki

commit sha ec1259af1bf13fc0c96a1d3f9e84d55d8106a9a4

mean na.rm=TRUE uses GForce (#4851)

view details

Cole Miller

commit sha 27c3bd8490210891c539bb3397d0f939919c584d

by = .EACHI key fix 4603 (#4917)

view details

Bob Jansen

commit sha 53e15854bb2c4d2faa7184a3c782cce40e9210f2

Fix typo in ?setDTthreads (#4938)

view details

Jan Gorecki

commit sha 189be779dc90044d4c6c2965b674994cc80898fa

C data.table docs and minor rename (#4753)

view details

Mark Derry

commit sha 8f425c69279eef8b743bb049c7c983e0b6f3543e

Fread documentation (#4745)

view details

Matt Dowle

commit sha 707ef0ca89f71af8a1c34b70d714e9d8faf9eff5

moved #4745 news item up. Faster to merge PR and make this NEWS-only edit to master afterwards than merge master to the fork and wait for CI just for a news item.

view details

Matt Dowle

commit sha d589fb86fae727d467dd41e12f3d8dcf18cde6cb

added markdown as well as rmarkdown to Suggests (#4954)

view details

Michael Chirico

commit sha 4673f4862449075115369edae23e3c5580fe5b0b

add whitespace to distinguish non-equi operators in error msg (#4570)

view details

Jan Gorecki

commit sha 54082e40c3bf94feb41f1357d6f5b9917a5424c9

improve error message for #4214 (#4343)

view details

Michael Chirico

commit sha c2b55bf183c7f9485a0cc92b0e5e7e6fc0f1cbd0

better error message for missing j in cube (#4282)

view details

Michael Chirico

commit sha 19065fba64f9b48930d8e51573d01976cbfb25a6

dt_width needs to be passed true nrow (#4268)

view details

Michael Chirico

commit sha 306f49c3a8318c1f92e676fe20c9033260b69ca4

... -> \dots in fcase.Rd (#4452)

view details

Xianying Tan

commit sha 1eadb95ae1f2d5be5b1b6bf89d8db06450d4b9cc

fwrite() UTF-8 csv file (#4785)

view details

Tyson Barrett

commit sha 79916306dedffc8882cc51b124badcb427c581c5

add check for trunc.cols (#4766)

view details

Benjamin Schwendinger

commit sha 374e20813f652b9f1729d26da1bad902979b06d6

fread nrows=0L fixed to work like nrows=0 (#4694)

view details

Michael Chirico

commit sha b1d25cd85e59a5549d9f319e6f5c513771ee4d98

fix frank(.SD) for ties.method="random" / na.last=NA (#4434)

view details

push time in 10 hours

PR opened Rdatatable/data.table

Changes buffer size for writing header in fwrite

This PR is an attempt to Resolve #5048.

Actually, buffer size for writing header only uses headerLen. headerLen is computed accurately and deflateBound returns a buffer size witch guarantees an one pass compression. But that's not true with OpenBSD which uses on old zlib version.

Here, we use by default the buffer size used for rows from the buffer size parameter (buffMB) and, if we have a very long header, we use headerLen.

+7 -0

0 comment

1 changed file

pr created time in 10 hours

create barnchRdatatable/data.table

branch : fwrite_openbsd

created branch time in 10 hours

issue commentRdatatable/data.table

fwrite gzip on OpenBSD error

Error code -9 is internal to fwrite and is returned when deflate does not return Z_STREAM_END.

zlib doc says "In order to complete in one call, avail_out must be at least the value returned by deflateBound (see below). Then deflate is guaranteed to return Z_STREAM_END.". We use deflateBound, that's why we check Z_STREAM_END as deflate return value.

But OpenBSD has an old zlib library, part of the system (not a package) : version 1.2.3 from 2005 (actual is 1.2.11 since 2017). And in version 1.2.3, deflateBound is incorrect for gzip fromat (seems fixed in 1.2.3.1 "- Take into account wrapper variations in deflateBound()" ) and returns a too small value : 20 instead of 22 in the above reproducible example.

philippechataignon

comment created time in 11 hours

issue openedRdatatable/data.table

fwrite gzip on OpenBSD error

On OpenBSD 6.9, released May 1, 2021, writing gzipped csv fails :

> library(data.table)
> test.data.table()
getDTthreads(verbose=TRUE):
This installation of data.table has not been compiled with OpenMP support.
  omp_get_num_procs()            1
  R_DATATABLE_NUM_PROCS_PERCENT  unset (default 50)
  R_DATATABLE_NUM_THREADS        unset
  R_DATATABLE_THROTTLE           unset (default 1024)
  omp_get_thread_limit()         1
  omp_get_max_threads()          1
  OMP_THREAD_LIMIT               unset
  OMP_NUM_THREADS                unset
  RestoreAfterFork               true
  data.table is using 1 threads with throttle==1024. See ?setDTthreads.
test.data.table() running: /usr/local/lib/R/library/data.table/tests/tests.Rraw.bz2 

**** Suggested package bit64 is not installed. Tests using it will be skipped.
**** Suggested package xts is not installed. Tests using it will be skipped.
**** Suggested package nanotime is not installed. Tests using it will be skipped.
**** Suggested package R.utils is not installed. Tests using it will be skipped.
**** Suggested package yaml is not installed. Tests using it will be skipped.

Test 1658.53 produced 1 errors but expected 0
Expected: 
Observed: Compress gzip error: -9
Test 1760 not run because this session either has no OpenMP or has been limited to one thread (e.g. under UBSAN and ASAN)

Fri Jun 18 15:21:25 2021  endian==little, sizeof(long double)==16, longdouble.digits==64, sizeof(pointer)==8, TZ==unset, Sys.timezone()=='Europe/Paris', Sys.geTest 1658.53 produced 1 errors but expected 0
Expected: 
Observed: Compress gzip error: -9tlocale()=='C', l10n_info()=='MBCS=FALSE; UTF-8=FALSE; Latin-1=FALSE', getDTthreads()=='This installation of data.table has not been compiled with OpenMP support.; omp_get_num_procs()==1; R_DATATABLE_NUM_PROCS_PERCENT==unset (default 50); R_DATATABLE_NUM_THREADS==unset; R_DATATABLE_THROTTLE==unset (default 1024); omp_get_thread_limit()==1; omp_get_max_threads()==1; OMP_THREAD_LIMIT==unset; OMP_NUM_THREADS==unset; RestoreAfterFork==true; data.table is using 1 threads with throttle==1024. See ?setDTthreads.', zlibVersion()==1.2.3 ZLIB_VERSION==1.2.3
Error in test.data.table() : 
  1 error out of 9060. Search tests/tests.Rraw.bz2 for test number 1658.53.

Reproducible example:

> library(data.table)
> sessionInfo()
R version 4.0.5 (2021-03-31)
Platform: x86_64-unknown-openbsd6.9 (64-bit)
Running under: OpenBSD 6.9 GENERIC.MP#3 amd64

Matrix products: default
BLAS:   /usr/local/lib/R/lib/libRblas.so.37.0
LAPACK: /usr/local/lib/R/lib/libRlapack.so.37.0

locale:
[1] C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] data.table_1.14.0

loaded via a namespace (and not attached):
[1] compiler_4.0.5
> a = data.table(i=1:100)
> fwrite(a, "test.csv.gz")
Error in fwrite(a, "test.csv.gz") : Compress gzip error: -9
Execution halted

created time in 11 hours

push eventnanhung/pksensi

Nan-Hung Hsieh

commit sha bc7b21e6bd6bcce679b2493d07918ea352c93a31

fix rtools path

view details

push time in 11 hours

startedcykerway/complete-alias

started time in 20 hours

delete branch Rdatatable/data.table

delete branch : att_on_FALSE

delete time in a day

push eventRdatatable/data.table

Matt Dowle

commit sha 2e8691185f8a0f7d26212fa4674d1d64f27151ee

Don't call copyMostAttrib on ScalarLogical result (#5047)

view details

push time in a day

PR merged Rdatatable/data.table

Don't call copyMostAttrib on ScalarLogical result dev

Follow up to #4350

The first commit "reprex" in this PR reproduces the problem. I'm using R 4.0.3 currently. Running R CMD check or test.data.table() is necessary to make 2195.[3-8] fail because test 2190.6 needs to run first. When I ran tests 2195 at the dev prompt they always passed and I couldn't reproduce.

Test 2190.6 is subassigning a logical vector with an attribute attached to an existing list column :

DT = data.table(a=list(1:2, 3, 4))
DT[1:2, a:=structure(c(TRUE, FALSE), att='t')]

This ended up attaching the "att" attribute with value "t" to R's internal global FALSE constant. This caused the !identical(incomparables, FALSE) in duplicated.R to fail. I debugged and confirmed that print(FALSE) showed that FALSE had indeed received the attribute whereas incomparables did not have the attribute. Presumably TRUE was also receiving the attribute but only FALSE was showing up so far in tests 2195.* on the FALSE value.

The error shows up as :

Running test id 2195.3          Test 2195.3 produced 1 errors but expected 0
Expected: 
Observed: argument 'incomparables != FALSE' is not used (yet)

In #4595 I worked around the issue by changing duplicated.R to use !isFALSE(incomparables) instead of !identical(incomparables, FALSE) to ignore any attributes attached to FALSE.

This PR now fixes the root cause. ScalarLogical(false) returns R's internal global FALSE value; allocVector() has to be used to return a new allocation of a length-1 logical value and a new allocation is necessary if attributes are to be attached. After this PR, duplicated.R could use !identical(incomparables, FALSE) again, but having gone through this, I'm now thinking that ignoring attributes attached to FALSE is more robust anyway so will leave the !isFALSE() in place in duplicated.R.

+14 -9

0 comment

1 changed file

mattdowle

pr closed time in a day

Pull request review commentRdatatable/data.table

Don't call copyMostAttrib on ScalarLogical result

 const char *memrecycle(const SEXP target, const SEXP where, const int start, con         BODY(SEXP, &, SEXP, val, SET_VECTOR_ELT(target, off+i, cval))     } else {       switch (TYPEOF(source)) {-      // no protect of CAST needed because SET_VECTOR_ELT protects it, and it can't get released by copyMostAttrib or anything else inside BODY-      // copyMostAttrib is appended to CAST so as to be outside loop-      case RAWSXP:  BODY(Rbyte,    RAW,        SEXP, ScalarRaw(val);    copyMostAttrib(source,cval), SET_VECTOR_ELT(target,off+i,cval))-      case LGLSXP:  BODY(int,      INTEGER,    SEXP, ScalarLogical(val);copyMostAttrib(source,cval), SET_VECTOR_ELT(target,off+i,cval))-      case INTSXP:  BODY(int,      INTEGER,    SEXP, ScalarInteger(val);copyMostAttrib(source,cval), SET_VECTOR_ELT(target,off+i,cval))-      case REALSXP: BODY(double,   REAL,       SEXP, ScalarReal(val);   copyMostAttrib(source,cval), SET_VECTOR_ELT(target,off+i,cval))-      case CPLXSXP: BODY(Rcomplex, COMPLEX,    SEXP, ScalarComplex(val);copyMostAttrib(source,cval), SET_VECTOR_ELT(target,off+i,cval))-      case STRSXP:  BODY(SEXP,     STRING_PTR, SEXP, ScalarString(val); copyMostAttrib(source,cval), SET_VECTOR_ELT(target,off+i,cval))+      // allocVector instead of ScalarLogical to avoid copyMostAttrib on R's internal global TRUE/FALSE values; #4595. Then because+      //   ScalarInteger may now or in future R also return R internal global small integer constants, the same for that. Then+      //   because we do that here for logical and integer, use allocVeector too for the other types to follow the same pattern and possibly+      //   in future R will also have some global constants for those types too.+      // the UNPROTECT can be at the end of the CAST before the SET_VECTOR_ELT, because SET_VECTOR_ELT will protect it and there's no other code inbetween+      // the PROTECT is now needed because of the call to LOGICAL() which could feasibly gc inside it.+      // copyMostAttrib is inside CAST so as to be outside loop.  See the history in #4350 and its follow up+      case RAWSXP:  BODY(Rbyte,    RAW,        SEXP, PROTECT(allocVector(RAWSXP, 1));RAW(cval)[0]=val;copyMostAttrib(source,cval);UNPROTECT(1),             SET_VECTOR_ELT(target,off+i,cval))+      case LGLSXP:  BODY(int,      LOGICAL,    SEXP, PROTECT(allocVector(LGLSXP, 1));LOGICAL(cval)[0]=val;copyMostAttrib(source,cval);UNPROTECT(1),         SET_VECTOR_ELT(target,off+i,cval))+      case INTSXP:  BODY(int,      INTEGER,    SEXP, PROTECT(allocVector(INTSXP, 1));INTEGER(cval)[0]=val;copyMostAttrib(source,cval);UNPROTECT(1),         SET_VECTOR_ELT(target,off+i,cval))+      case REALSXP: BODY(double,   REAL,       SEXP, PROTECT(allocVector(REALSXP, 1));REAL(cval)[0]=val;copyMostAttrib(source,cval);UNPROTECT(1),           SET_VECTOR_ELT(target,off+i,cval))+      case CPLXSXP: BODY(Rcomplex, COMPLEX,    SEXP, PROTECT(allocVector(CPLXSXP, 1));COMPLEX(cval)[0]=val;copyMostAttrib(source,cval);UNPROTECT(1),        SET_VECTOR_ELT(target,off+i,cval))

yes Rcomplex is a struct and in C you can assign structs; e.g. grep NA_CPLX data.table/src/*.

mattdowle

comment created time in a day

Pull request review commentRdatatable/data.table

Don't call copyMostAttrib on ScalarLogical result

 const char *memrecycle(const SEXP target, const SEXP where, const int start, con         BODY(SEXP, &, SEXP, val, SET_VECTOR_ELT(target, off+i, cval))     } else {       switch (TYPEOF(source)) {-      // no protect of CAST needed because SET_VECTOR_ELT protects it, and it can't get released by copyMostAttrib or anything else inside BODY-      // copyMostAttrib is appended to CAST so as to be outside loop-      case RAWSXP:  BODY(Rbyte,    RAW,        SEXP, ScalarRaw(val);    copyMostAttrib(source,cval), SET_VECTOR_ELT(target,off+i,cval))-      case LGLSXP:  BODY(int,      INTEGER,    SEXP, ScalarLogical(val);copyMostAttrib(source,cval), SET_VECTOR_ELT(target,off+i,cval))-      case INTSXP:  BODY(int,      INTEGER,    SEXP, ScalarInteger(val);copyMostAttrib(source,cval), SET_VECTOR_ELT(target,off+i,cval))-      case REALSXP: BODY(double,   REAL,       SEXP, ScalarReal(val);   copyMostAttrib(source,cval), SET_VECTOR_ELT(target,off+i,cval))-      case CPLXSXP: BODY(Rcomplex, COMPLEX,    SEXP, ScalarComplex(val);copyMostAttrib(source,cval), SET_VECTOR_ELT(target,off+i,cval))-      case STRSXP:  BODY(SEXP,     STRING_PTR, SEXP, ScalarString(val); copyMostAttrib(source,cval), SET_VECTOR_ELT(target,off+i,cval))+      // allocVector instead of ScalarLogical to avoid copyMostAttrib on R's internal global TRUE/FALSE values; #4595. Then because+      //   ScalarInteger may now or in future R also return R internal global small integer constants, the same for that. Then+      //   because we do that here for logical and integer, use allocVeector too for the other types to follow the same pattern and possibly+      //   in future R will also have some global constants for those types too.

hmm on second thought I think I misunderstood. I was analogizing to base::T which isn't the same issue

mattdowle

comment created time in a day

Pull request review commentRdatatable/data.table

Don't call copyMostAttrib on ScalarLogical result

 const char *memrecycle(const SEXP target, const SEXP where, const int start, con         BODY(SEXP, &, SEXP, val, SET_VECTOR_ELT(target, off+i, cval))     } else {       switch (TYPEOF(source)) {-      // no protect of CAST needed because SET_VECTOR_ELT protects it, and it can't get released by copyMostAttrib or anything else inside BODY-      // copyMostAttrib is appended to CAST so as to be outside loop-      case RAWSXP:  BODY(Rbyte,    RAW,        SEXP, ScalarRaw(val);    copyMostAttrib(source,cval), SET_VECTOR_ELT(target,off+i,cval))-      case LGLSXP:  BODY(int,      INTEGER,    SEXP, ScalarLogical(val);copyMostAttrib(source,cval), SET_VECTOR_ELT(target,off+i,cval))-      case INTSXP:  BODY(int,      INTEGER,    SEXP, ScalarInteger(val);copyMostAttrib(source,cval), SET_VECTOR_ELT(target,off+i,cval))-      case REALSXP: BODY(double,   REAL,       SEXP, ScalarReal(val);   copyMostAttrib(source,cval), SET_VECTOR_ELT(target,off+i,cval))-      case CPLXSXP: BODY(Rcomplex, COMPLEX,    SEXP, ScalarComplex(val);copyMostAttrib(source,cval), SET_VECTOR_ELT(target,off+i,cval))-      case STRSXP:  BODY(SEXP,     STRING_PTR, SEXP, ScalarString(val); copyMostAttrib(source,cval), SET_VECTOR_ELT(target,off+i,cval))+      // allocVector instead of ScalarLogical to avoid copyMostAttrib on R's internal global TRUE/FALSE values; #4595. Then because+      //   ScalarInteger may now or in future R also return R internal global small integer constants, the same for that. Then+      //   because we do that here for logical and integer, use allocVeector too for the other types to follow the same pattern and possibly+      //   in future R will also have some global constants for those types too.

interesting, where did you see that?

mattdowle

comment created time in a day

pull request commentRdatatable/data.table

fix melt(na.rm=TRUE) with list columns

by the way I asked for *_ELT docs on R-devel, and I got this response from Luke Tierney

> One more question: are there any circumstances in which one should use
> REAL_ELT(x,i) rather than REAL(x)[i] or vice versa? Or can they be used
> interchangeably?

For a single call it is better to use REAL_ELT(x, i) since it doesn't
force allocating a possibly large object in order to get a pointer to
its data with REAL(x).  If you are iterating over a whole object you
may want to get data in chunks. There are iteration macros that
help. Some examples are in src/main/summary.c.
tdhock

comment created time in a day

Pull request review commentRdatatable/data.table

Don't call copyMostAttrib on ScalarLogical result

 const char *memrecycle(const SEXP target, const SEXP where, const int start, con         BODY(SEXP, &, SEXP, val, SET_VECTOR_ELT(target, off+i, cval))     } else {       switch (TYPEOF(source)) {-      // no protect of CAST needed because SET_VECTOR_ELT protects it, and it can't get released by copyMostAttrib or anything else inside BODY-      // copyMostAttrib is appended to CAST so as to be outside loop-      case RAWSXP:  BODY(Rbyte,    RAW,        SEXP, ScalarRaw(val);    copyMostAttrib(source,cval), SET_VECTOR_ELT(target,off+i,cval))-      case LGLSXP:  BODY(int,      INTEGER,    SEXP, ScalarLogical(val);copyMostAttrib(source,cval), SET_VECTOR_ELT(target,off+i,cval))-      case INTSXP:  BODY(int,      INTEGER,    SEXP, ScalarInteger(val);copyMostAttrib(source,cval), SET_VECTOR_ELT(target,off+i,cval))-      case REALSXP: BODY(double,   REAL,       SEXP, ScalarReal(val);   copyMostAttrib(source,cval), SET_VECTOR_ELT(target,off+i,cval))-      case CPLXSXP: BODY(Rcomplex, COMPLEX,    SEXP, ScalarComplex(val);copyMostAttrib(source,cval), SET_VECTOR_ELT(target,off+i,cval))-      case STRSXP:  BODY(SEXP,     STRING_PTR, SEXP, ScalarString(val); copyMostAttrib(source,cval), SET_VECTOR_ELT(target,off+i,cval))+      // allocVector instead of ScalarLogical to avoid copyMostAttrib on R's internal global TRUE/FALSE values; #4595. Then because+      //   ScalarInteger may now or in future R also return R internal global small integer constants, the same for that. Then+      //   because we do that here for logical and integer, use allocVeector too for the other types to follow the same pattern and possibly+      //   in future R will also have some global constants for those types too.+      // the UNPROTECT can be at the end of the CAST before the SET_VECTOR_ELT, because SET_VECTOR_ELT will protect it and there's no other code inbetween+      // the PROTECT is now needed because of the call to LOGICAL() which could feasibly gc inside it.+      // copyMostAttrib is inside CAST so as to be outside loop.  See the history in #4350 and its follow up+      case RAWSXP:  BODY(Rbyte,    RAW,        SEXP, PROTECT(allocVector(RAWSXP, 1));RAW(cval)[0]=val;copyMostAttrib(source,cval);UNPROTECT(1),             SET_VECTOR_ELT(target,off+i,cval))+      case LGLSXP:  BODY(int,      LOGICAL,    SEXP, PROTECT(allocVector(LGLSXP, 1));LOGICAL(cval)[0]=val;copyMostAttrib(source,cval);UNPROTECT(1),         SET_VECTOR_ELT(target,off+i,cval))+      case INTSXP:  BODY(int,      INTEGER,    SEXP, PROTECT(allocVector(INTSXP, 1));INTEGER(cval)[0]=val;copyMostAttrib(source,cval);UNPROTECT(1),         SET_VECTOR_ELT(target,off+i,cval))+      case REALSXP: BODY(double,   REAL,       SEXP, PROTECT(allocVector(REALSXP, 1));REAL(cval)[0]=val;copyMostAttrib(source,cval);UNPROTECT(1),           SET_VECTOR_ELT(target,off+i,cval))+      case CPLXSXP: BODY(Rcomplex, COMPLEX,    SEXP, PROTECT(allocVector(CPLXSXP, 1));COMPLEX(cval)[0]=val;copyMostAttrib(source,cval);UNPROTECT(1),        SET_VECTOR_ELT(target,off+i,cval))

I'm not sure, does assigning like this work as expected for complex? or do we have to assign the real/imaginary parts individually?

mattdowle

comment created time in a day

Pull request review commentRdatatable/data.table

Don't call copyMostAttrib on ScalarLogical result

 const char *memrecycle(const SEXP target, const SEXP where, const int start, con         BODY(SEXP, &, SEXP, val, SET_VECTOR_ELT(target, off+i, cval))     } else {       switch (TYPEOF(source)) {-      // no protect of CAST needed because SET_VECTOR_ELT protects it, and it can't get released by copyMostAttrib or anything else inside BODY-      // copyMostAttrib is appended to CAST so as to be outside loop-      case RAWSXP:  BODY(Rbyte,    RAW,        SEXP, ScalarRaw(val);    copyMostAttrib(source,cval), SET_VECTOR_ELT(target,off+i,cval))-      case LGLSXP:  BODY(int,      INTEGER,    SEXP, ScalarLogical(val);copyMostAttrib(source,cval), SET_VECTOR_ELT(target,off+i,cval))-      case INTSXP:  BODY(int,      INTEGER,    SEXP, ScalarInteger(val);copyMostAttrib(source,cval), SET_VECTOR_ELT(target,off+i,cval))-      case REALSXP: BODY(double,   REAL,       SEXP, ScalarReal(val);   copyMostAttrib(source,cval), SET_VECTOR_ELT(target,off+i,cval))-      case CPLXSXP: BODY(Rcomplex, COMPLEX,    SEXP, ScalarComplex(val);copyMostAttrib(source,cval), SET_VECTOR_ELT(target,off+i,cval))-      case STRSXP:  BODY(SEXP,     STRING_PTR, SEXP, ScalarString(val); copyMostAttrib(source,cval), SET_VECTOR_ELT(target,off+i,cval))+      // allocVector instead of ScalarLogical to avoid copyMostAttrib on R's internal global TRUE/FALSE values; #4595. Then because+      //   ScalarInteger may now or in future R also return R internal global small integer constants, the same for that. Then+      //   because we do that here for logical and integer, use allocVeector too for the other types to follow the same pattern and possibly+      //   in future R will also have some global constants for those types too.

btw I believe base::pi counts as just such a constant for REALSXP already

mattdowle

comment created time in a day

push eventRdatatable/data.table

Matt Dowle

commit sha c93503b5761ff80736182ad62a66d30f3e14f194

isFALSE again

view details

push time in a day

PR opened Rdatatable/data.table

Don't call copyMostAttrib on ScalarLogical result dev

Follow up to #4350

The first commit "reprex" in this PR reproduces the problem. I'm using R 4.0.3 currently. Running R CMD check or test.data.table() is necessary to make 2195.[3-8] fail because test 2190.6 needs to run first. In other words, when I ran tests 2195 at the dev prompt they always passed and I couldn't reproduce.

Test 2190.6 is subassigning a logical vector with an attribute attached to an existing list column :

DT = data.table(a=list(1:2, 3, 4))
DT[1:2, a:=structure(c(TRUE, FALSE), att='t')]

This ended up attaching the "att" attribute with value "t" to R's internal global FALSE constant. This caused the !identical(incomparables, FALSE) in duplicated.R to fail. I debugged and confirmed that print(FALSE) showed that FALSE had indeed received the attribute whereas incomparables did not have the attribute. Presumably TRUE was also receiving the attribute but only FALSE was showing up so far in tests 2195.* on the FALSE value.

The error shows up as :

Running test id 2195.3          Test 2195.3 produced 1 errors but expected 0
Expected: 
Observed: argument 'incomparables != FALSE' is not used (yet)

In #4595 I worked around the issue by changing duplicated.R to use !isFALSE(incomparables) instead of !identical(incomparables, FALSE) to ignore any attributes attached to FALSE.

This PR now fixes the root cause. After this PR, duplicated.R could use !identical(incomparables, FALSE) again, but having gone through this, I'm now thinking that ignoring attributes on FALSE is more robust anyway so will leave the !isFALSE in place in duplicated.R.

+16 -11

0 comment

2 changed files

pr created time in a day

push eventnanhung/pksensi

Nan-Hung Hsieh

commit sha 9ab328568e561f13ab6ab30ee4cbf3f1df4d3235

README - address parameter correlation issue

view details

push time in a day

create barnchRdatatable/data.table

branch : att_on_FALSE

created branch time in a day