)} argument declaration convention is used.
-}
-}
-\description{
-The function \code{parse_args} formats KeOps formula arguments to be
-understood by the C++ code.
-}
-\details{
-Mathematical formula: \verb{sum_i e^(lambda*||x_i - y_j||^2)} where \code{x_i}, \code{y_j}
-are 3d vectors, and \code{lambda} is a scaler parameter.
-
-Corresponding KeOps formula and input parameters:
-
-\if{html}{\out{}}\preformatted{formula = "Sum_Reduction(Exp(lambda * SqNorm2(x-y)), 0)"
-args = c("x=Vi(3)", "y=Vj(3)", "lambda=Pm(1)")
-}\if{html}{\out{
}}
-
-Input arguments can be of different types:
-
-|---------|-------------------------|-----------|\tabular{lll}{
- keyword \tab meaning \tab type \cr
- \code{Vi} \tab variable indexed by \code{i} \tab \code{0} \cr
- \code{Vj} \tab variable indexed by \code{j} \tab \code{1} \cr
- \code{Pm} \tab parameter \tab \code{2} \cr
- --------- \tab ------------------------- \tab ----------- \cr
-}
-
-
-An input parameters should be defined as follows \code{"x=YY(dim)"} or
-\code{"x=YY(pos, dim)"} where \code{YY} can be \code{Vi}, \code{Vj} or \code{Pm}:
-\itemize{
-\item \code{dim} is the dimension of the variable or parameter. For \code{Vi} and \code{Vj},
-the range of \code{i} or \code{j} is not known at compile time, only at runtime.
-\item \code{pos} is the position of the variable as it will be supplied to the
-operator, starting from \code{0}. This position should be specify for all
-variable or none, if not specify the natural order in the vector \code{args} is
-used.
-}
-
-For the formula \code{"Sum_Reduction(Exp(lambda * SqNorm2(x-y)), 0)"}, both
-\code{args = c("x=Vi(3)", "y=Vj(3)", "lambda=Pm(1)")} and
-\code{args <- c("x=Vi(0,3)", "y=Vj(1,3)", "beta=Vj(2,3)", "lambda=Pm(3,1)")} are
-equivalent. When specifying the \code{pos} parameter, the natural order in the
-vector \code{args} may not correspond to the order of the formula input arguments.
-
-\strong{Note:} we recommend to use the \code{Vi(dim)} notation and let the position be
-determined by the argument order.
-}
-\author{
-Ghislain Durif
-}
-\keyword{internal}
diff --git a/rkeops/man/parse_extra_args.Rd b/rkeops/man/parse_extra_args.Rd
deleted file mode 100644
index 90f0d04b4..000000000
--- a/rkeops/man/parse_extra_args.Rd
+++ /dev/null
@@ -1,43 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/formula_args.R
-\name{parse_extra_args}
-\alias{parse_extra_args}
-\title{Parse formula for extra arguments in the formula not defined with an
-alias in the argument list.}
-\usage{
-parse_extra_args(formula)
-}
-\arguments{
-\item{formula}{text string, an operator formula (see Details).}
-}
-\value{
-a boolean value indicating if extra args were found in the formula.
-}
-\description{
-RKeOps does not support direct encoding of argument in the formula without
-an alias in the argument list. This function check if any argument are
-directly encoded in the formula without an alias.
-}
-\details{
-Parse the formula for string such as
-\itemize{
-\item \code{"YY(,)"} where \code{YY} can be a formula input argument type
-(\code{Vi}, \code{Vj} or \code{Pm}), \verb{} is the position of the corresponding input
-argument, and \verb{} its inner dimension.
-\item \code{"Var(,,)"} where \verb{} and \verb{} are the position and
-inner dimension (c.f. previous point) and \verb{} is an integer encoding
-the formula input argument type with the following relation:
-}
-
-|---------|-------------------------|-----------|\tabular{lll}{
- keyword \tab meaning \tab type \cr
- \code{Vi} \tab variable indexed by \code{i} \tab \code{0} \cr
- \code{Vj} \tab variable indexed by \code{j} \tab \code{1} \cr
- \code{Pm} \tab parameter \tab \code{2} \cr
- --------- \tab ------------------------- \tab ----------- \cr
-}
-}
-\author{
-Ghislain Durif
-}
-\keyword{internal}
diff --git a/rkeops/man/preprocess_reduction.Rd b/rkeops/man/preprocess_reduction.Rd
deleted file mode 100644
index 8a847caf1..000000000
--- a/rkeops/man/preprocess_reduction.Rd
+++ /dev/null
@@ -1,52 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/lazytensor_preprocess.R
-\name{preprocess_reduction}
-\alias{preprocess_reduction}
-\title{Preprocess reduction operation.}
-\usage{
-preprocess_reduction(x, opstr, index, opt_arg = NULL)
-}
-\arguments{
-\item{x}{A \code{LazyTensor} or a \code{ComplexLazyTensor}.}
-
-\item{opstr}{A \code{string} formula (like "Sum" or "Max").}
-
-\item{index}{A \code{character} that should be either \code{i} or \code{j} to specify
-whether if the reduction is indexed by \code{i} (rows), or \code{j} (columns).}
-
-\item{opt_arg}{An optional argument: an \code{integer} (e.g. for "Kmin"
-reduction), a \code{character}, a \code{LazyTensor} or a \code{ComplexLazyTensor}. \code{NULL}
-if not used (default).}
-}
-\value{
-A \code{function}.
-}
-\description{
-Returns a \code{function} for a reduction to a \code{LazyTensor} and it is called in
-\code{rkeops::reduction.LazyTensor()}.
-}
-\details{
-\code{preprocess_reduction(x, opstr, index)} will:
-\itemize{
-\item if \code{index = "i"}, return a \code{function} corresponding to the
-\code{opstr} reduction of \code{x} over the \code{i} indexes;
-\item if \code{index = "j"}, return a \code{function} corresponding to the
-\code{opstr} reduction of \code{x} over the \code{j} indexes.
-}
-}
-\examples{
-\dontrun{
-x <- matrix(runif(150 * 3), 150, 3) # arbitrary R matrix, 150 rows, 3 columns
-x_i <- LazyTensor(x, index = 'i') # creating LazyTensor from matrix x,
- # indexed by 'i'
-
-op <- preprocess_reduction(x_i, "Sum", "i")
-}
-}
-\seealso{
-\code{\link[=reduction.LazyTensor]{reduction.LazyTensor()}}
-}
-\author{
-Chloe Serre-Combe, Amelie Vernay
-}
-\keyword{internal}
diff --git a/rkeops/man/pykeops.Rd b/rkeops/man/pykeops.Rd
deleted file mode 100644
index 96e3dfc0e..000000000
--- a/rkeops/man/pykeops.Rd
+++ /dev/null
@@ -1,17 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/zzz.R
-\docType{data}
-\name{pykeops}
-\alias{pykeops}
-\title{Global reference to main PyKeOps module}
-\format{
-An object of class \code{python.builtin.module}
-}
-\value{
-the \code{pykeops} Python module
-}
-\description{
-The \code{pykeops} module object is an internal reference to the PyKeOps
-Python package that is used under the hood by \code{rkeops}.
-}
-\keyword{internal}
diff --git a/rkeops/man/random_varname.Rd b/rkeops/man/random_varname.Rd
deleted file mode 100644
index 8d538dfcd..000000000
--- a/rkeops/man/random_varname.Rd
+++ /dev/null
@@ -1,22 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/utils.R
-\name{random_varname}
-\alias{random_varname}
-\title{Helper function to generate random variable name for gradient input in
-formula}
-\usage{
-random_varname(prefix = "", len = 5)
-}
-\arguments{
-\item{prefix}{character string, prefix to add to the variable name.}
-
-\item{len}{integer, number of random character in the variable name.}
-}
-\value{
-character string, name of the python environment.
-}
-\description{
-Helper function to generate random variable name for gradient input in
-formula
-}
-\keyword{internal}
diff --git a/rkeops/man/real2complex.Rd b/rkeops/man/real2complex.Rd
index e08bc18c6..4fe2a0e8b 100644
--- a/rkeops/man/real2complex.Rd
+++ b/rkeops/man/real2complex.Rd
@@ -30,13 +30,11 @@ symbolically, the element-wise "real to complex" transformation of \code{x}
a \code{ComplexLazyTensor}.
}
\examples{
-\dontrun{
x <- matrix(runif(150 * 3), 150, 3) # arbitrary R matrix, 150 rows, 3 columns
x_i <- LazyTensor(x, "i") # creating LazyTensor from matrix x,
# indexed by 'i'
z <- real2complex(x_i) # ComplexLazyTensor object
}
-}
\author{
Chloe Serre-Combe, Amelie Vernay
}
diff --git a/rkeops/man/reduction.LazyTensor.Rd b/rkeops/man/reduction.LazyTensor.Rd
index 63cefbb6b..0fb6c0d41 100644
--- a/rkeops/man/reduction.LazyTensor.Rd
+++ b/rkeops/man/reduction.LazyTensor.Rd
@@ -33,12 +33,23 @@ Applies a reduction to a \code{LazyTensor}.
}
}
\examples{
-\dontrun{
+\donttest{
+\dontshow{
+# Specific setup for example runs (not necessary for standard use)
+reticulate::py_available(initialize = TRUE)
+set_rkeops_options()
+# For build on CRAN, use CPU computing with 2 cores max
+rkeops_use_cpu(ncore = 2)
+}
x <- matrix(runif(150 * 3), 150, 3) # arbitrary R matrix, 150 rows, 3 columns
x_i <- LazyTensor(x, index = 'i') # creating LazyTensor from matrix x,
# indexed by 'i'
red_x <- reduction.LazyTensor(x_i, "Sum", "i")
+\dontshow{
+# clean-up (for CRAN build)
+clean_rkeops(remove_cache_dir = TRUE)
+}
}
}
\author{
diff --git a/rkeops/man/relu.LazyTensor.Rd b/rkeops/man/relu.LazyTensor.Rd
index 95de17789..d0c129903 100644
--- a/rkeops/man/relu.LazyTensor.Rd
+++ b/rkeops/man/relu.LazyTensor.Rd
@@ -25,13 +25,11 @@ The ReLU function \insertCite{fukushima_cognitron_1975}{rkeops} is defined
as follows: \code{relu(x)} returns \code{0} if \code{x < 0}, \code{x} if \code{x >= 0}.
}
\examples{
-\dontrun{
x <- matrix(runif(150 * 3), 150, 3) # arbitrary R matrix, 150 rows, 3 columns
x_i <- LazyTensor(x, index = 'i') # creating LazyTensor from matrix x,
# indexed by 'i'
ReLU_x <- relu(x_i) # symbolic matrix, 150 rows and 3 columns
}
-}
\references{
\insertRef{fukushima_cognitron_1975}{rkeops}
}
diff --git a/rkeops/man/relu.Rd b/rkeops/man/relu.Rd
index 6b48481b2..776869d98 100644
--- a/rkeops/man/relu.Rd
+++ b/rkeops/man/relu.Rd
@@ -26,7 +26,6 @@ If \code{x} is a \code{LazyTensor}, see \code{\link[=relu.LazyTensor]{relu.LazyT
see \code{\link[=relu.default]{relu.default()}}.
}
\examples{
-\dontrun{
# Numerical input
relu(4)
relu(-10:10)
@@ -36,7 +35,6 @@ x_i <- LazyTensor(x, index = 'i') # creating LazyTensor from matrix x,
# indexed by 'i'
ReLU_x <- relu(x_i) # symbolic matrix, 150 rows and 3 columns
}
-}
\references{
\insertRef{fukushima_cognitron_1975}{rkeops}
}
diff --git a/rkeops/man/rkeops-package.Rd b/rkeops/man/rkeops-package.Rd
index 9cdedabf0..11bd07d3a 100644
--- a/rkeops/man/rkeops-package.Rd
+++ b/rkeops/man/rkeops-package.Rd
@@ -23,8 +23,7 @@ the computation of Kernel dot products and the associated gradients, even
when the full kernel matrix does not fit into the GPU memory.
For more information, please read the vignettes
-(\code{browseVignettes("rkeops")}) and visit
-\url{https://www.kernel-operations.io/}.
+(\code{browseVignettes("rkeops")}) and visit \url{https://www.kernel-operations.io/}.
}
\references{
\insertRef{JMLR:v22:20-275}{rkeops}
@@ -40,12 +39,12 @@ Useful links:
}
\author{
\itemize{
-\item \href{http://imag.umontpellier.fr/~charlier/}{Benjamin Charlier}
+\item \href{https://miat.inrae.fr/bcharlier/}{Benjamin Charlier}
\item Amelie Vernay
\item Chloe Serre-Combe
\item \href{https://gdurif.perso.math.cnrs.fr/}{Ghislain Durif}
\item \href{https://www.jeanfeydy.com}{Jean Feydy}
-\item \href{http://helios.mi.parisdescartes.fr/~glaunes/}{Joan Alexis Glaunès}
-\item François-David Collin
+\item \href{https://helios2.mi.parisdescartes.fr/~glaunes/}{Joan Alexis Glaunès}
+\item \href{https://fradav.perso.math.cnrs.fr/}{François-David Collin}
}
}
diff --git a/rkeops/man/rkeops_disable_verbosity.Rd b/rkeops/man/rkeops_disable_verbosity.Rd
index 94e9a17aa..a615066f7 100644
--- a/rkeops/man/rkeops_disable_verbosity.Rd
+++ b/rkeops/man/rkeops_disable_verbosity.Rd
@@ -13,8 +13,10 @@ None
Disable verbosity during operator compilation process.
}
\examples{
-\dontrun{
rkeops_disable_verbosity()
+\dontshow{
+# set options back to default
+set_rkeops_options()
}
}
\seealso{
diff --git a/rkeops/man/rkeops_enable_verbosity.Rd b/rkeops/man/rkeops_enable_verbosity.Rd
index f12c37f92..cfaadb8a3 100644
--- a/rkeops/man/rkeops_enable_verbosity.Rd
+++ b/rkeops/man/rkeops_enable_verbosity.Rd
@@ -13,8 +13,10 @@ None
Enable verbosity during operator compilation process.
}
\examples{
-\dontrun{
rkeops_enable_verbosity()
+\dontshow{
+# set options back to default
+set_rkeops_options()
}
}
\seealso{
diff --git a/rkeops/man/rkeops_use_cpu.Rd b/rkeops/man/rkeops_use_cpu.Rd
index 316416b2e..fcaf5e47d 100644
--- a/rkeops/man/rkeops_use_cpu.Rd
+++ b/rkeops/man/rkeops_use_cpu.Rd
@@ -29,8 +29,10 @@ the number of cores used by \code{rkeops} user-defined operators, you can used
the input parameter \code{ncore}.
}
\examples{
-\dontrun{
rkeops_use_cpu()
+\dontshow{
+# set options back to default
+set_rkeops_options()
}
}
\seealso{
diff --git a/rkeops/man/rkeops_use_float32.Rd b/rkeops/man/rkeops_use_float32.Rd
index cb1180f1d..fb677f46d 100644
--- a/rkeops/man/rkeops_use_float32.Rd
+++ b/rkeops/man/rkeops_use_float32.Rd
@@ -27,8 +27,10 @@ output are converted to 32bit float before computation and back to
64bit float after computation.
}
\examples{
-\dontrun{
rkeops_use_float32()
+\dontshow{
+# set options back to default
+set_rkeops_options()
}
}
\seealso{
diff --git a/rkeops/man/rkeops_use_float64.Rd b/rkeops/man/rkeops_use_float64.Rd
index b4f6f0919..843821d4d 100644
--- a/rkeops/man/rkeops_use_float64.Rd
+++ b/rkeops/man/rkeops_use_float64.Rd
@@ -24,8 +24,10 @@ accuracy of your computation and validity of your results
in certain applications.
}
\examples{
-\dontrun{
rkeops_use_float64()
+\dontshow{
+# set options back to default
+set_rkeops_options()
}
}
\seealso{
diff --git a/rkeops/man/rkeops_use_gpu.Rd b/rkeops/man/rkeops_use_gpu.Rd
index 2b4626887..4f493838d 100644
--- a/rkeops/man/rkeops_use_gpu.Rd
+++ b/rkeops/man/rkeops_use_gpu.Rd
@@ -35,8 +35,10 @@ computations on GPU.
To disable GPU computing, run \code{\link[=rkeops_use_cpu]{rkeops_use_cpu()}}.
}
\examples{
-\dontrun{
rkeops_use_gpu()
+\dontshow{
+# set options back to default
+set_rkeops_options()
}
}
\seealso{
diff --git a/rkeops/man/round.LazyTensor.Rd b/rkeops/man/round.LazyTensor.Rd
index de5131139..b8f02ff76 100644
--- a/rkeops/man/round.LazyTensor.Rd
+++ b/rkeops/man/round.LazyTensor.Rd
@@ -25,13 +25,11 @@ that encodes, symbolically, the element-wise rounding of \code{x} to \code{digit
decimal places.
}
\examples{
-\dontrun{
x <- matrix(runif(150 * 3), 150, 3) # arbitrary R matrix, 150 rows, 3 columns
x_i <- LazyTensor(x, index = 'i') # creating LazyTensor from matrix x,
# indexed by 'i'
Round_x <- round(x_i, 2) # symbolic matrix
}
-}
\seealso{
\code{\link[=round]{round()}}
}
diff --git a/rkeops/man/round.Rd b/rkeops/man/round.Rd
index bcddcaa58..d875db001 100644
--- a/rkeops/man/round.Rd
+++ b/rkeops/man/round.Rd
@@ -24,7 +24,6 @@ If \code{x} is a \code{LazyTensor}, see \code{\link[=round.LazyTensor]{round.Laz
see \code{\link[=round.default]{round.default()}}.
}
\examples{
-\dontrun{
# R base operation
round(5)
round(runif(10), 4)
@@ -34,7 +33,6 @@ x_i <- LazyTensor(x, index = 'i') # creating LazyTensor from matrix x,
# indexed by 'i'
Round_x <- round(x_i, 2) # symbolic matrix
}
-}
\seealso{
\code{\link[=round.default]{round.default()}}, \code{\link[=round.LazyTensor]{round.LazyTensor()}}
}
diff --git a/rkeops/man/round.default.Rd b/rkeops/man/round.default.Rd
index 52fb6d248..7d96d40f0 100644
--- a/rkeops/man/round.default.Rd
+++ b/rkeops/man/round.default.Rd
@@ -14,6 +14,9 @@
(\code{round}) or significant digits (\code{signif}) to be used.
For \code{round}, negative values are allowed (see \sQuote{Details}).}
}
+\value{
+See 'Details' section.
+}
\description{
\code{ceiling} takes a single numeric argument \code{x} and returns a
numeric vector containing the smallest integers not less than the
diff --git a/rkeops/man/rsqrt.LazyTensor.Rd b/rkeops/man/rsqrt.LazyTensor.Rd
index 8cbe9ae71..c0501fa5b 100644
--- a/rkeops/man/rsqrt.LazyTensor.Rd
+++ b/rkeops/man/rsqrt.LazyTensor.Rd
@@ -23,13 +23,11 @@ encodes, symbolically, the element-wise inverse square root of \code{x}, i.e.
\eqn{1/\sqrt{x}}.
}
\examples{
-\dontrun{
x <- matrix(runif(150 * 3), 150, 3) # arbitrary R matrix, 150 rows, 3 columns
x_i <- LazyTensor(x, index = 'i') # creating LazyTensor from matrix x,
# indexed by 'i'
Rsqrt_x <- rsqrt(x_i) # symbolic matrix, 150 rows and 3 columns
}
-}
\seealso{
\code{\link[=rsqrt]{rsqrt()}}
}
diff --git a/rkeops/man/rsqrt.Rd b/rkeops/man/rsqrt.Rd
index 9269ae1c7..03372b75f 100644
--- a/rkeops/man/rsqrt.Rd
+++ b/rkeops/man/rsqrt.Rd
@@ -24,7 +24,6 @@ If \code{x} is a \code{LazyTensor}, see \code{\link[=rsqrt.LazyTensor]{rsqrt.Laz
see \code{\link[=rsqrt.default]{rsqrt.default()}}.
}
\examples{
-\dontrun{
# Numerical input
rsqrt(4)
rsqrt(c(1,4,9,16))
@@ -34,7 +33,6 @@ x_i <- LazyTensor(x, index = 'i') # creating LazyTensor from matrix x,
# indexed by 'i'
Rsqrt_x <- rsqrt(x_i) # symbolic matrix, 150 rows and 3 columns
}
-}
\seealso{
\code{\link[=rsqrt.default]{rsqrt.default()}}, \code{\link[=rsqrt.LazyTensor]{rsqrt.LazyTensor()}}
}
diff --git a/rkeops/man/scalar.product.LazyTensor.Rd b/rkeops/man/scalar.product.LazyTensor.Rd
index 032f9bf34..cfc4bf87c 100644
--- a/rkeops/man/scalar.product.LazyTensor.Rd
+++ b/rkeops/man/scalar.product.LazyTensor.Rd
@@ -27,7 +27,6 @@ a vector or a scalar, it is first converted to \code{LazyTensor}).
\strong{Note}: \code{x} and \code{y} input arguments should have the same inner dimension.
}
\examples{
-\dontrun{
x <- matrix(runif(150 * 3), 150, 3) # arbitrary R matrix, 150 rows, 3 columns
y <- matrix(runif(250 * 3), 250, 3) # arbitrary R matrix, 250 rows, 3 columns
x_i <- LazyTensor(x, index = 'i') # creating LazyTensor from matrix x,
@@ -36,7 +35,6 @@ y_j <- LazyTensor(y, index = 'j') # creating LazyTensor from matrix y,
# indexed by 'j'
x_sp_y <- x_i | y_j # symbolic matrix
}
-}
\author{
Chloe Serre-Combe, Amelie Vernay
}
diff --git a/rkeops/man/set_pykeops_verbosity.Rd b/rkeops/man/set_pykeops_verbosity.Rd
deleted file mode 100644
index ac8e4b941..000000000
--- a/rkeops/man/set_pykeops_verbosity.Rd
+++ /dev/null
@@ -1,31 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/keops_setup.R
-\name{set_pykeops_verbosity}
-\alias{set_pykeops_verbosity}
-\title{Set PyKeOps verbosity}
-\usage{
-set_pykeops_verbosity()
-}
-\value{
-None
-}
-\description{
-Enable or disable verbosity during operator compilation process in PyKeops
-using current verbosity status in RKeOps options.
-}
-\details{
-\strong{Note:} this is an internal function, user should use
-\code{\link[=rkeops_enable_verbosity]{rkeops_enable_verbosity()}} or \code{\link[=rkeops_disable_verbosity]{rkeops_disable_verbosity()}}.
-}
-\examples{
-\dontrun{
-set_pykeops_verbosity()
-}
-}
-\seealso{
-\code{\link[=setup_pykeops]{setup_pykeops()}}
-}
-\author{
-Ghislain Durif
-}
-\keyword{internal}
diff --git a/rkeops/man/set_rkeops_cache_dir.Rd b/rkeops/man/set_rkeops_cache_dir.Rd
index 3dd8cf5df..ef448ad5c 100644
--- a/rkeops/man/set_rkeops_cache_dir.Rd
+++ b/rkeops/man/set_rkeops_cache_dir.Rd
@@ -43,9 +43,13 @@ to (fully or partially) delete its content.
the default rkeops cache directory.
}
\examples{
+# use default cache directory
+set_rkeops_cache_dir()
\dontrun{
-set_rkeops_build_dir()
+# edit path at your convenience
+set_rkeops_cache_dir("/path/to/a/specific/directory")
}
+
}
\seealso{
\code{\link[=get_rkeops_cache_dir]{get_rkeops_cache_dir()}}, \code{\link[=stat_rkeops_cache_dir]{stat_rkeops_cache_dir()}},
diff --git a/rkeops/man/set_rkeops_options.Rd b/rkeops/man/set_rkeops_options.Rd
index ebe8f1396..097ba4634 100644
--- a/rkeops/man/set_rkeops_options.Rd
+++ b/rkeops/man/set_rkeops_options.Rd
@@ -2,7 +2,7 @@
% Please edit documentation in R/rkeops_options.R
\name{set_rkeops_options}
\alias{set_rkeops_options}
-\title{Get or set the current \code{rkeops} options in \code{R} global options scope}
+\title{Set the current \code{rkeops} options in \code{R} global options scope}
\usage{
set_rkeops_options(input = NULL)
}
@@ -55,6 +55,10 @@ recompilation).
\examples{
set_rkeops_options()
set_rkeops_options(list(verbosity = 0))
+\dontshow{
+# set options back to default
+set_rkeops_options()
+}
}
\seealso{
diff --git a/rkeops/man/setup_pykeops.Rd b/rkeops/man/setup_pykeops.Rd
deleted file mode 100644
index 244e00019..000000000
--- a/rkeops/man/setup_pykeops.Rd
+++ /dev/null
@@ -1,36 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/keops_setup.R
-\name{setup_pykeops}
-\alias{setup_pykeops}
-\title{Setup PyKeOps before using it}
-\usage{
-setup_pykeops()
-}
-\value{
-None
-}
-\description{
-Wrapper function to call all setup functions for PyKeOps including:
-\itemize{
-\item \code{\link[=set_pykeops_verbosity]{set_pykeops_verbosity()}} to set verbosity
-\item \code{\link[=set_pykeops_build_dir]{set_pykeops_build_dir()}} to set build directory
-}
-}
-\details{
-\strong{Note:} this is an internal function, user should use
-\code{\link[=rkeops_enable_verbosity]{rkeops_enable_verbosity()}} or \code{\link[=rkeops_disable_verbosity]{rkeops_disable_verbosity()}}
-for verbosity setup, \code{\link[=get_rkeops_cache_dir]{get_rkeops_cache_dir()}} or
-\code{\link[=set_rkeops_cache_dir]{set_rkeops_cache_dir()}} for cache/build directory setup.
-}
-\examples{
-\dontrun{
-setup_pykeops()
-}
-}
-\seealso{
-\code{\link[=set_pykeops_verbosity]{set_pykeops_verbosity()}}, \code{\link[=set_pykeops_build_dir]{set_pykeops_build_dir()}}
-}
-\author{
-Ghislain Durif
-}
-\keyword{internal}
diff --git a/rkeops/man/sign.LazyTensor.Rd b/rkeops/man/sign.LazyTensor.Rd
index aa10d6bcf..bfd02ee4f 100644
--- a/rkeops/man/sign.LazyTensor.Rd
+++ b/rkeops/man/sign.LazyTensor.Rd
@@ -27,13 +27,11 @@ encodes, symbolically, the element-wise sign of \code{x}, i.e.
\end{array}\right.}
}
\examples{
-\dontrun{
x <- matrix(runif(150 * 3), 150, 3) # arbitrary R matrix, 150 rows, 3 columns
x_i <- LazyTensor(x, index = 'i') # creating LazyTensor from matrix x,
# indexed by 'i'
Sign_x <- sign(x_i) # symbolic matrix, 150 rows and 3 columns
}
-}
\seealso{
\code{\link[=sign]{sign()}}
}
diff --git a/rkeops/man/sign.Rd b/rkeops/man/sign.Rd
index 49dc8f0c6..90971da83 100644
--- a/rkeops/man/sign.Rd
+++ b/rkeops/man/sign.Rd
@@ -29,7 +29,6 @@ The sign function is defined as follows:
\end{array}\right.}
}
\examples{
-\dontrun{
# R base operation
sign(5)
sign(-5)
@@ -40,7 +39,6 @@ x_i <- LazyTensor(x, index = 'i') # creating LazyTensor from matrix x,
# indexed by 'i'
Sign_x <- sign(x_i) # symbolic matrix, 150 rows and 3 columns
}
-}
\seealso{
\code{\link[=sign.default]{sign.default()}}, \code{\link[=sign.LazyTensor]{sign.LazyTensor()}}
}
diff --git a/rkeops/man/sign.default.Rd b/rkeops/man/sign.default.Rd
index 000cfca91..7ac692df1 100644
--- a/rkeops/man/sign.default.Rd
+++ b/rkeops/man/sign.default.Rd
@@ -9,6 +9,9 @@
\arguments{
\item{x}{a numeric vector}
}
+\value{
+See 'Details' section.
+}
\description{
\code{sign} returns a vector with the signs of the corresponding
elements of \code{x} (the sign of a real number is 1, 0, or \eqn{-1}
diff --git a/rkeops/man/sin.LazyTensor.Rd b/rkeops/man/sin.LazyTensor.Rd
index a90bd2d26..07ada1db6 100644
--- a/rkeops/man/sin.LazyTensor.Rd
+++ b/rkeops/man/sin.LazyTensor.Rd
@@ -21,13 +21,11 @@ If \code{x} is a \code{LazyTensor}, \code{sin(x)} returns a \code{LazyTensor} th
encodes, symbolically, the element-wise sine of \code{x}.
}
\examples{
-\dontrun{
x <- matrix(runif(150 * 3), 150, 3) # arbitrary R matrix, 150 rows, 3 columns
x_i <- LazyTensor(x, index = 'i') # creating LazyTensor from matrix x,
# indexed by 'i'
Sin_x <- sin(x_i) # symbolic matrix, 150 rows and 3 columns
}
-}
\seealso{
\code{\link[=sin]{sin()}}
}
diff --git a/rkeops/man/sin.Rd b/rkeops/man/sin.Rd
index 1cb2e1e05..8d8d63fa1 100644
--- a/rkeops/man/sin.Rd
+++ b/rkeops/man/sin.Rd
@@ -23,7 +23,6 @@ If \code{x} is a \code{LazyTensor}, see \code{\link[=sin.LazyTensor]{sin.LazyTen
see \code{\link[=sin.default]{sin.default()}}.
}
\examples{
-\dontrun{
# R base operation
sin(0)
sin(pi)
@@ -33,7 +32,6 @@ x_i <- LazyTensor(x, index = 'i') # creating LazyTensor from matrix x,
# indexed by 'i'
Sin_x <- sin(x_i) # symbolic matrix, 150 rows and 3 columns
}
-}
\seealso{
\code{\link[=sin.default]{sin.default()}}, \code{\link[=sin.LazyTensor]{sin.LazyTensor()}}
}
diff --git a/rkeops/man/sinxdivx.LazyTensor.Rd b/rkeops/man/sinxdivx.LazyTensor.Rd
index 59fd91df3..a24986f0b 100644
--- a/rkeops/man/sinxdivx.LazyTensor.Rd
+++ b/rkeops/man/sinxdivx.LazyTensor.Rd
@@ -23,13 +23,11 @@ encodes, symbolically, the element-wise \code{sin(x)/x} values for \code{x}.
\strong{Note}: by convention \code{sinxdivx(0)} returns \code{1}.
}
\examples{
-\dontrun{
x <- matrix(runif(150 * 3), 150, 3) # arbitrary R matrix, 150 rows, 3 columns
x_i <- LazyTensor(x, index = 'i') # creating LazyTensor from matrix x,
# indexed by 'i'
sindiv_x <- sinxdivx(x_i) # symbolic matrix, 150 rows and 3 columns
}
-}
\seealso{
\code{\link[=sinxdivx]{sinxdivx()}}
}
diff --git a/rkeops/man/sinxdivx.Rd b/rkeops/man/sinxdivx.Rd
index 7ea858f96..bc23e94db 100644
--- a/rkeops/man/sinxdivx.Rd
+++ b/rkeops/man/sinxdivx.Rd
@@ -25,7 +25,6 @@ else see \code{\link[=sinxdivx.default]{sinxdivx.default()}}.
\strong{Note}: by convention \code{sinxdivx(0)} returns \code{1}.
}
\examples{
-\dontrun{
# Numerical input
sinxdivx(4)
sinxdivx(1:10)
@@ -35,7 +34,6 @@ x_i <- LazyTensor(x, index = 'i') # creating LazyTensor from matrix x,
# indexed by 'i'
sindiv_x <- sinxdivx(x_i) # symbolic matrix, 150 rows and 3 columns
}
-}
\seealso{
\code{\link[=sinxdivx.default]{sinxdivx.default()}}, \code{\link[=sinxdivx.LazyTensor]{sinxdivx.LazyTensor()}}
}
diff --git a/rkeops/man/sqdist.Rd b/rkeops/man/sqdist.Rd
index 891f1b86d..c9fc3fc9a 100644
--- a/rkeops/man/sqdist.Rd
+++ b/rkeops/man/sqdist.Rd
@@ -28,13 +28,14 @@ the squared Euclidean distance between \code{x} and \code{y}, same as \code{sqno
or be of dimension 1.
}
\examples{
-\dontrun{
x <- matrix(runif(150 * 3), 150, 3) # arbitrary R matrix, 150 rows, 3 columns
+y <- matrix(runif(150 * 3), 150, 3) # arbitrary R matrix, 150 rows, 3 columns
x_i <- LazyTensor(x, index = 'i') # creating LazyTensor from matrix x,
# indexed by 'i'
+y_j <- LazyTensor(y, index = 'j') # creating LazyTensor from matrix y,
+ # indexed by 'j'
-SqD_x <- sqdist(x_i) # symbolic matrix, 150 rows and 3 columns
-}
+SqD_x <- sqdist(x_i, y_j) # symbolic matrix, 150 rows and 3 columns
}
\seealso{
\code{\link[=sqnorm2]{sqnorm2()}}
diff --git a/rkeops/man/sqnorm2.Rd b/rkeops/man/sqnorm2.Rd
index d4424b02c..bd8315d84 100644
--- a/rkeops/man/sqnorm2.Rd
+++ b/rkeops/man/sqnorm2.Rd
@@ -21,13 +21,11 @@ Symbolic squared Euclidean norm operation for \code{LazyTensor} objects.
the squared Euclidean norm of \code{x}, same as \code{(x|x)}.
}
\examples{
-\dontrun{
x <- matrix(runif(150 * 3), 150, 3) # arbitrary R matrix, 150 rows, 3 columns
x_i <- LazyTensor(x, index = 'i') # creating LazyTensor from matrix x,
# indexed by 'i'
SqN_x <- sqnorm2(x_i) # symbolic matrix, 150 rows, 1 columns
}
-}
\seealso{
\code{\link[=|.LazyTensor]{|.LazyTensor()}}
}
diff --git a/rkeops/man/sqrt.LazyTensor.Rd b/rkeops/man/sqrt.LazyTensor.Rd
index ca2776070..211a35965 100644
--- a/rkeops/man/sqrt.LazyTensor.Rd
+++ b/rkeops/man/sqrt.LazyTensor.Rd
@@ -22,13 +22,11 @@ encodes, symbolically, the element-wise square root of \code{x}, i.e.
\eqn{\sqrt{x}}.
}
\examples{
-\dontrun{
x <- matrix(runif(150 * 3), 150, 3) # arbitrary R matrix, 150 rows, 3 columns
x_i <- LazyTensor(x, index = 'i') # creating LazyTensor from matrix x,
# indexed by 'i'
Sqrt_x <- sqrt(x_i) # symbolic matrix, 150 rows and 3 columns
}
-}
\seealso{
\code{\link[=sqrt]{sqrt()}}
}
diff --git a/rkeops/man/sqrt.Rd b/rkeops/man/sqrt.Rd
index 4f95fb1a7..d72b454fa 100644
--- a/rkeops/man/sqrt.Rd
+++ b/rkeops/man/sqrt.Rd
@@ -25,7 +25,6 @@ see \code{\link[=sqrt.default]{sqrt.default()}}.
corresponds to the complex modulus \code{sqrt(z) = z^0.5}.
}
\examples{
-\dontrun{
# R base operation
sqrt(4)
sqrt(c(1,4,9,16))
@@ -35,7 +34,6 @@ x_i <- LazyTensor(x, index = 'i') # creating LazyTensor from matrix x,
# indexed by 'i'
Sqrt_x <- sqrt(x_i) # symbolic matrix, 150 rows and 3 columns
}
-}
\seealso{
\code{\link[=sqrt.default]{sqrt.default()}}, \code{\link[=sqrt.LazyTensor]{sqrt.LazyTensor()}}
}
diff --git a/rkeops/man/square.LazyTensor.Rd b/rkeops/man/square.LazyTensor.Rd
index 96f98ac89..ad9cb130f 100644
--- a/rkeops/man/square.LazyTensor.Rd
+++ b/rkeops/man/square.LazyTensor.Rd
@@ -21,13 +21,11 @@ If \code{x} is a \code{LazyTensor}, \code{square(x)} returns a \code{LazyTensor}
encodes, symbolically, the element-wise square of \code{x}, i.e. \eqn{x^2}.
}
\examples{
-\dontrun{
x <- matrix(runif(150 * 3), 150, 3) # arbitrary R matrix, 150 rows, 3 columns
x_i <- LazyTensor(x, index = 'i') # creating LazyTensor from matrix x,
# indexed by 'i'
Square_x <- square(x_i) # symbolic matrix, 150 rows and 3 columns
}
-}
\seealso{
\code{\link[=square]{square()}}
}
diff --git a/rkeops/man/square.Rd b/rkeops/man/square.Rd
index f5522eeb8..0f49b6875 100644
--- a/rkeops/man/square.Rd
+++ b/rkeops/man/square.Rd
@@ -23,7 +23,6 @@ If \code{x} is a \code{LazyTensor}, see \code{\link[=square.LazyTensor]{square.L
see \code{\link[=square.default]{square.default()}}.
}
\examples{
-\dontrun{
# Numerical input
square(4)
square(1:4)
@@ -33,7 +32,6 @@ x_i <- LazyTensor(x, index = 'i') # creating LazyTensor from matrix x,
# indexed by 'i'
Square_x <- square(x_i) # symbolic matrix, 150 rows and 3 columns
}
-}
\seealso{
\code{\link[=square.default]{square.default()}}, \code{\link[=square.LazyTensor]{square.LazyTensor()}}
}
diff --git a/rkeops/man/stat_dir.Rd b/rkeops/man/stat_dir.Rd
deleted file mode 100644
index 5e7989e31..000000000
--- a/rkeops/man/stat_dir.Rd
+++ /dev/null
@@ -1,22 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/utils.R
-\name{stat_dir}
-\alias{stat_dir}
-\title{Disk usage of a given directory}
-\usage{
-stat_dir(path)
-}
-\arguments{
-\item{path}{character string, path to directory for which the disk
-usage will be computed.}
-}
-\value{
-character string, a disk usage in (G/M/K)bytes.
-}
-\description{
-Sum the sizes of all files in a given folder and its sub-directories.
-}
-\author{
-Ghislain Durif
-}
-\keyword{internal}
diff --git a/rkeops/man/stat_rkeops_cache_dir.Rd b/rkeops/man/stat_rkeops_cache_dir.Rd
index d58a2d95f..87de0bcbf 100644
--- a/rkeops/man/stat_rkeops_cache_dir.Rd
+++ b/rkeops/man/stat_rkeops_cache_dir.Rd
@@ -38,9 +38,8 @@ directory, and you can use \code{\link[=clean_rkeops]{clean_rkeops()}} to (fully
delete its content.
}
\examples{
-\dontrun{
stat_rkeops_cache_dir()
-}
+
}
\seealso{
\code{\link[=get_rkeops_cache_dir]{get_rkeops_cache_dir()}}, \code{\link[=clean_rkeops]{clean_rkeops()}}
diff --git a/rkeops/man/step.LazyTensor.Rd b/rkeops/man/step.LazyTensor.Rd
index 5f216d246..35f619cff 100644
--- a/rkeops/man/step.LazyTensor.Rd
+++ b/rkeops/man/step.LazyTensor.Rd
@@ -25,12 +25,10 @@ that encodes, symbolically, the element-wise 0-1 step of \code{x}, i.e.
\code{0} if \code{x < 0}, \code{1} if \code{x >= 0}.
}
\examples{
-\dontrun{
x <- matrix(runif(150 * 3), 150, 3) # arbitrary R matrix, 150 rows, 3 columns
x_i <- LazyTensor(x, index = 'i') # creating LazyTensor from matrix x,
# indexed by 'i'
-Step_x <- step.LazyTensor(x_i) # symbolic matrix, 150 rows and 3 columns
-}
+Step_x <- step(x_i) # symbolic matrix, 150 rows and 3 columns
}
\seealso{
\code{\link[=step]{step()}}
diff --git a/rkeops/man/step.Rd b/rkeops/man/step.Rd
index a6a4ed717..5f06c2f3d 100644
--- a/rkeops/man/step.Rd
+++ b/rkeops/man/step.Rd
@@ -26,14 +26,12 @@ If \code{x} is a \code{LazyTensor}, see \code{\link[=step.LazyTensor]{step.LazyT
see \code{\link[=step.default]{step.default()}}.
}
\examples{
-\dontrun{
# R base operation: see `?step.default`
# LazyTensor symbolic element-wise sign
x <- matrix(runif(150 * 3), 150, 3) # arbitrary R matrix, 150 rows, 3 columns
x_i <- LazyTensor(x, index = 'i') # creating LazyTensor from matrix x,
# indexed by 'i'
-Step_x <- step.LazyTensor(x_i) # symbolic matrix, 150 rows and 3 columns
-}
+Step_x <- step(x_i) # symbolic matrix, 150 rows and 3 columns
}
\seealso{
\code{\link[=step.default]{step.default()}}, \code{\link[=step.LazyTensor]{step.LazyTensor()}}
diff --git a/rkeops/man/sum.LazyTensor.Rd b/rkeops/man/sum.LazyTensor.Rd
index 7d7b587ee..87778cab9 100644
--- a/rkeops/man/sum.LazyTensor.Rd
+++ b/rkeops/man/sum.LazyTensor.Rd
@@ -44,21 +44,42 @@ section \emph{"Reductions"}.
\code{sum_reduction()} function.
}
\examples{
-\dontrun{
+\donttest{
+\dontshow{
+# Specific setup for example runs (not necessary for standard use)
+reticulate::py_available(initialize = TRUE)
+set_rkeops_options()
+# For build on CRAN, use CPU computing with 2 cores max
+rkeops_use_cpu(ncore = 2)
+}
x <- matrix(runif(150 * 3), 150, 3) # arbitrary R matrix, 150 rows, 3 columns
x_i <- LazyTensor(x, index = 'i') # creating LazyTensor from matrix x,
# indexed by 'i'
sum_x <- sum(x_i) # LazyTensor object
sum_red_x <- sum(x_i, "i") # sum reduction indexed by 'i'
+\dontshow{
+# clean-up (for CRAN build)
+clean_rkeops(remove_cache_dir = TRUE)
}
-
-\dontrun{
+}
+\donttest{
+\dontshow{
+# Specific setup for example runs (not necessary for standard use)
+reticulate::py_available(initialize = TRUE)
+set_rkeops_options()
+# For build on CRAN, use CPU computing with 2 cores max
+rkeops_use_cpu(ncore = 2)
+}
x <- matrix(runif(150 * 3), 150, 3) # arbitrary R matrix, 150 rows, 3 columns
x_i <- LazyTensor(x, index = 'i') # creating LazyTensor from matrix x,
# indexed by 'i'
sum_reduction(x_i, "i")
+\dontshow{
+# clean-up (for CRAN build)
+clean_rkeops(remove_cache_dir = TRUE)
+}
}
}
\seealso{
diff --git a/rkeops/man/sum.Rd b/rkeops/man/sum.Rd
index 50af4c8af..285fa0137 100644
--- a/rkeops/man/sum.Rd
+++ b/rkeops/man/sum.Rd
@@ -24,10 +24,17 @@ If \code{x} is a \code{LazyTensor}, see \code{\link[=sum.LazyTensor]{sum.LazyTen
\code{\link[=sum.default]{sum.default()}}.
}
\examples{
-\dontrun{
# R base operation
sum(1:10)
sum(c(NA, 1, 2), na.rm = TRUE)
+\donttest{
+\dontshow{
+# Specific setup for example runs (not necessary for standard use)
+reticulate::py_available(initialize = TRUE)
+set_rkeops_options()
+# For build on CRAN, use CPU computing with 2 cores max
+rkeops_use_cpu(ncore = 2)
+}
# LazyTensor operation
x <- matrix(runif(150 * 3), 150, 3) # arbitrary R matrix, 150 rows, 3 columns
x_i <- LazyTensor(x, index = 'i') # creating LazyTensor from matrix x,
@@ -35,6 +42,10 @@ x_i <- LazyTensor(x, index = 'i') # creating LazyTensor from matrix x,
sum_x <- sum(x_i) # LazyTensor object
sum_red_x <- sum(x_i, "i") # sum reduction indexed by 'i'
+\dontshow{
+# clean-up (for CRAN build)
+clean_rkeops(remove_cache_dir = TRUE)
+}
}
}
\author{
diff --git a/rkeops/man/sumsoftmaxweight.Rd b/rkeops/man/sumsoftmaxweight.Rd
index 7dd22a198..9c39b128e 100644
--- a/rkeops/man/sumsoftmaxweight.Rd
+++ b/rkeops/man/sumsoftmaxweight.Rd
@@ -42,7 +42,14 @@ details about this function in the \emph{"RKeOps LazyTensor"} vignette, at
section \emph{"Reductions"}.
}
\examples{
-\dontrun{
+\donttest{
+\dontshow{
+# Specific setup for example runs (not necessary for standard use)
+reticulate::py_available(initialize = TRUE)
+set_rkeops_options()
+# For build on CRAN, use CPU computing with 2 cores max
+rkeops_use_cpu(ncore = 2)
+}
x <- matrix(runif(150 * 3), 150, 3)
x_i <- LazyTensor(x, index = 'i')
y <- matrix(runif(100 * 3), 100, 3)
@@ -53,19 +60,33 @@ S_ij = sum(V_ij^2)
ssmaxweight <- sumsoftmaxweight(S_ij, 'i', V_ij) # sumsoftmaxweight reduction
# over the 'i' indices
+\dontshow{
+# clean-up (for CRAN build)
+clean_rkeops(remove_cache_dir = TRUE)
+}
+}
+\donttest{
+\dontshow{
+# Specific setup for example runs (not necessary for standard use)
+reticulate::py_available(initialize = TRUE)
+set_rkeops_options()
+# For build on CRAN, use CPU computing with 2 cores max
+rkeops_use_cpu(ncore = 2)
}
-\dontrun{
x <- matrix(runif(150 * 3), 150, 3)
x_i <- LazyTensor(x, index = 'i')
y <- matrix(runif(100 * 3), 100, 3)
y_j <- LazyTensor(y, index = 'j')
V_ij <- x_i - y_j # weight matrix
-S_ij = sum(V-ij^2)
+S_ij = sum(V_ij^2)
# sumsoftmaxweight reduction over the 'i' indices
ssmaxw_red <- sumsoftmaxweight_reduction(S_ij, 'i', V_ij)
-
+\dontshow{
+# clean-up (for CRAN build)
+clean_rkeops(remove_cache_dir = TRUE)
+}
}
}
\author{
diff --git a/rkeops/man/tensorprod.Rd b/rkeops/man/tensorprod.Rd
index 7f19db5d7..2dd5510ad 100644
--- a/rkeops/man/tensorprod.Rd
+++ b/rkeops/man/tensorprod.Rd
@@ -24,15 +24,12 @@ symbolically, the tensor product between matrix \code{x} and \code{y}, which is
a symbolic matrix of dimension (\code{nx*ny}, \code{px*py}).
}
\examples{
-\dontrun{
x <- matrix(c(1, 2, 3), 2, 3) # arbitrary R matrix, 150 rows, 3 columns
x_i <- LazyTensor(x, index = 'i') # LazyTensor from matrix x, indexed by 'i'
y <- matrix(c(1, 1, 1), 2, 3) # arbitrary R matrix, 200 rows, 3 columns
y_i <- LazyTensor(y, index = 'i') # LazyTensor from matrix y, indexed by 'i'
-tp_xy <- tensorprod(x_i, y_i) # symbolic (4, 9) matrix.
-
-}
+tp_xy <- tensorprod(x_i, y_i) # symbolic (4, 9) matrix.
}
\author{
Chloe Serre-Combe, Amelie Vernay
diff --git a/rkeops/man/ternaryop.LazyTensor.Rd b/rkeops/man/ternaryop.LazyTensor.Rd
index 3bd5d04b6..588f85160 100644
--- a/rkeops/man/ternaryop.LazyTensor.Rd
+++ b/rkeops/man/ternaryop.LazyTensor.Rd
@@ -39,7 +39,6 @@ An object of class "LazyTensor".
Symbolically applies \code{opstr} operation to \code{x}, \code{y} and \code{z}.
}
\examples{
-\dontrun{
# basic example
D <- 3
M <- 100
@@ -55,7 +54,6 @@ z_i <- LazyTensor(z, index = 'i')
# symbolic matrix:
tern_xyz <- ternaryop.LazyTensor(x_i, y_j, z_i, "IfElse")
}
-}
\author{
Chloe Serre-Combe, Amelie Vernay
}
diff --git a/rkeops/man/unaryop.LazyTensor.Rd b/rkeops/man/unaryop.LazyTensor.Rd
index ae1650fff..de4fe9a4f 100644
--- a/rkeops/man/unaryop.LazyTensor.Rd
+++ b/rkeops/man/unaryop.LazyTensor.Rd
@@ -39,7 +39,6 @@ An object of class "LazyTensor" or "ComplexLazyTensor".
Symbolically applies \code{opstr} operation to \code{x}.
}
\examples{
-\dontrun{
x <- matrix(runif(150 * 3), 150, 3) # arbitrary R matrix, 150 rows, 3 columns
x_i <- LazyTensor(x, index = 'i') # creating LazyTensor from matrix x,
# indexed by 'i'
@@ -49,10 +48,9 @@ una2_x <- unaryop.LazyTensor(x_i, "Pow", opt_arg = 3) # symbolic matrix
# example with not NA dim_res:
## set dim_res to 1 because the "Norm2" operation results on a (symbolic) scalar
-una3_x <- unaryop.LazyTensor(x, "Norm2",
- res_type = "LazyTensor",
- dim_res = 1)
-}
+una3_x <- unaryop.LazyTensor(
+ x_i, "Norm2", res_type = "LazyTensor", dim_res = 1
+)
}
\author{
Chloe Serre-Combe, Amelie Vernay
diff --git a/rkeops/man/vecmatmult.Rd b/rkeops/man/vecmatmult.Rd
index 9effb143b..b6f784a26 100644
--- a/rkeops/man/vecmatmult.Rd
+++ b/rkeops/man/vecmatmult.Rd
@@ -25,7 +25,6 @@ of vector \code{v} and matrix \code{m}.
of dimension 1.
}
\examples{
-\dontrun{
v <- c(1,2,3) # arbitrary R vector of length 3
m <- matrix(runif(150 * 3), 150, 3) # arbitrary R matrix, 150 rows, 3 columns
Pm_v <- LazyTensor(v) # parameter vector LazyTensor from v
@@ -33,7 +32,6 @@ m_i <- LazyTensor(m, index = 'i') # LazyTensor from matrix m, indexed by 'i'
vm_mult <- vecmatmult(Pm_v, m_i) # symbolic matrix
}
-}
\author{
Chloe Serre-Combe, Amelie Vernay
}
diff --git a/rkeops/man/weightedsqdist.Rd b/rkeops/man/weightedsqdist.Rd
index 00b33a8e2..61f856805 100644
--- a/rkeops/man/weightedsqdist.Rd
+++ b/rkeops/man/weightedsqdist.Rd
@@ -34,7 +34,6 @@ details about this function in the \emph{"RKeOps LazyTensor"} vignette, at
section \emph{"Simple vector operations"}.
}
\examples{
-\dontrun{
x <- matrix(runif(100 * 3), 100, 3) # arbitrary R matrix, 100 rows, 3 columns
y <- matrix(runif(100 * 3), 100, 3) # arbitrary R matrix, 100 rows, 3 columns
s <- matrix(runif(100 * 3), 100, 3) # arbitrary R matrix, 100 rows, 3 columns
@@ -48,7 +47,6 @@ s_i <- LazyTensor(s, index = 'i') # creating LazyTensor from matrix s,
wsqd_xy <- weightedsqdist(x_i, y_j, s_i) # symbolic matrix
}
-}
\seealso{
\code{\link[=weightedsqnorm]{weightedsqnorm()}}, \code{\link[=sqdist]{sqdist()}}
}
diff --git a/rkeops/man/weightedsqnorm.Rd b/rkeops/man/weightedsqnorm.Rd
index c3be44836..e8df4af60 100644
--- a/rkeops/man/weightedsqnorm.Rd
+++ b/rkeops/man/weightedsqnorm.Rd
@@ -31,7 +31,6 @@ details about this function in the \emph{"RKeOps LazyTensor"} vignette, at
section \emph{"Simple vector operations"}.
}
\examples{
-\dontrun{
x <- matrix(runif(100 * 3), 100, 3) # arbitrary R matrix, 100 rows, 3 columns
s <- matrix(runif(100 * 3), 100, 3) # arbitrary R matrix, 100 rows, 3 columns
x_i <- LazyTensor(x, index = 'i') # creating LazyTensor from matrix x,
@@ -40,7 +39,6 @@ s_j <- LazyTensor(s, index = 'j') # creating LazyTensor from matrix s,
# indexed by 'j'
wsqn_xy <- weightedsqnorm(x_i, s_j) # symbolic matrix, 100 rows,1 columns
}
-}
\seealso{
\code{\link[=sqnorm2]{sqnorm2()}}, \code{\link[=weightedsqdist]{weightedsqdist()}}
}
diff --git a/rkeops/man/xlogx.LazyTensor.Rd b/rkeops/man/xlogx.LazyTensor.Rd
index 21834c760..9bc7feafe 100644
--- a/rkeops/man/xlogx.LazyTensor.Rd
+++ b/rkeops/man/xlogx.LazyTensor.Rd
@@ -23,13 +23,11 @@ encodes, symbolically, the element-wise \code{x*log(x)} values for \code{x}.
\strong{Note}: by convention \code{xlogx(0)} returns \code{0}.
}
\examples{
-\dontrun{
x <- matrix(runif(150 * 3), 150, 3) # arbitrary R matrix, 150 rows, 3 columns
x_i <- LazyTensor(x, index = 'i') # creating LazyTensor from matrix x,
# indexed by 'i'
xlog_x <- xlogx(x_i) # symbolic matrix, 150 rows and 3 columnsjs
}
-}
\seealso{
\code{\link[=xlogx]{xlogx()}}
}
diff --git a/rkeops/man/xlogx.Rd b/rkeops/man/xlogx.Rd
index 5e5c4244a..95ba9e7cd 100644
--- a/rkeops/man/xlogx.Rd
+++ b/rkeops/man/xlogx.Rd
@@ -25,17 +25,15 @@ else see \code{\link[=xlogx.default]{xlogx.default()}}.
\strong{Note}: by convention \code{xlogx(0)} returns \code{0}.
}
\examples{
-\dontrun{
# Numerical input
-xlog(4)
-xlog(1:10)
+xlogx(4)
+xlogx(1:10)
# LazyTensor symbolic element-wise `x*log(x)`
x <- matrix(runif(150 * 3), 150, 3) # arbitrary R matrix, 150 rows, 3 columns
x_i <- LazyTensor(x, index = 'i') # creating LazyTensor from matrix x,
# indexed by 'i'
xlog_x <- xlogx(x_i) # symbolic matrix, 150 rows and 3 columns
}
-}
\seealso{
\code{\link[=xlogx.default]{xlogx.default()}}, \code{\link[=xlogx.LazyTensor]{xlogx.LazyTensor()}}
}
diff --git a/rkeops/tests/testthat/setup.R b/rkeops/tests/testthat/setup.R
index b84331c8d..124c851f2 100644
--- a/rkeops/tests/testthat/setup.R
+++ b/rkeops/tests/testthat/setup.R
@@ -6,6 +6,7 @@ skip_if_not_installed("fs")
library(checkmate)
library(withr)
library(fs)
+library(stringr)
# helper function to skip tests if Python is not available on the system
skip_if_no_python <- function() {
diff --git a/rkeops/tests/testthat/test-01_install.R b/rkeops/tests/testthat/test-01_py_req.R
similarity index 64%
rename from rkeops/tests/testthat/test-01_install.R
rename to rkeops/tests/testthat/test-01_py_req.R
index eb0f32804..7e4bf77a3 100644
--- a/rkeops/tests/testthat/test-01_install.R
+++ b/rkeops/tests/testthat/test-01_py_req.R
@@ -3,6 +3,7 @@ test_that("install_rkeops", {
withr::with_options(list(rkeops = NULL), {
set_rkeops_options()
- expect_error(install_rkeops(), NA)
+ setup_pyreq()
+ expect_true(reticulate::py_available("pykeops"))
})
})
diff --git a/rkeops/tests/testthat/test-01_starting.R b/rkeops/tests/testthat/test-01_starting.R
deleted file mode 100644
index 3506dc12a..000000000
--- a/rkeops/tests/testthat/test-01_starting.R
+++ /dev/null
@@ -1,3 +0,0 @@
-test_that("helloWorld", {
- expect_output(helloWorld(), "Hello user of KeOps")
-})
diff --git a/rkeops/tests/testthat/test-02_utils.R b/rkeops/tests/testthat/test-02_utils.R
index 11af437be..5a1a081b7 100644
--- a/rkeops/tests/testthat/test-02_utils.R
+++ b/rkeops/tests/testthat/test-02_utils.R
@@ -30,10 +30,16 @@ test_that("random_varname", {
test_that("stat_dir", {
# empty dir
withr::with_tempdir({
- checkmate::expect_string(
- stat_dir(getwd()), pattern = "[0-9]+(.[0-9])*[KMG]?")
+ res <- stat_dir(getwd())
+ checkmate::expect_string(res, pattern = "[0-9]+(.[0-9])*[KMG]?")
+ expect_equal(res, "0")
})
# current dir
checkmate::expect_string(
- stat_dir(getwd()), pattern = "[0-9]+(.[0-9])*[KMG]?")
+ stat_dir(getwd()),
+ pattern = "[0-9]+(.[0-9])*[KMG]?"
+ )
+ # non existing directory
+ expect_warning({res <- stat_dir("/not/existing/dir", warn = TRUE)})
+ expect_equal(res, "0")
})
diff --git a/rkeops/tests/testthat/test-03_rkeops_options.R b/rkeops/tests/testthat/test-03_rkeops_options.R
index ee531b280..2e248f7ef 100644
--- a/rkeops/tests/testthat/test-03_rkeops_options.R
+++ b/rkeops/tests/testthat/test-03_rkeops_options.R
@@ -1,12 +1,13 @@
test_that("def_rkeops_options", {
+ # default options
res <- def_rkeops_options()
expect_equal(class(res), "rkeops_options")
- checkmate::expect_list(res, len = 6)
+ checkmate::expect_list(res, len = 7)
checkmate::expect_set_equal(
names(res),
c("backend", "device_id", "precision", "verbosity", "debug",
- "cache_dir"))
+ "cache_dir", "formula_only"))
checkmate::expect_choice(res$backend, c("CPU", "GPU"))
checkmate::expect_integerish(res$device_id)
checkmate::expect_choice(res$precision, c("float32", "float64"))
@@ -14,16 +15,17 @@ test_that("def_rkeops_options", {
checkmate::expect_choice(res$debug, c(0, 1))
checkmate::expect_directory(res$cache_dir)
+ # modify cache directory
res <- def_rkeops_options(
backend = "CPU", device_id = -1, precision = "float32",
verbosity = FALSE, debug = FALSE, cache_dir = getwd())
expect_equal(class(res), "rkeops_options")
- checkmate::expect_list(res, len = 6)
+ checkmate::expect_list(res, len = 7)
checkmate::expect_set_equal(
names(res),
c("backend", "device_id", "precision", "verbosity", "debug",
- "cache_dir"))
+ "cache_dir", "formula_only"))
checkmate::expect_choice(res$backend, c("CPU", "GPU"))
checkmate::expect_integerish(res$device_id)
checkmate::expect_choice(res$precision, c("float32", "float64"))
@@ -31,12 +33,14 @@ test_that("def_rkeops_options", {
checkmate::expect_choice(res$debug, c(0, 1))
expect_equal(res$cache_dir, getwd())
+ # bad input
expect_error(def_rkeops_options(backend = "TPU"))
expect_error(def_rkeops_options(device_id = 2.5))
expect_error(def_rkeops_options(precision = "integer"))
expect_error(def_rkeops_options(verbosity = "FALSE"))
expect_error(def_rkeops_options(debug = "FALSE"))
- expect_error(def_rkeops_options(cache_dir = "/not/existing/dir"))
+ expect_warning(def_rkeops_options(cache_dir = "/not/existing/dir"))
+ expect_error(def_rkeops_options(formula_only = "TRUE"))
})
test_that("get_rkeops_options", {
@@ -204,6 +208,19 @@ test_that("set_rkeops_cache_dir", {
checkmate::expect_directory(getOption("rkeops")$cache_dir)
expect_equal(getOption("rkeops")$cache_dir, getwd())
})
+
+ withr::with_options(list(rkeops = NULL), {
+ # set options
+ set_rkeops_options()
+ # specific dir
+ expect_warning(set_rkeops_cache_dir(
+ "/not/existing/dir", verbose = FALSE
+ ))
+
+ # check cache dir
+ expect_error(checkmate::expect_directory(getOption("rkeops")$cache_dir))
+ expect_equal(getOption("rkeops")$cache_dir, "/not/existing/dir")
+ })
})
test_that("default_rkeops_cache_dir", {
diff --git a/rkeops/tests/testthat/test-04_keops_setup.R b/rkeops/tests/testthat/test-04_keops_setup.R
index cb8dd788d..7f4d62750 100644
--- a/rkeops/tests/testthat/test-04_keops_setup.R
+++ b/rkeops/tests/testthat/test-04_keops_setup.R
@@ -54,6 +54,7 @@ test_that("setup_pykeops", {
setup_pykeops()
expect_equal(def_pykeops_build_dir(), pykeops$get_build_folder())
expect_equal(
- as.logical(get_rkeops_options("verbosity")), pykeops$verbose)
+ as.logical(get_rkeops_options("verbosity")), pykeops$verbose
+ )
})
})
diff --git a/rkeops/tests/testthat/test-04_keops_utils.R b/rkeops/tests/testthat/test-04_keops_utils.R
index 29fa1d951..14dbfdc77 100644
--- a/rkeops/tests/testthat/test-04_keops_utils.R
+++ b/rkeops/tests/testthat/test-04_keops_utils.R
@@ -1,5 +1,8 @@
test_that("get_pykeops_formula", {
+ formula <- "Sum_Reduction((x|y, 1)"
+ expect_error(res <- get_pykeops_formula(formula))
+
formula <- "Sum_Reduction(Exp(-s * SqNorm2(x - y)) * b, 1)"
res <- get_pykeops_formula(formula)
expect_equal(
diff --git a/rkeops/tests/testthat/test-07_keops_kernel.R b/rkeops/tests/testthat/test-07_keops_kernel.R
index 2cebced8f..d4a90e4ee 100644
--- a/rkeops/tests/testthat/test-07_keops_kernel.R
+++ b/rkeops/tests/testthat/test-07_keops_kernel.R
@@ -3,13 +3,19 @@ test_that("keops_kernel", {
skip_if_no_keopscore()
skip_if_no_pykeops()
+ # clean running env
withr::with_options(list(rkeops = NULL), {
+ # dedicated cache directory for tests
set_rkeops_options(list(cache_dir = testing_cache_dir))
- ## computation on GPU ?
- if(Sys.getenv("TEST_GPU") == "1") rkeops_use_gpu()
+ # setup computing resources (or skip if limited resources)
+ if(Sys.getenv("RUN_LONG_TEST") == "1") {
+ if(Sys.getenv("TEST_GPU") == "1") rkeops_use_gpu()
+ } else {
+ skip("Long tests: not running (e.g. during a package check)")
+ }
- ## use float64 precision in test (to match R precision)
+ # use float64 precision in test (to match R precision)
rkeops_use_float64()
## bad formula
diff --git a/rkeops/tests/testthat/test-08_keops_grad.R b/rkeops/tests/testthat/test-08_keops_grad.R
index 57dfd2bbb..b7383a2c1 100644
--- a/rkeops/tests/testthat/test-08_keops_grad.R
+++ b/rkeops/tests/testthat/test-08_keops_grad.R
@@ -49,13 +49,19 @@ test_that("keops_grad", {
skip_if_no_keopscore()
skip_if_no_pykeops()
+ # clean running env
withr::with_options(list(rkeops = NULL), {
+ # dedicated cache directory for tests
set_rkeops_options(list(cache_dir = testing_cache_dir))
-
- ## computation on GPU ?
- if(Sys.getenv("TEST_GPU") == "1") use_gpu()
- ## use float64 precision in test (to match R precision)
+ # setup computing resources (or skip if limited resources)
+ if(Sys.getenv("RUN_LONG_TEST") == "1") {
+ if(Sys.getenv("TEST_GPU") == "1") rkeops_use_gpu()
+ } else {
+ skip("Long tests: not running (e.g. during a package check)")
+ }
+
+ # use float64 precision in test (to match R precision)
rkeops_use_float64()
## define an operator (squared norm reduction)
diff --git a/rkeops/tests/testthat/test-09_lazytensor_preprocess.R b/rkeops/tests/testthat/test-09_lazytensor_preprocess.R
index 61542458c..7e5fbb4ff 100644
--- a/rkeops/tests/testthat/test-09_lazytensor_preprocess.R
+++ b/rkeops/tests/testthat/test-09_lazytensor_preprocess.R
@@ -2,8 +2,19 @@ skip_if_no_python()
skip_if_no_keopscore()
skip_if_no_pykeops()
+# clean running env
+withr::with_options(list(rkeops = NULL), {
+
+# dedicated cache directory for tests
set_rkeops_options(list(cache_dir = testing_cache_dir))
+# setup computing resources (or skip if limited resources)
+if(Sys.getenv("RUN_LONG_TEST") == "1") {
+ if(Sys.getenv("TEST_GPU") == "1") rkeops_use_gpu()
+} else {
+ skip("Long tests: not running (e.g. during a package check)")
+}
+
# TEST LAZYTENSOR CONFIGURATION ================================================
# Tests for LazyTensor related functions
@@ -973,15 +984,15 @@ test_that("fix_variables", {
expect_equal(fix_variables(l)$formula,
"IntCst(314)")
expect_equal(fix_variables(l + l*l)$formula,
- "IntCst(314)+IntCst(314)*IntCst(314)")
+ "Add(IntCst(314),Mult(IntCst(314),IntCst(314)))")
expect_equal(fix_variables(x_i)$formula,
"V0")
expect_equal(fix_expr1$formula,
- "V0+V1+V0+V2")
+ "Add(Add(Add(V0,V1),V0),V2)")
expect_equal(fix_expr2$formula,
- "Exp(Powf(SqDist(V0,V1),IntCst(314)))-V0*V2")
+ "Subtract(Exp(Powf(SqDist(V0,V1),IntCst(314))),Mult(V0,V2))")
expect_equal(fix_expr3$formula,
- "Norm2(V0)+(V1|V2)*IntCst(314)")
+ "Add(Norm2(V0),Mult((V1|V2),IntCst(314)))")
expect_equal(fix_expr4$formula,
"Clamp(V0,V1,V2)")
@@ -995,9 +1006,11 @@ test_that("fix_variables", {
expect_equal(fix_expr3$args[3], "V2=Vi(3)")
# errors
- expect_error(fix_variables(x),
- "`x` input must be a LazyTensor or a ComplexLazyTensor.",
- fixed = TRUE)
+ expect_error(
+ fix_variables(x),
+ "`x` input must be a LazyTensor or a ComplexLazyTensor.",
+ fixed = TRUE
+ )
})
@@ -1095,3 +1108,5 @@ test_that("cplx_warning", {
cplx_warning(FALSE) # should not produce warning
})
+
+}) # withr::with_options
\ No newline at end of file
diff --git a/rkeops/tests/testthat/test-10_lazytensor_operations.R b/rkeops/tests/testthat/test-10_lazytensor_operations.R
index 62ca9736e..10e51ead4 100644
--- a/rkeops/tests/testthat/test-10_lazytensor_operations.R
+++ b/rkeops/tests/testthat/test-10_lazytensor_operations.R
@@ -2,8 +2,19 @@ skip_if_no_python()
skip_if_no_keopscore()
skip_if_no_pykeops()
+# clean running env
+withr::with_options(list(rkeops = NULL), {
+
+# dedicated cache directory for tests
set_rkeops_options(list(cache_dir = testing_cache_dir))
+# setup computing resources (or skip if limited resources)
+if(Sys.getenv("RUN_LONG_TEST") == "1") {
+ if(Sys.getenv("TEST_GPU") == "1") rkeops_use_gpu()
+} else {
+ skip("Long tests: not running (e.g. during a package check)")
+}
+
# TEST ARITHMETIC OPERATIONS ===================================================
@@ -47,55 +58,59 @@ test_that("+", {
obj <- x_i + y_j
expect_equal(length(obj$args), 2)
expect_equal(length(obj$data), 2)
- bool_grep_formula <- grep("A0x.*i\\+A0x.*j", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(
+ obj$formula, "Add\\(A0x.*i,A0x.*j\\)")
+ expect_equal(bool_grep_formula, TRUE)
expect_warning(obj <- x_i + xc_i)
expect_equal(length(obj$args), 2)
expect_equal(length(obj$data), 2)
- bool_grep_formula <- grep(
- "Add\\(Real2Complex\\(A0x.*i\\),A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(
+ obj$formula, "Add\\(Real2Complex\\(A0x.*i\\),A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
expect_warning(obj <- xc_i + x_i)
expect_equal(length(obj$args), 2)
expect_equal(length(obj$data), 2)
- bool_grep_formula <- grep(
- "Add\\(A0x.*i,Real2Complex\\(A0x.*i\\)\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(
+ obj$formula, "Add\\(A0x.*i,Real2Complex\\(A0x.*i\\)\\)")
+ expect_equal(bool_grep_formula, TRUE)
expect_warning(obj <- xc_i + 3)
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("Add\\(A0x.*i,Real2Complex\\(IntCst\\(3\\)\\)\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(
+ obj$formula, "Add\\(A0x.*i,Real2Complex\\(IntCst\\(3\\)\\)\\)")
+ expect_equal(bool_grep_formula, TRUE)
expect_warning(obj <- 3 + xc_i)
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep(
- "Add\\(Real2Complex\\(IntCst\\(3\\)\\),A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(
+ obj$formula, "Add\\(Real2Complex\\(IntCst\\(3\\)\\),A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- x_i + 3
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("A0x.*i\\+IntCst\\(3\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(
+ obj$formula, "Add\\(A0x.*i,IntCst\\(3\\)\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- 3.14 + x_i
expect_equal(length(obj$args), 2)
expect_equal(length(obj$data), 2)
- bool_grep_formula <- grep("A0x.*NA\\+A0x.*i", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Add\\(A0x.*NA,A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
# errors
expect_error(
x_i + z_j,
- paste(
- "Operation `+` expects inputs of the same dimension or dimension 1.",
- " Received 3 and 7.",
- sep = ""
+ str_c(
+ "Operation `Add` expects inputs of the same dimension",
+ "or dimension 1.",
+ "Received 3 and 7.",
+ sep = " "
),
fixed = TRUE
)
@@ -142,65 +157,67 @@ test_that("-", {
obj <- x_i - y_j
expect_equal(length(obj$args), 2)
expect_equal(length(obj$data), 2)
- bool_grep_formula <- grep("A0x.*i-A0x.*j", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Subtract\\(A0x.*i,A0x.*j\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- xc_i - yc_j
expect_equal(length(obj$args), 2)
expect_equal(length(obj$data), 2)
- bool_grep_formula <- grep("Subtract\\(A0x.*i,A0x.*j\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Subtract\\(A0x.*i,A0x.*j\\)")
+ expect_equal(bool_grep_formula, TRUE)
expect_warning(obj <- xc_i - y_j)
expect_equal(length(obj$args), 2)
expect_equal(length(obj$data), 2)
- bool_grep_formula <- grep(
- "Subtract\\(A0x.*i,Real2Complex\\(A0x.*j\\)\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(
+ obj$formula, "Subtract\\(A0x.*i,Real2Complex\\(A0x.*j\\)\\)")
+ expect_equal(bool_grep_formula, TRUE)
expect_warning(obj <- x_i - yc_j)
- bool_grep_formula <- grep(
- "Subtract\\(Real2Complex\\(A0x.*i\\),A0x.*j\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(
+ obj$formula, "Subtract\\(Real2Complex\\(A0x.*i\\),A0x.*j\\)")
+ expect_equal(bool_grep_formula, TRUE)
expect_warning(obj <- xc_i - 3)
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep(
- "Subtract\\(A0x.*i,Real2Complex\\(IntCst\\(3\\)\\)\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(
+ obj$formula, "Subtract\\(A0x.*i,Real2Complex\\(IntCst\\(3\\)\\)\\)")
+ expect_equal(bool_grep_formula, TRUE)
expect_warning(obj <- 3.3 - xc_i)
expect_equal(length(obj$args), 2)
expect_equal(length(obj$data), 2)
- bool_grep_formula <- grep(
- "Subtract\\(Real2Complex\\(A0x.*NA\\),A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(
+ obj$formula, "Subtract\\(Real2Complex\\(A0x.*NA\\),A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- x_i - 3
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("A0x.*i-IntCst\\(3\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(
+ obj$formula, "Subtract\\(A0x.*i,IntCst\\(3\\)\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- -x_i
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("Minus\\(A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Minus\\(A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- 3.14 - x_i
expect_equal(length(obj$args), 2)
expect_equal(length(obj$data), 2)
- bool_grep_formula <- grep("A0x.*NA-A0x.*i", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(
+ obj$formula, "Subtract\\(A0x.*NA,A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
# errors
expect_error(
x_i - z_j,
- paste(
- "Operation `-` expects inputs of the same dimension or dimension 1.",
- " Received 3 and 7.", sep = ""
+ str_c(
+ "Operation `Subtract` expects inputs of the same dimension",
+ "or dimension 1. Received 3 and 7.", sep = " "
),
fixed = TRUE
)
@@ -246,74 +263,77 @@ test_that("*", {
obj <- x_i * y_j
expect_equal(length(obj$args), 2)
expect_equal(length(obj$data), 2)
- bool_grep_formula <- grep("A0x.*i\\*A0x.*j", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Mult\\(A0x.*i,A0x.*j\\)")
+ expect_equal(bool_grep_formula, TRUE)
expect_warning(obj <- x_i * xc_i)
expect_equal(length(obj$args), 2)
expect_equal(length(obj$data), 2)
- bool_grep_formula <- grep(
- "ComplexMult\\(Real2Complex\\(A0x.*i\\),A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(
+ obj$formula, "ComplexMult\\(Real2Complex\\(A0x.*i\\),A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
expect_warning(obj <- xc_i * x_i)
expect_equal(length(obj$args), 2)
expect_equal(length(obj$data), 2)
- bool_grep_formula <- grep(
- "ComplexMult\\(A0x.*i,Real2Complex\\(A0x.*i\\)\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(
+ obj$formula, "ComplexMult\\(A0x.*i,Real2Complex\\(A0x.*i\\)\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- xc_i * Pm(2i)
expect_equal(length(obj$args), 2)
expect_equal(length(obj$data), 2)
- bool_grep_formula <- grep("ComplexScal\\(A0x.*i,A0x.*NA\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(
+ obj$formula, "ComplexScal\\(A0x.*i,A0x.*NA\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- Pm(2i) * xc_i
expect_equal(length(obj$args), 2)
expect_equal(length(obj$data), 2)
- bool_grep_formula <- grep("ComplexScal\\(A0x.*NA,A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(
+ obj$formula, "ComplexScal\\(A0x.*NA,A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- xc_i * Pm(2)
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep(
- "ComplexRealScal\\(A0x.*i,IntCst\\(2\\)\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(
+ obj$formula, "ComplexRealScal\\(A0x.*i,IntCst\\(2\\)\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- xc_i * 2
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep(
- "ComplexRealScal\\(A0x.*i,IntCst\\(2\\)\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(
+ obj$formula, "ComplexRealScal\\(A0x.*i,IntCst\\(2\\)\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- 2 * xc_i
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep(
- "ComplexRealScal\\(IntCst\\(2\\),A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(
+ obj$formula, "ComplexRealScal\\(IntCst\\(2\\),A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
- obj <- x_i * 3
+ obj <- x_i * 3L
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("A0x.*i\\*+IntCst\\(3\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(
+ obj$formula, "Mult\\(A0x.*i,IntCst\\(3\\)\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- 3.14 * x_i
expect_equal(length(obj$args), 2)
expect_equal(length(obj$data), 2)
- bool_grep_formula <- grep("A0x.*NA\\*A0x.*i", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Mult\\(A0x.*NA,A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
# errors
expect_error(
x_i * z_j,
paste(
- "Operation `*` expects inputs of the same dimension or dimension 1.",
- " Received 3 and 7.", sep = ""
+ "Operation `Mult` expects inputs of the same dimension",
+ "or dimension 1. Received 3 and 7.", sep = " "
),
fixed = TRUE
)
@@ -360,59 +380,58 @@ test_that("/", {
obj <- x_i / y_j
expect_equal(length(obj$args), 2)
expect_equal(length(obj$data), 2)
- bool_grep_formula <- grep("A0x.*i/A0x.*j", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Divide\\(A0x.*i,A0x.*j\\)")
+ expect_equal(bool_grep_formula, TRUE)
expect_warning(obj <- xc_i / y_j)
expect_equal(length(obj$args), 2)
expect_equal(length(obj$data), 2)
- bool_grep_formula <- grep(
- "ComplexDivide\\(A0x.*i,Real2Complex\\(A0x.*j\\)\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(
+ obj$formula, "ComplexDivide\\(A0x.*i,Real2Complex\\(A0x.*j\\)\\)")
+ expect_equal(bool_grep_formula, TRUE)
expect_warning(obj <- y_j / xc_i)
expect_equal(length(obj$args), 2)
expect_equal(length(obj$data), 2)
- bool_grep_formula <- grep(
- "ComplexDivide\\(Real2Complex\\(A0x.*j\\),A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(
+ obj$formula, "ComplexDivide\\(Real2Complex\\(A0x.*j\\),A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
expect_warning(obj <- yc_j / 3)
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep(
- "ComplexDivide\\(A0x.*j,Real2Complex\\(IntCst\\(3\\)\\)\\)",
- obj$formula
+ bool_grep_formula <- str_detect(
+ obj$formula,
+ "ComplexDivide\\(A0x.*j,Real2Complex\\(IntCst\\(3\\)\\)\\)"
)
- expect_equal(bool_grep_formula, 1)
+ expect_equal(bool_grep_formula, TRUE)
expect_warning(obj <- 3 / xc_i)
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep(
- "ComplexDivide\\(Real2Complex\\(IntCst\\(3\\)\\),A0x.*i\\)",
- obj$formula
- )
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(
+ obj$formula, "ComplexDivide\\(Real2Complex\\(IntCst\\(3\\)\\),A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- x_i / 3
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("A0x.*i/IntCst\\(3\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(
+ obj$formula, "Divide\\(A0x.*i,IntCst\\(3\\)\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- 3.14 / x_i
expect_equal(length(obj$args), 2)
expect_equal(length(obj$data), 2)
- bool_grep_formula <- grep("A0x.*NA/A0x.*i", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Divide\\(A0x.*NA,A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
# errors
expect_error(
x_i / z_j,
paste(
- "Operation `/` expects inputs of the same dimension or dimension 1.",
- " Received 3 and 7.", sep = ""
+ "Operation `Divide` expects inputs of the same dimension",
+ "or dimension 1. Received 3 and 7.", sep = " "
),
fixed = TRUE
)
@@ -453,44 +472,44 @@ test_that("^", {
obj <- x_i^y_j
expect_equal(length(obj$args), 2)
expect_equal(length(obj$data), 2)
- bool_grep_formula <- grep("Powf\\(A0x.*i,A0x.*j\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Powf\\(A0x.*i,A0x.*j\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- x_i^3
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("Pow\\(A0x.*i,3\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Pow\\(A0x.*i,3\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- x_i^(-0.5)
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("Rsqrt\\(A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Rsqrt\\(A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- x_i^(0.5)
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("Sqrt\\(A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Sqrt\\(A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- y_j^2
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("Square\\(A0x.*j\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Square\\(A0x.*j\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- x_i^0.314
expect_equal(length(obj$args), 2)
expect_equal(length(obj$data), 2)
- bool_grep_formula <- grep("Powf\\(A0x.*i,A0x.*NA\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Powf\\(A0x.*i,A0x.*NA\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- 3.14^x_i
expect_equal(length(obj$args), 2)
expect_equal(length(obj$data), 2)
- bool_grep_formula <- grep("Powf\\(A0x.*NA,A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Powf\\(A0x.*NA,A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
})
@@ -517,8 +536,8 @@ test_that("square", {
obj <- square(x_i)
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("Square\\(A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Square\\(A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
})
@@ -545,8 +564,8 @@ test_that("sqrt", {
obj <- sqrt(x_i)
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("Sqrt\\(A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Sqrt\\(A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
})
@@ -573,8 +592,8 @@ test_that("rsqrt", {
obj <- rsqrt(x_i)
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("Rsqrt\\(A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Rsqrt\\(A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
})
@@ -617,8 +636,8 @@ test_that("|", {
obj <- x_i | y_j
expect_equal(length(obj$args), 2)
expect_equal(length(obj$data), 2)
- bool_grep_formula <- grep("\\(A0x.*i\\|A0x.*j\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "\\(A0x.*i\\|A0x.*j\\)")
+ expect_equal(bool_grep_formula, TRUE)
# errors
expect_error(
@@ -663,20 +682,21 @@ test_that("exp", {
obj <- exp(x_i)
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("Exp\\(A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Exp\\(A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- exp(x_i - y_j)
expect_equal(length(obj$args), 2)
expect_equal(length(obj$data), 2)
- bool_grep_formula <- grep("Exp\\(A0x.*i-A0x.*j\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(
+ obj$formula, "Exp\\(Subtract\\(A0x.*i,A0x.*j\\)\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- exp(z_i)
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("ComplexExp\\(A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "ComplexExp\\(A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
})
@@ -709,20 +729,21 @@ test_that("log", {
obj <- log(x_i)
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("Log\\(A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Log\\(A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- log(x_i - y_j)
expect_equal(length(obj$args), 2)
expect_equal(length(obj$data), 2)
- bool_grep_formula <- grep("Log\\(A0x.*i-A0x.*j\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(
+ obj$formula, "Log\\(Subtract\\(A0x.*i,A0x.*j\\)\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- log(z_i)
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("Log\\(A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Log\\(A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
})
@@ -755,20 +776,21 @@ test_that("inv", {
obj <- inv(x_i)
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("Inv\\(A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Inv\\(A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- inv(x_i + y_j)
expect_equal(length(obj$args), 2)
expect_equal(length(obj$data), 2)
- bool_grep_formula <- grep("Inv\\(A0x.*i\\+A0x.*j\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(
+ obj$formula, "Inv\\(Add\\(A0x.*i,A0x.*j\\)\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- inv(z_i)
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("Inv\\(A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Inv\\(A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
})
@@ -801,20 +823,21 @@ test_that("cos", {
obj <- cos(x_i)
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("Cos\\(A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Cos\\(A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- cos(x_i + y_j)
expect_equal(length(obj$args), 2)
expect_equal(length(obj$data), 2)
- bool_grep_formula <- grep("Cos\\(A0x.*i\\+A0x.*j\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(
+ obj$formula, "Cos\\(Add\\(A0x.*i,A0x.*j\\)\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- cos(z_i)
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("Cos\\(A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Cos\\(A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
})
@@ -847,20 +870,21 @@ test_that("sin", {
obj <- sin(x_i)
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("Sin\\(A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Sin\\(A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- sin(x_i + y_j)
expect_equal(length(obj$args), 2)
expect_equal(length(obj$data), 2)
- bool_grep_formula <- grep("Sin\\(A0x.*i\\+A0x.*j\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(
+ obj$formula, "Sin\\(Add\\(A0x.*i,A0x.*j\\)\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- sin(z_i)
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("Sin\\(A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Sin\\(A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
})
@@ -893,14 +917,15 @@ test_that("acos", {
obj <- acos(x_i)
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("Acos\\(A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Acos\\(A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- acos(x_i + y_j)
expect_equal(length(obj$args), 2)
expect_equal(length(obj$data), 2)
- bool_grep_formula <- grep("Acos\\(A0x.*i\\+A0x.*j\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(
+ obj$formula, "Acos\\(Add\\(A0x.*i,A0x.*j\\)\\)")
+ expect_equal(bool_grep_formula, TRUE)
})
@@ -931,14 +956,15 @@ test_that("asin", {
obj <- asin(x_i)
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("Asin\\(A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Asin\\(A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- asin(x_i + y_j)
expect_equal(length(obj$args), 2)
expect_equal(length(obj$data), 2)
- bool_grep_formula <- grep("Asin\\(A0x.*i\\+A0x.*j\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(
+ obj$formula, "Asin\\(Add\\(A0x.*i,A0x.*j\\)\\)")
+ expect_equal(bool_grep_formula, TRUE)
})
@@ -968,14 +994,15 @@ test_that("atan", {
obj <- atan(x_i)
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("Atan\\(A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Atan\\(A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- atan(x_i + y_j)
expect_equal(length(obj$args), 2)
expect_equal(length(obj$data), 2)
- bool_grep_formula <- grep("Atan\\(A0x.*i\\+A0x.*j\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(
+ obj$formula, "Atan\\(Add\\(A0x.*i,A0x.*j\\)\\)")
+ expect_equal(bool_grep_formula, TRUE)
})
@@ -1010,8 +1037,8 @@ test_that("atan2", {
obj <- atan2(x_i, y_j)
expect_equal(length(obj$args), 2)
expect_equal(length(obj$data), 2)
- bool_grep_formula <- grep("Atan2\\(A0x.*i,A0x.*j\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Atan2\\(A0x.*i,A0x.*j\\)")
+ expect_equal(bool_grep_formula, TRUE)
# errors
expect_error(atan2(x_i, z_j),
@@ -1103,20 +1130,20 @@ test_that("abs", {
obj <- abs(x_i)
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("Abs\\(A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Abs\\(A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- abs(-y_j)
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("Abs\\(Minus\\(A0x.*j\\)\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Abs\\(Minus\\(A0x.*j\\)\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- abs(-xc_i)
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("ComplexAbs\\(Minus\\(A0x.*i\\)\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "ComplexAbs\\(Minus\\(A0x.*i\\)\\)")
+ expect_equal(bool_grep_formula, TRUE)
})
@@ -1146,14 +1173,14 @@ test_that("sign", {
obj <- sign(x_i)
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("Sign\\(A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Sign\\(A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- sign(-y_j)
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("Sign\\(Minus\\(A0x.*j\\)\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Sign\\(Minus\\(A0x.*j\\)\\)")
+ expect_equal(bool_grep_formula, TRUE)
})
@@ -1185,20 +1212,20 @@ test_that("round", {
obj <- round(x_i, 3)
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("Round\\(A0x.*i,3\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Round\\(A0x.*i,3\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- round(y_j, 3.14)
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("Round\\(A0x.*j,3.14\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Round\\(A0x.*j,3.14\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- round(Pm(3), 3)
expect_null(obj$args)
expect_null(obj$data)
- bool_grep_formula <- grep("Round\\(IntCst\\(.*\\),3\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Round\\(IntCst\\(.*\\),3\\)")
+ expect_equal(bool_grep_formula, TRUE)
# errors
expect_error(round(x_i, x),
@@ -1237,14 +1264,14 @@ test_that("xlogx", {
obj <- xlogx(x_i)
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("XLogX\\(A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "XLogX\\(A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- xlogx(Pm(3))
expect_null(obj$args)
expect_null(obj$data)
- bool_grep_formula <- grep("XLogX\\(IntCst\\(.*\\)\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "XLogX\\(IntCst\\(.*\\)\\)")
+ expect_equal(bool_grep_formula, TRUE)
})
@@ -1274,14 +1301,14 @@ test_that("sinxdivx", {
obj <- sinxdivx(x_i)
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("SinXDivX\\(A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "SinXDivX\\(A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- sinxdivx(Pm(3))
expect_null(obj$args)
expect_null(obj$data)
- bool_grep_formula <- grep("SinXDivX\\(IntCst\\(.*\\)\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "SinXDivX\\(IntCst\\(.*\\)\\)")
+ expect_equal(bool_grep_formula, TRUE)
})
@@ -1310,14 +1337,14 @@ test_that("step", {
obj <- step(x_i)
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("Step\\(A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Step\\(A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- step(Pm(2))
expect_null(obj$args)
expect_null(obj$data)
- bool_grep_formula <- grep("Step\\(IntCst\\(.*\\)\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Step\\(IntCst\\(.*\\)\\)")
+ expect_equal(bool_grep_formula, TRUE)
})
@@ -1346,14 +1373,14 @@ test_that("relu", {
obj <- relu(x_i)
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("ReLU\\(A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "ReLU\\(A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- relu(LazyTensor(4))
expect_null(obj$args)
expect_null(obj$data)
- bool_grep_formula <- grep("ReLU\\(IntCst\\(.*\\)\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "ReLU\\(IntCst\\(.*\\)\\)")
+ expect_equal(bool_grep_formula, TRUE)
})
@@ -1382,29 +1409,29 @@ test_that("clamp", {
expect_true(is.LazyTensor(obj))
expect_equal(length(obj$args), 3)
expect_equal(length(obj$data), 3)
- bool_grep_formula <- grep("Clamp\\(A0x.*i,A0x.*j,A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Clamp\\(A0x.*i,A0x.*j,A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- clamp(x_i, y_j, 3)
expect_true(is.LazyTensor(obj))
expect_equal(length(obj$args), 2)
expect_equal(length(obj$data), 2)
- bool_grep_formula <- grep("Clamp\\(A0x.*i,A0x.*j,IntCst\\(3\\)\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Clamp\\(A0x.*i,A0x.*j,IntCst\\(3\\)\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- clamp(2, y_j, 3)
expect_true(is.LazyTensor(obj))
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("Clamp\\(IntCst\\(2\\),A0x.*j,IntCst\\(3\\)\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Clamp\\(IntCst\\(2\\),A0x.*j,IntCst\\(3\\)\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- clamp(x_i, 2, 3)
expect_true(is.LazyTensor(obj))
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("ClampInt\\(A0x.*i,2,3\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "ClampInt\\(A0x.*i,2,3\\)")
+ expect_equal(bool_grep_formula, TRUE)
# errors
expect_error(
@@ -1461,15 +1488,15 @@ test_that("clampint", {
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
expect_s3_class(obj, "LazyTensor")
- bool_grep_formula <- grep("ClampInt\\(A0x.*i,6,8\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "ClampInt\\(A0x.*i,6,8\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- clampint(1, 6, 8)
expect_null(obj$args)
expect_null(obj$data)
expect_s3_class(obj, "LazyTensor")
- bool_grep_formula <- grep("ClampInt\\(IntCst\\(1\\),6,8\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "ClampInt\\(IntCst\\(1\\),6,8\\)")
+ expect_equal(bool_grep_formula, TRUE)
# errors
@@ -1538,22 +1565,22 @@ test_that("ifelse", {
obj <- ifelse(x_i, y_j, z_i)
expect_equal(length(obj$args), 3)
expect_equal(length(obj$data), 3)
- bool_grep_formula <- grep("IfElse\\(A0x.*i,A0x.*j,A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "IfElse\\(A0x.*i,A0x.*j,A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
expect_s3_class(obj, "LazyTensor")
obj <- ifelse(x_i, y_j, 3)
expect_equal(length(obj$args), 2)
expect_equal(length(obj$data), 2)
- bool_grep_formula <- grep("IfElse\\(A0x.*i,A0x.*j,IntCst\\(3\\)\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "IfElse\\(A0x.*i,A0x.*j,IntCst\\(3\\)\\)")
+ expect_equal(bool_grep_formula, TRUE)
expect_s3_class(obj, "LazyTensor")
obj <- ifelse(x_i, 2, 3)
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("IfElse\\(A0x.*i,IntCst\\(2\\),IntCst\\(3\\)\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "IfElse\\(A0x.*i,IntCst\\(2\\),IntCst\\(3\\)\\)")
+ expect_equal(bool_grep_formula, TRUE)
expect_s3_class(obj, "LazyTensor")
# errors
@@ -1610,51 +1637,50 @@ test_that("mod", {
obj <- mod(x_i, y_j, z_i)
expect_equal(length(obj$args), 3)
expect_equal(length(obj$data), 3)
- bool_grep_formula <- grep("Mod\\(A0x.*i,A0x.*j,A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Mod\\(A0x.*i,A0x.*j,A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
expect_s3_class(obj, "LazyTensor")
obj <- mod(xc_i, yc_j, zc_i)
expect_equal(length(obj$args), 3)
expect_equal(length(obj$data), 3)
- bool_grep_formula <- grep("Mod\\(A0x.*i,A0x.*j,A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Mod\\(A0x.*i,A0x.*j,A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
expect_s3_class(obj, "ComplexLazyTensor")
obj <- mod(x_i, yc_j, zc_i)
expect_equal(length(obj$args), 3)
expect_equal(length(obj$data), 3)
- bool_grep_formula <- grep("Mod\\(A0x.*i,A0x.*j,A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Mod\\(A0x.*i,A0x.*j,A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
expect_s3_class(obj, "ComplexLazyTensor")
obj <- mod(xc_i, y_j, z_i)
expect_equal(length(obj$args), 3)
expect_equal(length(obj$data), 3)
- bool_grep_formula <- grep("Mod\\(A0x.*i,A0x.*j,A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Mod\\(A0x.*i,A0x.*j,A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
expect_s3_class(obj, "ComplexLazyTensor")
obj <- mod(x_i, y_j, 3)
expect_equal(length(obj$args), 2)
expect_equal(length(obj$data), 2)
- bool_grep_formula <- grep("Mod\\(A0x.*i,A0x.*j,IntCst\\(3\\)\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Mod\\(A0x.*i,A0x.*j,IntCst\\(3\\)\\)")
+ expect_equal(bool_grep_formula, TRUE)
expect_s3_class(obj, "LazyTensor")
obj <- mod(x_i, 2, 3)
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("Mod\\(A0x.*i,IntCst\\(2\\),IntCst\\(3\\)\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Mod\\(A0x.*i,IntCst\\(2\\),IntCst\\(3\\)\\)")
+ expect_equal(bool_grep_formula, TRUE)
expect_s3_class(obj, "LazyTensor")
obj <- mod(x_i, 2)
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("Mod\\(A0x.*i,IntCst\\(2\\),IntCst\\(0\\)\\)",
- obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Mod\\(A0x.*i,IntCst\\(2\\),IntCst\\(0\\)\\)")
+ expect_equal(bool_grep_formula, TRUE)
expect_s3_class(obj, "LazyTensor")
# errors
@@ -1691,8 +1717,8 @@ test_that("sqnorm2", {
obj <- sqnorm2(x_i)
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("SqNorm2\\(A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "SqNorm2\\(A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
})
@@ -1714,8 +1740,8 @@ test_that("norm2", {
obj <- norm2(x_i)
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("Norm2\\(A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Norm2\\(A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
})
@@ -1736,8 +1762,8 @@ test_that("normalize", {
obj <- normalize(x_i)
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("Normalize\\(A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Normalize\\(A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
})
@@ -1778,14 +1804,14 @@ test_that("sqdist", {
obj <- sqdist(x_i, y_j)
expect_equal(length(obj$args), 2)
expect_equal(length(obj$data), 2)
- bool_grep_formula <- grep("SqDist\\(A0x.*i,A0x.*j\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "SqDist\\(A0x.*i,A0x.*j\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- sqdist(x_i, 3)
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("SqDist\\(A0x.*i,IntCst\\(3\\)\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "SqDist\\(A0x.*i,IntCst\\(3\\)\\)")
+ expect_equal(bool_grep_formula, TRUE)
# errors
expect_error(
@@ -1823,14 +1849,14 @@ test_that("weightedsqnorm", {
obj <- weightedsqnorm(x_i, s_j)
expect_equal(length(obj$args), 2)
expect_equal(length(obj$data), 2)
- bool_grep_formula <- grep("WeightedSqNorm\\(A0x.*j,A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "WeightedSqNorm\\(A0x.*j,A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- weightedsqnorm(x_i, 3)
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("WeightedSqNorm\\(IntCst\\(3\\),A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "WeightedSqNorm\\(IntCst\\(3\\),A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
})
@@ -1869,32 +1895,33 @@ test_that("weightedsqdist", {
obj <- weightedsqdist(x_i, y_j, s_i)
expect_equal(length(obj$args), 3)
expect_equal(length(obj$data), 3)
- bool_grep_formula <- grep("WeightedSqNorm\\(A0x.*i,A0x.*i-A0x.*j\\)",
- obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(
+ obj$formula, "WeightedSqNorm\\(A0x.*i,Subtract\\(A0x.*i,A0x.*j\\)\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- weightedsqdist(x_i, 2, s_i)
expect_equal(length(obj$args), 2)
expect_equal(length(obj$data), 2)
- bool_grep_formula <- grep("WeightedSqNorm\\(A0x.*i,A0x.*i-IntCst\\(2\\)\\)",
- obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(
+ obj$formula,
+ "WeightedSqNorm\\(A0x.*i,Subtract\\(A0x.*i,IntCst\\(2\\)\\)\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- weightedsqdist(x_i, y_j, 3)
expect_equal(length(obj$args), 2)
expect_equal(length(obj$data), 2)
- bool_grep_formula <- grep("WeightedSqNorm\\(IntCst\\(3\\),A0x.*i-A0x.*j\\)",
- obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(
+ obj$formula,
+ "WeightedSqNorm\\(IntCst\\(3\\),Subtract\\(A0x.*i,A0x.*j\\)\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- weightedsqdist(x_i, 2, 3)
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep(
- "WeightedSqNorm\\(IntCst\\(3\\),A0x.*i-IntCst\\(2\\)\\)",
- obj$formula
- )
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(
+ obj$formula,
+ "WeightedSqNorm\\(IntCst\\(3\\),Subtract\\(A0x.*i,IntCst\\(2\\)\\)\\)")
+ expect_equal(bool_grep_formula, TRUE)
})
@@ -1933,13 +1960,17 @@ test_that("Re", {
obj <- Re(z_i)
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("ComplexReal\\(A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "ComplexReal\\(A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
expect_s3_class(obj, "LazyTensor")
expect_error(
Re(x_i),
- "`Re` cannot be applied to a LazyTensor. See `?Re` for compatible types.",
+ str_c(
+ "`Re` cannot be applied to a LazyTensor.",
+ "See `?Re` for compatible types.",
+ sep = " "
+ ),
fixed = TRUE
)
@@ -1975,13 +2006,17 @@ test_that("Im", {
obj <- Im(z_i)
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("ComplexImag\\(A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "ComplexImag\\(A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
expect_s3_class(obj, "LazyTensor")
expect_error(
- Im(x_i),
- "`Im` cannot be applied to a LazyTensor. See `?Im` for compatible types.",
+ Im(x_i),
+ str_c(
+ "`Im` cannot be applied to a LazyTensor.",
+ "See `?Im` for compatible types.",
+ sep = " "
+ ),
fixed = TRUE
)
@@ -2017,14 +2052,18 @@ test_that("Arg", {
obj <- Arg(z_i)
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("ComplexAngle\\(A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "ComplexAngle\\(A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
expect_s3_class(obj, "LazyTensor")
# error
expect_error(
- Arg(x_i),
- "`Arg` cannot be applied to a LazyTensor. See `?Arg` for compatible types.",
+ Arg(x_i),
+ str_c(
+ "`Arg` cannot be applied to a LazyTensor.",
+ "See `?Arg` for compatible types.",
+ sep = " "
+ ),
fixed = TRUE
)
@@ -2046,16 +2085,16 @@ test_that("real2complex", {
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
expect_equal(obj$dimres, x_i$dimres)
- bool_grep_formula <- grep("Real2Complex\\(A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Real2Complex\\(A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
expect_s3_class(obj, "ComplexLazyTensor")
expect_warning(obj <- real2complex(Pm(2)))
expect_null(obj$args)
expect_null(obj$data)
expect_equal(obj$dimres, 1)
- bool_grep_formula <- grep("Real2Complex\\(IntCst\\(2\\)\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Real2Complex\\(IntCst\\(2\\)\\)")
+ expect_equal(bool_grep_formula, TRUE)
expect_s3_class(obj, "ComplexLazyTensor")
# errors
@@ -2083,16 +2122,16 @@ test_that("imag2complex", {
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
expect_equal(obj$dimres, x_i$dimres)
- bool_grep_formula <- grep("Imag2Complex\\(A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Imag2Complex\\(A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
expect_s3_class(obj, "ComplexLazyTensor")
obj <- imag2complex(Pm(2))
expect_null(obj$args)
expect_null(obj$data)
expect_equal(obj$dimres, 1)
- bool_grep_formula <- grep("Imag2Complex\\(IntCst\\(2\\)\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Imag2Complex\\(IntCst\\(2\\)\\)")
+ expect_equal(bool_grep_formula, TRUE)
expect_s3_class(obj, "ComplexLazyTensor")
expect_error(imag2complex(xc_i),
@@ -2116,8 +2155,8 @@ test_that("exp1j", {
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
expect_equal(obj$dimres, x_i$dimres)
- bool_grep_formula <- grep("ComplexExp1j\\(A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "ComplexExp1j\\(A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
expect_s3_class(obj, "ComplexLazyTensor")
expect_error(exp1j(xc_i),
@@ -2152,8 +2191,8 @@ test_that("Conj", {
expect_s3_class(obj, "ComplexLazyTensor")
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
- bool_grep_formula <- grep("Conj\\(A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Conj\\(A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- Conj(1 + 2i)
expect_equal(obj, 1 - 2i)
@@ -2194,8 +2233,8 @@ test_that("Mod", {
expect_equal(obj$dimres, 3)
expect_true(is.LazyTensor(obj))
expect_false(is.ComplexLazyTensor(obj))
- bool_grep_formula <- grep("ComplexAbs\\(A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "ComplexAbs\\(A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
})
@@ -2216,13 +2255,13 @@ test_that("elem", {
# check formulas, args & classes
obj <- elem(x_i, m)
expect_true(is.LazyTensor(obj))
- bool_grep_formula <- grep("Elem\\(A0x.*i,2\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Elem\\(A0x.*i,2\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- elem(Pm_int, 0)
expect_true(is.LazyTensor(obj))
- bool_grep_formula <- grep("Elem\\(IntCst\\(5\\),0\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Elem\\(IntCst\\(5\\),0\\)")
+ expect_equal(bool_grep_formula, TRUE)
expect_null <- obj$args
expect_null <- obj$data
expect_equal(obj$dimres, 1)
@@ -2264,19 +2303,19 @@ test_that("elemT", {
# check formulas, args & classes
obj <- elemT(Pm_x, m, n)
expect_true(is.LazyTensor(obj))
- bool_grep_formula <- grep("ElemT\\(A0x.*NA,3,2\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "ElemT\\(A0x.*NA,3,2\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- elemT(Pm_z, m, n)
expect_true(is.LazyTensor(obj))
expect_true(is.ComplexLazyTensor(obj))
- bool_grep_formula <- grep("ElemT\\(A0x.*NA,3,2\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "ElemT\\(A0x.*NA,3,2\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- elemT(Pm_int, 5, 7)
expect_true(is.LazyTensor(obj))
- bool_grep_formula <- grep("ElemT\\(IntCst\\(4\\),7,5\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "ElemT\\(IntCst\\(4\\),7,5\\)")
+ expect_equal(bool_grep_formula, TRUE)
expect_null <- obj$args
expect_null <- obj$data
expect_equal(obj$dimres, 1)
@@ -2319,18 +2358,18 @@ test_that("extract", {
# check formulas, args & classes
obj <- extract(x_i, m, d)
expect_true(is.LazyTensor(obj))
- bool_grep_formula <- grep("Extract\\(A0x.*i,1,3\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Extract\\(A0x.*i,1,3\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- extract(Pm_v, 0, d)
expect_true(is.LazyTensor(obj))
- bool_grep_formula <- grep("Extract\\(A0x.*NA,0,3\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Extract\\(A0x.*NA,0,3\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- extract(Pm_int, 0, 1)
expect_true(is.LazyTensor(obj))
- bool_grep_formula <- grep("Extract\\(IntCst\\(2\\),0,1\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Extract\\(IntCst\\(2\\),0,1\\)")
+ expect_equal(bool_grep_formula, TRUE)
expect_null <- obj$args
expect_null <- obj$data
expect_equal(obj$dimres, 1)
@@ -2376,18 +2415,18 @@ test_that("extractT", {
# check formulas, args & classes
obj <- extractT(x_i, m, d)
expect_true(is.LazyTensor(obj))
- bool_grep_formula <- grep("ExtractT\\(A0x.*i,1,8\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "ExtractT\\(A0x.*i,1,8\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- extractT(Pm_v, 0, d)
expect_true(is.LazyTensor(obj))
- bool_grep_formula <- grep("ExtractT\\(A0x.*NA,0,8\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "ExtractT\\(A0x.*NA,0,8\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- extractT(Pm_int, 0, d)
expect_true(is.LazyTensor(obj))
- bool_grep_formula <- grep("ExtractT\\(IntCst\\(2\\),0,8\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "ExtractT\\(IntCst\\(2\\),0,8\\)")
+ expect_equal(bool_grep_formula, TRUE)
expect_null <- obj$args
expect_null <- obj$data
expect_equal(obj$dimres, 1)
@@ -2428,8 +2467,8 @@ test_that("concat", {
obj <- concat(x_i, y_j)
expect_true(is.LazyTensor(obj))
- bool_grep_formula <- grep("Concat\\(A0x.*i,A0x.*j\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Concat\\(A0x.*i,A0x.*j\\)")
+ expect_equal(bool_grep_formula, TRUE)
res <- sum(concat(x_i,y_j), "i")
expected_res <- rep(1:2, each = 3)
@@ -2447,13 +2486,14 @@ test_that("concat", {
# check formulas, args & classes
obj <- concat(x_i, y_j)
expect_true(is.LazyTensor(obj))
- bool_grep_formula <- grep("Concat\\(A0x.*i,A0x.*j\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Concat\\(A0x.*i,A0x.*j\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj <- concat(x_i, Pm_int)
expect_true(is.LazyTensor(obj))
- bool_grep_formula <- grep("Concat\\(A0x.*i,IntCst\\(5\\)\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(
+ obj$formula, "Concat\\(A0x.*i,IntCst\\(5\\)\\)")
+ expect_equal(bool_grep_formula, TRUE)
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
expect_equal(obj$dimres, 4)
@@ -2478,16 +2518,16 @@ test_that("one_hot", {
# check formulas, args & classes
obj <- one_hot(LT_s, D)
expect_true(is.LazyTensor(obj))
- bool_grep_formula <- grep("OneHot\\(IntCst\\(13\\),7\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "OneHot\\(IntCst\\(13\\),7\\)")
+ expect_equal(bool_grep_formula, TRUE)
expect_null <- obj$args
expect_null <- obj$data
expect_equal(obj$dimres, 7)
obj <- one_hot(LT_dec, D)
expect_true(is.LazyTensor(obj))
- bool_grep_formula <- grep("OneHot\\(A0x.*NA,7\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "OneHot\\(A0x.*NA,7\\)")
+ expect_equal(bool_grep_formula, TRUE)
expect_equal(length(obj$args), 1)
expect_equal(length(obj$data), 1)
expect_equal(obj$dimres, 7)
@@ -2528,15 +2568,13 @@ test_that("matvecmult", {
# check formulas, args & classes
obj <- matvecmult(m_i, Pm_v)
expect_true(is.LazyTensor(obj))
- bool_grep_formula <- grep("MatVecMult\\(A0x.*i,A0x.*NA\\)",
- obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "MatVecMult\\(A0x.*i,A0x.*NA\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj_Pm_one <- matvecmult(m_i, Pm_one)
expect_true(is.LazyTensor(obj_Pm_one))
- bool_grep_formula <- grep("MatVecMult\\(A0x.*i,A0x.*NA\\)",
- obj_Pm_one$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj_Pm_one$formula, "MatVecMult\\(A0x.*i,A0x.*NA\\)")
+ expect_equal(bool_grep_formula, TRUE)
# check dimres
expect_equal(obj$dimres, 1)
@@ -2578,15 +2616,13 @@ test_that("vecmatmult", {
# check formulas, args & classes
obj <- vecmatmult(Pm_v, m_i)
expect_true(is.LazyTensor(obj))
- bool_grep_formula <- grep("VecMatMult\\(A0x.*NA,A0x.*i\\)",
- obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "VecMatMult\\(A0x.*NA,A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
obj_Pm_one <- vecmatmult(Pm_one, m_i)
expect_true(is.LazyTensor(obj_Pm_one))
- bool_grep_formula <- grep("VecMatMult\\(A0x.*NA,A0x.*i\\)",
- obj_Pm_one$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj_Pm_one$formula, "VecMatMult\\(A0x.*NA,A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
# check dimres
expect_equal(obj$dimres, 1)
@@ -2630,8 +2666,8 @@ test_that("tensorprod", {
expect_true(is.LazyTensor(obj))
expect_false(is.ComplexLazyTensor(obj))
expect_equal(obj$dimres, 9)
- bool_grep_formula <- grep("TensorProd\\(A0x.*i,A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "TensorProd\\(A0x.*i,A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
})
@@ -2763,11 +2799,11 @@ test_that("sum", {
expect_equal(as.vector(res), expected_res, tolerance = 1E-5)
# check formulae
- bool_grep_formula <- grep("Sum\\(A0x.*NA\\)", sum(Pm_v)$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(sum(Pm_v)$formula, "Sum\\(A0x.*NA\\)")
+ expect_equal(bool_grep_formula, TRUE)
- bool_grep_formula <- grep("ComplexSum\\(A0x.*NA\\)", sum(Pm_complex)$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(sum(Pm_complex)$formula, "ComplexSum\\(A0x.*NA\\)")
+ expect_equal(bool_grep_formula, TRUE)
# errors
expect_error(sum(x_i, "b"),
@@ -2871,8 +2907,8 @@ test_that("min", {
# checks when there is no reduction
obj <- min(x_i)
expect_true(is.LazyTensor(obj))
- bool_grep_formula <- grep("Min\\(A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Min\\(A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
# errors
expect_error(min(x_i, "b"),
@@ -2940,8 +2976,8 @@ test_that("argmin", {
obj <- argmin(x_i)
expect_true(is.LazyTensor(obj))
- bool_grep_formula <- grep("ArgMin\\(A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "ArgMin\\(A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
# errors
expect_error(argmin(3, "i"),
@@ -3106,8 +3142,8 @@ test_that("max", {
# when there is no reduction
obj <- max(x_i)
expect_true(is.LazyTensor(obj))
- bool_grep_formula <- grep("Max\\(A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "Max\\(A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
# errors
expect_error(max(x_i, "b"),
@@ -3163,8 +3199,8 @@ test_that("argmax", {
obj <- argmax(x_i)
expect_true(is.LazyTensor(obj))
- bool_grep_formula <- grep("ArgMax\\(A0x.*i\\)", obj$formula)
- expect_equal(bool_grep_formula, 1)
+ bool_grep_formula <- str_detect(obj$formula, "ArgMax\\(A0x.*i\\)")
+ expect_equal(bool_grep_formula, TRUE)
# errors
expect_error(argmax(3, "i"),
@@ -3690,7 +3726,7 @@ test_that("logsumexp", {
V_ij <- x_i - y_j
S_ij <- sum(V_ij^2)
- expect_error(logsumexp(sum(V_ij), 'i', w_j))
+ expect_error(logsumexp(S_ij, 'i', w_j))
res <- logsumexp(S_ij, 'i')
expect_false(is.LazyTensor(res))
@@ -3827,10 +3863,10 @@ test_that("sumsoftmaxweight", {
x_i <- LazyTensor(x, index = 'i')
y <- matrix(runif(100 * 3), 100, 3)
y_j <- LazyTensor(y, index = 'j')
-
+
V_ij <- x_i - y_j # weight matrix
S_ij = sum(V_ij^2)
-
+
res <- sumsoftmaxweight(S_ij, 'i', V_ij)
expect_false(is.LazyTensor(res))
expect_true(is.matrix(res))
@@ -3946,7 +3982,7 @@ test_that("grad", {
expect_error(
grad(sqnorm2(x_i - y_j), eta_i, "Sum", var = 0, 1),
- paste0("`index` input argument should be a character, either 'i' or 'j'."),
+ "`index` input argument should be a character, either 'i' or 'j'.",
fixed = TRUE
)
@@ -3957,3 +3993,5 @@ test_that("grad", {
)
})
+
+}) # withr::with_options
diff --git a/rkeops/vignettes/Kernel_Interpolation_rkeops.Rmd b/rkeops/vignettes/Kernel_Interpolation_rkeops.Rmd
index 47c53fe23..219d0be71 100644
--- a/rkeops/vignettes/Kernel_Interpolation_rkeops.Rmd
+++ b/rkeops/vignettes/Kernel_Interpolation_rkeops.Rmd
@@ -27,7 +27,7 @@ knitr::opts_chunk$set(
```
```{r requirement, include=FALSE}
-required <- c("ggplot2", "dplyr", "pracma", "plotly", "reshape")
+required <- c("ggplot2", "dplyr", "pracma", "plotly", "reshape", "withr")
sapply(
required,
function(pkg) {
@@ -49,14 +49,6 @@ library(reshape) # matrix to data.frame reformatting
```{r init, message=FALSE, warning=FALSE, results='hide', eval=FALSE}
# load rkeops
library(rkeops)
-# create a dedicated Python environment with reticulate (!!to be done only once)
-reticulate::virtualenv_create("rkeops")
-# activate the dedicated Python environment
-reticulate::use_virtualenv(virtualenv = "rkeops", required = TRUE)
-# install rkeops requirements (!!to be done only once)
-install_rkeops()
-# use 64bit floating operation precision
-rkeops_use_float64()
```
```{r safe_init, message=FALSE, warning=FALSE, results='hide', include=FALSE}
@@ -64,24 +56,15 @@ rkeops_use_float64()
library(rkeops)
tryCatch({
- # create a dedicated Python environment with reticulate (to be done only once)
- reticulate::virtualenv_create("rkeops")
- # activate the dedicated Python environment
- reticulate::use_virtualenv(virtualenv = "rkeops", required = TRUE)
-
# check Python availability
- if(reticulate::py_available(initialize = TRUE)) {
- # install rkeops requirements (to be done only once)
- install_rkeops()
- } else {
+ if(!reticulate::py_available(initialize = TRUE)) {
knitr::opts_chunk$set(eval = FALSE)
}
}, error = function(e) {knitr::opts_chunk$set(eval = FALSE)})
-
```
```{r}
-# check rkeops install
+# check rkeops setup
check_rkeops()
# use 64bit floating operation precision
@@ -94,13 +77,13 @@ if(!check_rkeops(verbose = FALSE)) {
}
```
-For build on CRAN, use CPU computing with 2 cores:
-```{r limit_cpu_usage}
+```{r limit_cpu_usage, include=FALSE}
+# For build on CRAN, use CPU computing with 2 cores max
rkeops_use_cpu(ncore = 2)
```
```{r cleanup, include=FALSE}
-# cleanup afterward
+# cleanup afterward (especially for CRAN build)
withr::defer(clean_rkeops(verbose = FALSE, remove_cache_dir = TRUE))
```
@@ -306,7 +289,7 @@ mean_t <- mean_t[nrow(mean_t):1, ]
data2plot_sample <- data.frame(
X = x[,1],
Y = x[,2],
- value = b
+ value = b[,1]
)
ggplot(data2plot_sample, aes(x = X, y = Y, col = value)) +
diff --git a/rkeops/vignettes/LazyTensor_rkeops.Rmd b/rkeops/vignettes/LazyTensor_rkeops.Rmd
index 42429249d..f5d3e065b 100644
--- a/rkeops/vignettes/LazyTensor_rkeops.Rmd
+++ b/rkeops/vignettes/LazyTensor_rkeops.Rmd
@@ -31,12 +31,8 @@ knitr::opts_chunk$set(
```{r}
# load rkeops
library(rkeops)
-# create a dedicated Python environment with reticulate (!!to be done only once)
-reticulate::virtualenv_create("rkeops")
-# activate the dedicated Python environment
-reticulate::use_virtualenv(virtualenv = "rkeops", required = TRUE)
-# install rkeops requirements (!!to be done only once)
-install_rkeops()
+# check rkeops setup
+check_rkeops()
```
@@ -142,7 +138,7 @@ Pm_v_z <- LazyTensor(v_z, is_complex = TRUE)
Pm_v_z$data
## [[1]]
## [,1] [,2] [,3] [,4] [,5] [,6]
-## [1,] 4 5 2 3 7 1
+## [1,] 4 5 2 3 7 1
```
Of course if you create a vector or a matrix of real values, and
@@ -350,9 +346,9 @@ The operations `sum()`, `min()`, `argmin()`, `max()` and `argmax()` can be calle
Here, `x` is a `LazyTensor` of inner dimension $D$ and outer dimension $M$, indexed by $i \in \{1, \ldots ,M\}$, and `y` is a `LazyTensor` of inner dimension $D$ and outer dimension $N$, indexed by $j \in \{1, \ldots ,N\}$.
-| operation | meaning | mathematical expression |
-|:----------|:----------------------------------------------------------------------------------------------------|:------------------------------------------------|
-|`x %*% y` | sum reduction of the product `x` * `y` indexed by `j`.
Same as `sum_reduction(x * y, "j")` | $\sum_j x_{ik} y_{jk}, ~ k \in \{1, \ldots, N\}$ |
+| operation | meaning | mathematical expression |
+|:----------|:----------------------------------------------------------------------------------------------------|:-------------------------------------------------|
+|`x %*% y` | sum reduction of the product `x` * `y` indexed by `j`.
Same as `sum_reduction(x * y, "j")` | $\sum_j x_{ik} y_{jk}, ~ k \in \{1, \ldots, N\}$ |
## Advices and random notes
diff --git a/rkeops/vignettes/introduction_to_rkeops.Rmd b/rkeops/vignettes/introduction_to_rkeops.Rmd
index 97f6ed33e..6afc99cd1 100644
--- a/rkeops/vignettes/introduction_to_rkeops.Rmd
+++ b/rkeops/vignettes/introduction_to_rkeops.Rmd
@@ -35,9 +35,9 @@ a report on our [GitHub issue tracker](https://github.com/getkeops/keops/issues)
**Core library - KeOps, PyKeOps, KeOpsLab:**
-- [Benjamin Charlier](https://imag.umontpellier.fr/~charlier/), from the University of Montpellier.
+- [Benjamin Charlier](https://miat.inrae.fr/bcharlier/), from the University of Montpellier.
- [Jean Feydy](https://www.jeanfeydy.com), from Inria.
-- [Joan Alexis Glaunès](http://helios.mi.parisdescartes.fr/~glaunes/), from the University of Paris.
+- [Joan Alexis Glaunès](https://helios2.mi.parisdescartes.fr/~glaunes/), from the University of Paris.
**R bindings - RKeOps:**
@@ -47,11 +47,11 @@ a report on our [GitHub issue tracker](https://github.com/getkeops/keops/issues)
**Contributors:**
-- [François-David Collin](https://github.com/fradav), from the University of Montpellier: Tensordot operation, CI setup.
+- [François-David Collin](https://fradav.perso.math.cnrs.fr/), from the University of Montpellier: Tensordot operation, CI setup.
- [Tanguy Lefort](https://github.com/tanglef), from the University of Montpellier: conjugate gradient solver.
- [Mauricio Diaz](https://github.com/mdiazmel), from Inria of Paris: CI setup.
- [Benoît Martin](https://github.com/benoitmartin88), from the Aramis Inria team: multi-GPU support.
-- [Francis Williams](https://www.fwilliams.info), from New York University: maths operations.
+- [Francis Williams](https://fwilliams.info/), from New York University: maths operations.
- [Kshiteej Kalambarkar](https://github.com/kshitij12345), from Quansight: maths operations.
- [D. J. Sutherland](https://djsutherland.ml), from the TTI-Chicago: bug fix in the Python package.
- [David Völgyes](https://scholar.google.no/citations?user=ngT2GvMAAAAJ&hl=en), from the Norwegian Institute of Science and Technology: bug fix in the formula parser.
@@ -154,15 +154,11 @@ remotes::install_github("getkeops/keops", subdir = "rkeops")
```{r}
# load rkeops
library(rkeops)
-# create a dedicated Python environment with reticulate (!!to be done only once)
-reticulate::virtualenv_create("rkeops")
-# activate the dedicated Python environment
-reticulate::use_virtualenv(virtualenv = "rkeops", required = TRUE)
-# install rkeops requirements (!!to be done only once)
-install_rkeops()
+# check rkeops setup
+check_rkeops()
```
-For more details, see the specific **"Using RKeOps" [article](https://www.kernel-operations.io/rkeops/articles/using_rkeops.html)** or the corresponding vignette:
+**Important:** for more details (especially in case of problems), see the specific **"Using RKeOps" [article](https://www.kernel-operations.io/rkeops/articles/using_rkeops.html)** or the corresponding vignette:
```{r}
vignette("using_rkeops", package = "rkeops")
```
diff --git a/rkeops/vignettes/using_rkeops.Rmd b/rkeops/vignettes/using_rkeops.Rmd
index c5470a7c6..a2e6b72c9 100644
--- a/rkeops/vignettes/using_rkeops.Rmd
+++ b/rkeops/vignettes/using_rkeops.Rmd
@@ -33,11 +33,35 @@ Thanks to RKeOps, you can use **GPU computing directly inside R** without the co
* R (tested with R >= 4.2)
* C++ compiler (g++ >=7 or clang) for CPU computing or CUDA compiler (nvcc >=10) and CUDA libs for GPU computing
-* Python (>= 3.10)
+* Python (>= 3.10), c.f. [next section](#note-on-python-requirement)
+
+**Disclaimer:** KeOps (including RKeOps) is not functional on Windows, it was only tested on Linux and MacOS.
**Important:** Python is a requirement as an intern machinery for the package to work but you will not need to create nor manipulate Python codes to use the RKeOps package.
-**Disclaimer:** KeOps (including RKeOps) is not functional on Windows, it was only tested on Linux and MacOS.
+### Note on Python requirement
+
+RKeOps now uses PyKeOps Python package under the hood thanks to the [`reticulate`](https://rstudio.github.io/reticulate/) R package that provides an “R Interface to Python”.
+
+Everything related to Python, including the installation of the required Python version and required Python packages, should be automatically managed with `reticulate`. It should be transparent for the user.
+
+#### Troubleshooting
+
+In case of trouble with `reticulate` not being able to setup the Python configuration, you can try the following workaround:
+
+- install the development version of `reticulate`:
+```{r}
+remotes::install_github("rstudio/reticulate")
+```
+
+- check if `reticulate` is able to setup a Python environment:
+```{r, eval=FALSE}
+unlink(tools::R_user_dir("reticulate", "cache"), recursive = TRUE)
+Sys.setenv("_RETICULATE_DEBUG_UV_" = "1")
+library(reticulate)
+py_require(python_version="3.12")
+py_config()
+```
## Install from CRAN
@@ -58,49 +82,23 @@ install.packages("remotes")
remotes::install_github("getkeops/keops", subdir = "rkeops")
```
-## Setup and requirement install
-
-**To be done once after installation:**
-
-```{r install_requirements}
-# load rkeops
-library(rkeops)
-# create a dedicated Python environment with reticulate (!!to be done only once)
-reticulate::virtualenv_create("rkeops")
-# activate the dedicated Python environment
-reticulate::use_virtualenv(virtualenv = "rkeops", required = TRUE)
-# install rkeops requirements (!!to be done only once)
-install_rkeops()
-```
-
-### Note on Python requirement
-
-RKeOps now uses PyKeOps Python package under the hood thanks to the [`reticulate`](https://rstudio.github.io/reticulate/) R package that provides an “R Interface to Python”.
-
-We recommend to use a dedicated Python environment (through `reticulate`) to install and use RKeOps Python dependencies (c.f. [previously](#setup-and-requirement-install)).
-
-> **Note:** To get more information about **managing** which **version of Python** you are using, you can refer to `reticulate` [documentation](https://rstudio.github.io/reticulate/articles/versions.html) about “Python Version Configuration”. In particular, if you are a Miniconda/Anaconda Python distribution user, you can either user a Python virtual environment (c.f. above) or a **Conda environment** with the same results. Please refer to the `reticulate` [documentation](https://rstudio.github.io/reticulate/articles/versions.html#providing-hints) in this case.
-
---
# How to use RKeOps
-Load RKeOps in R:
+RKeOps allows to define and compile new operators that run computations on GPU or on CPU with the exact same code.
+
+## Loading
+
+Load RKeOps in R and verify that it is working:
```{r setup}
# load rkeops
library(rkeops)
-# activate the dedicated Python environment
-reticulate::use_virtualenv(virtualenv = "rkeops", required = TRUE)
-```
-
-**Note**: If you are using a Python environment (c.f. [previously](#note-on-python-requirement)), you should always activate it after loading RKeOps.
-
-You can verify that every thing is ok:
-```{r check}
+# check rkeops setup
check_rkeops()
```
-RKeOps allows to define and compile new operators that run computations on GPU.
+**Note:** in case, the previous call does not return `TRUE`, you may need to force `reticulate` initialization by calling `reticulate::py_config()`.
## LazyTensors