atime_versions_exprs: Create expressions for different git versions

View source: R/versions.R

atime_versions_exprsR Documentation

Create expressions for different git versions

Description

Install different git commit versions as different packages, then create a list of expressions, one for each version. For most use cases atime_versions is simpler, but atime_versions_exprs is more flexible for the case of comparing different versions of one expression to another expression.

Usage

atime_versions_exprs(
 pkg.path, expr, sha.vec=NULL,
 verbose=FALSE,
 pkg.edit.fun=pkg.edit.default,
 setup.version=NULL,
 checkout.path=pkg.path,
 ...)

Arguments

pkg.path

Path to git repo containing R package.

expr

code with package double-colon prefix, for example PKG::fun(argA, argB), where PKG is the name of the package specified by pkg.path. This code will be evaluated for each different package version, by replacing PKG:: by PKG.SHA::. To run different versions of implicitly-called functions like DT[i,j], you need to call them explicitly, as in data.table:::`[.data.table`(DT,i,j).

sha.vec

named character vector / list of versions.

verbose

logical, print messages after every data size?

pkg.edit.fun

function called to edit package before installation, should typically replace instances of PKG with PKG.SHA, default works with Rcpp packages, but does not work with all packages. For an example of a custom package editing function, see the atime vignette about data.table.

setup.version

expression to evaluate for each version, prior to timings.

checkout.path

path to repo in which we run git checkout prior to package installation. Default is pkg.path, but can be set to a sub-directory with a git submodule.

...

named versions.

Details

For convenience, versions can be specified either as code (...), data (sha.vec), or both. Each version should be either "" (to use currently installed version of package, or if missing, install most recent version from CRAN) or a SHA1 hash, which is passed as branch arg to git checkout; version names used to identify/interpret the output/plots. Each version is installed as a separate package (to whatever R library is first on .libPaths()), using the package name PKG.SHA.

Value

A list of expressions, one for each version, created by replacing PKG:: in expr with PKG.SHA::. If setup.version is used, then each expression has an attribute named setup.version, an version-specific expression to run prior to timings. This list can be used as expr.list argument of atime(), instead of writing code like atime(name1=Package.SHA1::fun(argA, argB), name2=Package.SHA2::fun(argA, argB)). If there is a HEAD commit, then the list has attributes Package and new.Package which are used in atime_versions to modify setup so that it runs using the HEAD version.

Author(s)

Toby Dylan Hocking

Examples


if(FALSE){

  if(requireNamespace("changepoint")){
    tdir <- tempfile()
    dir.create(tdir)
    gert::git_clone("https://github.com/tdhock/binsegRcpp", tdir)
    expr.list <- atime::atime_versions_exprs(
      pkg.path=tdir,
      expr=binsegRcpp::binseg_normal(data.vec, max.segs),
      cv="908b77c411bc7f4fcbcf53759245e738ae724c3e",
      "rm unord map"="dcd0808f52b0b9858352106cc7852e36d7f5b15d",
      "mvl_construct"="5942af606641428315b0e63c7da331c4cd44c091")
    atime.list <- atime::atime(
      N=2^seq(2, 20),
      setup={
        max.segs <- as.integer(N/2)
        data.vec <- 1:N
      },
      expr.list=expr.list,
      changepoint=changepoint::cpt.mean(
        data.vec, penalty="Manual", pen.value=0, method="BinSeg",
        Q=max.segs-1))
    plot(atime.list)
  }

  atime::atime_versions_remove("binsegRcpp")

}


atime documentation built on Sept. 18, 2026, 1:06 a.m.