GithubHelp home page GithubHelp logo

integer64 interaction about nanotime HOT 14 CLOSED

eddelbuettel avatar eddelbuettel commented on May 23, 2024
integer64 interaction

from nanotime.

Comments (14)

lsilvest avatar lsilvest commented on May 23, 2024 1

Looks like the last issue has nothing to do with subsetting. Also, it's really an issue with the underlying integer64 implementation:

integer64(0) > 0
## Error in if (n2%%n1) warning("length(e2) not a multiple length(e1)") : 
##  argument is not interpretable as logical

We also have another problem with zero length vectors, and again we just inherit the integer64 issues:

integer64(0)[TRUE]
## integer64
## [1] 9218868437227407266

instead of:

integer(0)[TRUE]
[1] NA

We might be able to fix the above issues with if statements, but it's not a very satisfactory solution.

from nanotime.

eddelbuettel avatar eddelbuettel commented on May 23, 2024

Thanks for this -- I had seen the same error message at times when I created zero-row result sets for which I requested a nanotime column.

@lsilvest Do you have a quick idea where this may be from?

from nanotime.

wsrfad avatar wsrfad commented on May 23, 2024
format.nanotime <- function(x, format="", tz="", ...)
{
    format <- .getFormat(format)
    tz <- .getTz(x, tz)
    bigint <- as.integer64(x)
    secs  <- as.integer64(bigint / as.integer64(1000000000))
    nanos <- bigint - secs * as.integer64(1000000000)
    res <- RcppCCTZ::formatDouble(as.double(secs), as.double(nanos), fmt=format, tgttzstr=tz)
    res[is.na(x)] <- as.character(NA)
    n = names(x)
    if (!is.null(n)) {
        names(res) <- n  						## #nocov
    }
    res
}```    

This error happens when we do binary operations on integer64 with another integer64 which is empty. In R, integer(0) / integer(1) gives numeric(0), while integer64(0) / integer64(1) gives error. This issue is creating problems at many places

from nanotime.

eddelbuettel avatar eddelbuettel commented on May 23, 2024

Yes, traceback() lead me there too but I don't quite know yet what I want the format() of an empty nanotime object should be.

from nanotime.

eddelbuettel avatar eddelbuettel commented on May 23, 2024

Try the bugfix/issue35 branch I just committed -- format.nanotime() now tests for an empty argument.

from nanotime.

wsrfad avatar wsrfad commented on May 23, 2024

This is how Date does it ...

## Scenario 1 : Empty vector in constructor
> d = character()
> as.Date(d)
[1] "Date of length 0"

## Scenario 2 : Subsetting based on empty vector of dates should also be supported
> dates = as.Date(c("2017-10-02", "2017-10-03"))
> dates[dates == as.Date("2017-10-04")]
[1] "Date of length 0"
> dates[dates == as.Date("2017-10-04")]
[1] "Date of length 0"

Does your fix support the second scenario also ?

> times = nanotime(integer64())
> times = times[times > nanotime(100) ]
> print(times)

Without your fix, at least, this case is problematic:

> times = nanotime(integer64())
> times = times[times > nanotime(100) ]
Error in callNextMethod() : 
  error in evaluating a 'primitive' next method: Error in if (n2%%n1) warning("length(e2) not a multiple length(e1)") : 
  argument is not interpretable as logical

from nanotime.

eddelbuettel avatar eddelbuettel commented on May 23, 2024

Made a second commit.

from nanotime.

wsrfad avatar wsrfad commented on May 23, 2024

The scenario 2 still fails, with bug fix !

> times = nanotime(integer64())
> times
character(0)
> times = times[times > nanotime(100) ]
Error in callNextMethod() : 
  error in evaluating a 'primitive' next method: Error in if (n2%%n1) warning("length(e2) not a multiple length(e1)") : 
  argument is not interpretable as logical

from nanotime.

eddelbuettel avatar eddelbuettel commented on May 23, 2024

Patches welcome.

from nanotime.

wsrfad avatar wsrfad commented on May 23, 2024

I am not very well versed with all the features in nanotime, as also oldClass etc keywords. I would have loved to contribute...But will take me much more time. I am taking it as a learning exercise. I had tried few things before reaching out. Few workarounds include checking for size of vector, before subsetting. But actual fix (in my opinion) should be around integer64 / RcppTz / (not sure what, though). Hope you guys can help, I will learn and then next time sure I will be able to contribute ! I will be happy to tell you test cases though, for now

from nanotime.

eddelbuettel avatar eddelbuettel commented on May 23, 2024

Maybe @lsilvest has an idea on that one; we did get two warts taken care of so some progress made.

from nanotime.

eddelbuettel avatar eddelbuettel commented on May 23, 2024

We can leave this open. Mayne we want to retitle this as it just the subsetting from integer64 that bites.

I merged the two pending branches I had -- this one and another one with two added constructor improvements.

Maybe time for a quick 0.2.1 release.

from nanotime.

wsrfad avatar wsrfad commented on May 23, 2024

I do not wish to raise issues, where people do not appreciate or welcome feedback !

from nanotime.

eddelbuettel avatar eddelbuettel commented on May 23, 2024

Can you please calm down over your non-reproducible issue #39?

This issue here was addressed over two weeks ago with this CRAN release as I mentioned.

from nanotime.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.