Re: [Rd] timezone tests and R-devel

2020-10-02 Thread Martin Maechler
> Kasper Daniel Hansen 
> on Thu, 1 Oct 2020 20:31:12 +0200 writes:

> The return value of Sys.time() today with a timezone of US/Eastern is
> unchanged between 4.0.3-patched and devel, but on devel the following test
> fails
> all.equal(x, as.POSIXlt(x))
> with
> x = Sys.time()

> This means that devel does not complete make tests (failure on
> tests/reg-tests-2.R)

> It is entirely possible that it is an error on my end, I use
> export TZ="US/Eastern"
> but I have been using this for a while, and R-4.0.3-patched built today
> passes make tests.

> Details below, and I am happy to provide more information.

> Build platform: inside a conda environment on linux. I have been doing 
this
> for a while, but it is certainly a non-standard setup. GCC 7.3

> Best,
> Kasper

> On R version 4.0.3 beta (2020-10-01 r79286) I get

>> x = Sys.time()
>> attributes(x)
> $class
> [1] "POSIXct" "POSIXt"

>> attributes(as.POSIXlt(x))
> $names
> [1] "sec""min""hour"   "mday"   "mon""year"   "wday"   "yday"
> [9] "isdst"  "zone"   "gmtoff"

> $class
> [1] "POSIXlt" "POSIXt"

> $tzone
> [1] "US/Eastern" "EST""EDT"

>> all.equal(x, as.POSIXlt(x))
> [1] TRUE

> On R Under development (unstable) (2020-10-01 r79286) I get
>> x = Sys.time()
>> all.equal(x,x)
> [1] TRUE
>> attributes(as.POSIXlt(x))
> $names
> [1] "sec""min""hour"   "mday"   "mon""year"   "wday"   "yday"
> [9] "isdst"  "zone"   "gmtoff"

> $class
> [1] "POSIXlt" "POSIXt"

> $tzone
> [1] "US/Eastern" "EST""EDT"

>> all.equal(x, as.POSIXlt(x))
> [1] "'tzone' attributes are inconsistent ('' and 'US/Eastern')"

Yes, this is a new feature, actually a __bug fix__ in R-devel,
see NEWS :

• all.equal.POSIXt() no longer warns about and subsequently ignores
  inconsistent "tzone" attributes, but describes the difference in
  its return value (PR#17277).  This check can be disabled _via_
  the new argument check.tzone = FALSE; as suggested by Sebastian
  Meyer.

Here's pure R code for reproducing what you've seen :

x <- structure(1601623657, class = c("POSIXct", "POSIXt"))

Sys.unsetenv("TZ")
all.equal(x, ltx <- as.POSIXlt(x))  # TRUE
attr(ltx, "tzone")  # [1]  "" "CET"  "CEST"

Sys.setenv(TZ = "US/Eastern")
all.equal(x, ltx <- as.POSIXlt(x))
## "'tzone' attributes are inconsistent ('' and 'US/Eastern')"
all.equal(x, ltx, check.tzone = FALSE) # TRUE

Sys.unsetenv("TZ")
all.equal(x, ltx <- as.POSIXlt(x)) # TRUE

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] timezone tests and R-devel

2020-10-02 Thread Sebastian Meyer
Thank you for the report. In R-devel, all.equal.POSIXt() by default
reports inconsistent time zones. Previously,

> x <- Sys.time()
> all.equal(x, as.POSIXlt(x, tz = "EST5EDT"))

would return TRUE. To ignore the time zone attributes in R-devel, the
argument 'check.tzone = FALSE' needs to be used.

That said, I can reproduce the 'make check' failure in R-devel on Ubuntu
Linux when TZ is set, even if it is set to the system time zone:

$ export TZ=Europe/Berlin
$ make check
[...]
> running code in '../../tests/reg-tests-2.R' ... OK
>   comparing 'reg-tests-2.Rout' to '../../tests/reg-tests-2.Rout.save' 
> ...7335c7335
> < [1] "'tzone' attributes are inconsistent ('' and 'Europe/Berlin')"
> ---
>> [1] TRUE


Compare the following two sessions:

> R-devel --vanilla --no-echo -e 'Sys.timezone(); x <- Sys.time(); all.equal(x, 
> as.POSIXlt(x))'
[1] "Europe/Berlin"
[1] TRUE

> TZ='Europe/Berlin' R-devel --vanilla --no-echo -e 'Sys.timezone(); x <- 
> Sys.time(); all.equal(x, as.POSIXlt(x))'
[1] "Europe/Berlin"
[1] "'tzone' attributes are inconsistent ('' and 'Europe/Berlin')"


So as.POSIXlt() sets a 'tzone' attribute if TZ is set, but this
behaviour is not new. Even with old R 3.6.3, I see

> R-3.6.3 --vanilla --slave -e 'attr(as.POSIXlt(Sys.time()), "tzone")'
[1] "" "CET"  "CEST"

> TZ='Europe/Berlin' R-3.6.3 --vanilla --slave -e 'attr(as.POSIXlt(Sys.time()), 
> "tzone")'
[1] "Europe/Berlin" "CET"   "CEST"

This might be system-specific.

I suggest to modify the test as attached for make check to pass in this
setting.

Best regards,

Sebastian


Am 01.10.20 um 20:31 schrieb Kasper Daniel Hansen:
> The return value of Sys.time() today with a timezone of US/Eastern is
> unchanged between 4.0.3-patched and devel, but on devel the following test
> fails
>   all.equal(x, as.POSIXlt(x))
> with
>   x = Sys.time()
> 
> This means that devel does not complete make tests (failure on
> tests/reg-tests-2.R)
> 
> It is entirely possible that it is an error on my end, I use
>   export TZ="US/Eastern"
> but I have been using this for a while, and R-4.0.3-patched built today
> passes make tests.
> 
> Details below, and I am happy to provide more information.
> 
> Build platform: inside a conda environment on linux. I have been doing this
> for a while, but it is certainly a non-standard setup. GCC 7.3
> 
> Best,
> Kasper
> 
> On R version 4.0.3 beta (2020-10-01 r79286) I get
> 
>> x = Sys.time()
>> attributes(x)
> $class
> [1] "POSIXct" "POSIXt"
> 
>> attributes(as.POSIXlt(x))
> $names
>  [1] "sec""min""hour"   "mday"   "mon""year"   "wday"   "yday"
>  [9] "isdst"  "zone"   "gmtoff"
> 
> $class
> [1] "POSIXlt" "POSIXt"
> 
> $tzone
> [1] "US/Eastern" "EST""EDT"
> 
>> all.equal(x, as.POSIXlt(x))
> [1] TRUE
> 
> On R Under development (unstable) (2020-10-01 r79286) I get
>> x = Sys.time()
>> all.equal(x,x)
> [1] TRUE
>> attributes(as.POSIXlt(x))
> $names
>  [1] "sec""min""hour"   "mday"   "mon""year"   "wday"   "yday"
>  [9] "isdst"  "zone"   "gmtoff"
> 
> $class
> [1] "POSIXlt" "POSIXt"
> 
> $tzone
> [1] "US/Eastern" "EST""EDT"
> 
>> all.equal(x, as.POSIXlt(x))
> [1] "'tzone' attributes are inconsistent ('' and 'US/Eastern')"
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
> 
Index: tests/reg-tests-2.R
===
--- tests/reg-tests-2.R	(revision 79287)
+++ tests/reg-tests-2.R	(working copy)
@@ -2838,7 +2838,7 @@
 ## all.equal datetime method
 x <- Sys.time()
 all.equal(x,x)
-all.equal(x, as.POSIXlt(x))
+all.equal(x, as.POSIXlt(x), check.tzone = FALSE)
 all.equal(x, as.numeric(x))  # errored in R <= 4.0.2
 all.equal(x, as.POSIXlt(x, tz = "EST5EDT"))
 all.equal(x, x+1e-4)
Index: tests/reg-tests-2.Rout.save
===
--- tests/reg-tests-2.Rout.save	(revision 79287)
+++ tests/reg-tests-2.Rout.save	(working copy)
@@ -7368,7 +7368,7 @@
 > x <- Sys.time()
 > all.equal(x,x)
 [1] TRUE
-> all.equal(x, as.POSIXlt(x))
+> all.equal(x, as.POSIXlt(x), check.tzone = FALSE)
 [1] TRUE
 > all.equal(x, as.numeric(x))  # errored in R <= 4.0.2
 [1] "'current' is not a POSIXt"
__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] timezone tests and R-devel

2020-10-02 Thread Kasper Daniel Hansen
Yes, the potential issue I see is that
  make check
fails when I explicitly set TZ. However, I set it to be the same as what
the system reports when I login.

Details: The system (RHEL) I am working on has
$ strings /etc/localtime | tail -n 1
EST5EDT,M3.2.0,M11.1.0
$ date +%Z
EDT
$ echo $TZ
US/Eastern



On Fri, Oct 2, 2020 at 9:48 AM Sebastian Meyer  wrote:

> Thank you for the report. In R-devel, all.equal.POSIXt() by default
> reports inconsistent time zones. Previously,
>
> > x <- Sys.time()
> > all.equal(x, as.POSIXlt(x, tz = "EST5EDT"))
>
> would return TRUE. To ignore the time zone attributes in R-devel, the
> argument 'check.tzone = FALSE' needs to be used.
>
> That said, I can reproduce the 'make check' failure in R-devel on Ubuntu
> Linux when TZ is set, even if it is set to the system time zone:
>
> $ export TZ=Europe/Berlin
> $ make check
> [...]
> > running code in '../../tests/reg-tests-2.R' ... OK
> >   comparing 'reg-tests-2.Rout' to '../../tests/reg-tests-2.Rout.save'
> ...7335c7335
> > < [1] "'tzone' attributes are inconsistent ('' and 'Europe/Berlin')"
> > ---
> >> [1] TRUE
>
>
> Compare the following two sessions:
>
> > R-devel --vanilla --no-echo -e 'Sys.timezone(); x <- Sys.time();
> all.equal(x, as.POSIXlt(x))'
> [1] "Europe/Berlin"
> [1] TRUE
>
> > TZ='Europe/Berlin' R-devel --vanilla --no-echo -e 'Sys.timezone(); x <-
> Sys.time(); all.equal(x, as.POSIXlt(x))'
> [1] "Europe/Berlin"
> [1] "'tzone' attributes are inconsistent ('' and 'Europe/Berlin')"
>
>
> So as.POSIXlt() sets a 'tzone' attribute if TZ is set, but this
> behaviour is not new. Even with old R 3.6.3, I see
>
> > R-3.6.3 --vanilla --slave -e 'attr(as.POSIXlt(Sys.time()), "tzone")'
> [1] "" "CET"  "CEST"
>
> > TZ='Europe/Berlin' R-3.6.3 --vanilla --slave -e
> 'attr(as.POSIXlt(Sys.time()), "tzone")'
> [1] "Europe/Berlin" "CET"   "CEST"
>
> This might be system-specific.
>
> I suggest to modify the test as attached for make check to pass in this
> setting.
>
> Best regards,
>
> Sebastian
>
>
> Am 01.10.20 um 20:31 schrieb Kasper Daniel Hansen:
> > The return value of Sys.time() today with a timezone of US/Eastern is
> > unchanged between 4.0.3-patched and devel, but on devel the following
> test
> > fails
> >   all.equal(x, as.POSIXlt(x))
> > with
> >   x = Sys.time()
> >
> > This means that devel does not complete make tests (failure on
> > tests/reg-tests-2.R)
> >
> > It is entirely possible that it is an error on my end, I use
> >   export TZ="US/Eastern"
> > but I have been using this for a while, and R-4.0.3-patched built today
> > passes make tests.
> >
> > Details below, and I am happy to provide more information.
> >
> > Build platform: inside a conda environment on linux. I have been doing
> this
> > for a while, but it is certainly a non-standard setup. GCC 7.3
> >
> > Best,
> > Kasper
> >
> > On R version 4.0.3 beta (2020-10-01 r79286) I get
> >
> >> x = Sys.time()
> >> attributes(x)
> > $class
> > [1] "POSIXct" "POSIXt"
> >
> >> attributes(as.POSIXlt(x))
> > $names
> >  [1] "sec""min""hour"   "mday"   "mon""year"   "wday"
>  "yday"
> >  [9] "isdst"  "zone"   "gmtoff"
> >
> > $class
> > [1] "POSIXlt" "POSIXt"
> >
> > $tzone
> > [1] "US/Eastern" "EST""EDT"
> >
> >> all.equal(x, as.POSIXlt(x))
> > [1] TRUE
> >
> > On R Under development (unstable) (2020-10-01 r79286) I get
> >> x = Sys.time()
> >> all.equal(x,x)
> > [1] TRUE
> >> attributes(as.POSIXlt(x))
> > $names
> >  [1] "sec""min""hour"   "mday"   "mon""year"   "wday"
>  "yday"
> >  [9] "isdst"  "zone"   "gmtoff"
> >
> > $class
> > [1] "POSIXlt" "POSIXt"
> >
> > $tzone
> > [1] "US/Eastern" "EST""EDT"
> >
> >> all.equal(x, as.POSIXlt(x))
> > [1] "'tzone' attributes are inconsistent ('' and 'US/Eastern')"
> >
> >   [[alternative HTML version deleted]]
> >
> > __
> > R-devel@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
> >
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>


-- 
Best,
Kasper

[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Specifying C Standard in Package's Makevars File

2020-10-02 Thread Andreas Kersting
Thanks, that was very helpful. The C11 features I use do actually work in C99 
mode, so I will stick with that. I just thought it was kind of "cleaner" to 
specify C11 mode when using features from that standard.

2020-09-29 16:35 GMT+02:00 "Prof Brian Ripley" :
> On 28/09/2020 12:44, Andreas Kersting wrote:> Hi,
>> > what is the correct way to specify a C standard in a package's Makevars 
>> > file?
>> > Building a package with e.g. PKG_CFLAGS = -std=gnu11 does work but R CMD 
>> > check issues a warning:
> 
> for some unstated value of 'work' ...
> 
>> * checking compilation flags in Makevars ... WARNING
>> Non-portable flags in variable 'PKG_CFLAGS':
>>-std=gnu11
>> > (Same for -std=c11.)
>> > Thanks! Regards,
>> Andreas Kersting
> 
> Those flags are not portable, as 'check' correctly says.  Furthermore, on 
> some platforms there may be no flag which can be added -- R documents that 
> 'CC' specifies a C99 compiler, and that or CC+CFLAGS are likely to specify 
> flags which are incompatible with -std=c11 (true on Solaris where -xc99 is 
> used).
> 
> So, like all such overrides (see 'Writing R Extensions') you need to write a 
> configure script (preferably using autoconf) to
> 
> - select an appropriate C compiler+flags
> - substitute them into src/Makefile.in
> 
> For the new features I have used in C11, all known compilers make them 
> available in C99 mode and a configure script could be used to test for their 
> presence (as R itself does).  That is, it is rare to actually need to specify 
> C11 mode.
> 
> -- 
> Brian D. Ripley,  rip...@stats.ox.ac.uk
> Emeritus Professor of Applied Statistics, University of Oxford
> 
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
> 
__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel