Skip to content

Commit

Permalink
Merge pull request #124 from symengine/fix/cran-issue
Browse files Browse the repository at this point in the history
fix cran check issues and bump version
  • Loading branch information
Marlin-Na committed Feb 24, 2024
2 parents dc87644 + 0f5fe3e commit c573238
Show file tree
Hide file tree
Showing 14 changed files with 83 additions and 67 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: symengine
Title: Interface to the 'SymEngine' Library
Version: 0.2.2
Version: 0.2.4
Authors@R: c(person("Jialin", "Ma", email="marlin@inventati.org", role = c("cre", "aut")),
person("Isuru", "Fernando", email="isuruf@gmail.com", role = c("aut")),
person("Xin", "Chen", email="xinchen.tju@gmail.com", role = c("aut")))
Expand Down Expand Up @@ -39,7 +39,7 @@ License: GPL (>= 2)
Copyright: The R package bundles the 'SymEngine' library source and its subcomponents
under 'src/upstream' directory. See file COPYRIGHTS for retained copyright notices
as a relicensing and redistribution requirement.
RoxygenNote: 7.1.2
RoxygenNote: 7.2.3
Collate:
'RcppExports.R'
'basic-getinfo.R'
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ S3method(as.function,BasicOrVecBasic)
S3method(as.matrix,DenseMatrix)
S3method(cbind,SymEngineDataType)
S3method(rbind,SymEngineDataType)
S3method(rep,Basic)
S3method(rep,VecBasic)
S3method(unique,VecBasic)
export(Basic)
export(Constant)
Expand Down
29 changes: 9 additions & 20 deletions R/vector.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,27 +79,16 @@ setMethod("length", "VecBasic",
)

#' @rdname vecbasic-bindings
setMethod("rep", c(x = "VecBasic"),
function(x, ...)
s4binding_subset(x, rep(seq_len(length(x)), ...), get_basic = FALSE)
)
#' @export
rep.VecBasic <- function(x, ...) {
s4binding_subset(x, rep(seq_len(length(x)), ...), get_basic = FALSE)
}

#' @rdname vecbasic-bindings
setMethod("rep", c(x = "Basic"),
function(x, ...)
s4binding_subset(x, rep(1L, ...), get_basic = FALSE)
)
setMethod("rep_len", c(x = "VecBasic"),
function(x, length.out) rep(x, length.out = length.out)
)
setMethod("rep_len", c(x = "Basic"),
function(x, length.out) rep(x, length.out = length.out)
)
setMethod("rep.int", c(x = "VecBasic"),
function(x, times) rep(x, times = times)
)
setMethod("rep.int", c(x = "Basic"),
function(x, times) rep(x, times = times)
)
#' @export
rep.Basic <- function(x, ...) {
s4binding_subset(x, rep(1L, ...), get_basic = FALSE)
}

#' @rdname vecbasic-bindings
#' @export
Expand Down
1 change: 0 additions & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ knitr::opts_chunk$set(

<!-- badges: start -->
[![R-CMD-check](https://github.com/symengine/symengine.R/workflows/R-CMD-check/badge.svg)](https://github.com/symengine/symengine.R/actions)
[![Travis-CI Build Status](https://travis-ci.org/symengine/symengine.R.svg?branch=master)](https://travis-ci.org/symengine/symengine.R)
[![AppVeyor Build status](https://ci.appveyor.com/api/projects/status/rr0tdh8ykvs04qg2?svg=true)](https://ci.appveyor.com/project/symengine/symengine-r)
<!-- badges: end -->

Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
<!-- badges: start -->

[![R-CMD-check](https://github.com/symengine/symengine.R/workflows/R-CMD-check/badge.svg)](https://github.com/symengine/symengine.R/actions)
[![Travis-CI Build
Status](https://travis-ci.org/symengine/symengine.R.svg?branch=master)](https://travis-ci.org/symengine/symengine.R)
[![AppVeyor Build
status](https://ci.appveyor.com/api/projects/status/rr0tdh8ykvs04qg2?svg=true)](https://ci.appveyor.com/project/symengine/symengine-r)
<!-- badges: end -->
Expand Down
27 changes: 20 additions & 7 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,18 @@ if test -z "$R_CXX"; then
echo >&2 "could not detect C++ compiler with R CMD config"
fi

echo == setting cmake environment variables
echo == setting environment variables for cmake

CC="$R_CC" ; echo setting CC="$CC" ; export CC
CXX="$R_CXX" ; echo setting CXX="$CXX" ; export CXX

echo == translating to cmake variables

CMAKE_C_FLAGS="$R_CFLAGS $R_CPICFLAGS" ; echo setting CMAKE_C_FLAGS="$CMAKE_C_FLAGS"
CMAKE_CXX_FLAGS="$R_CXXFLAGS $R_CXXPICFLAGS" ; echo setting CMAKE_CXX_FLAGS="$CMAKE_CXX_FLAGS"
CMAKE_INCLUDE_PATH=`"${R_HOME}/bin/Rscript" ./tools/translate_to_cmake_flags.R CMAKE_INCLUDE_PATH "$R_CPPFLAGS"` ; echo setting CMAKE_INCLUDE_PATH="$CMAKE_INCLUDE_PATH"
CMAKE_LIBRARY_PATH=`"${R_HOME}/bin/Rscript" ./tools/translate_to_cmake_flags.R CMAKE_LIBRARY_PATH "$R_LDFLAGS"` ; echo setting CMAKE_LIBRARY_PATH="$CMAKE_LIBRARY_PATH"

CMAKE_C_COMPILER="$R_CC" ; echo setting CMAKE_C_COMPILER="$CMAKE_C_COMPILER" ; export CMAKE_C_COMPILER="$CMAKE_C_COMPILER"
CMAKE_C_FLAGS="$R_CFLAGS $R_CPICFLAGS" ; echo setting CMAKE_C_FLAGS="$CMAKE_C_FLAGS" ; export CMAKE_C_FLAGS="$CMAKE_C_FLAGS"
CMAKE_CXX_COMPILER="$R_CXX" ; echo setting CMAKE_CXX_COMPILER="$CMAKE_CXX_COMPILER" ; export CMAKE_CXX_COMPILER="$CMAKE_CXX_COMPILER"
CMAKE_CXX_FLAGS="$R_CXXFLAGS $R_CXXPICFLAGS" ; echo setting CMAKE_CXX_FLAGS="$CMAKE_CXX_FLAGS" ; export CMAKE_CXX_FLAGS="$CMAKE_CXX_FLAGS"
CMAKE_INCLUDE_PATH=`"${R_HOME}/bin/Rscript" ./tools/translate_to_cmake_flags.R CMAKE_INCLUDE_PATH "$R_CPPFLAGS"` ; echo setting CMAKE_INCLUDE_PATH="$CMAKE_INCLUDE_PATH" ; export CMAKE_INCLUDE_PATH="$CMAKE_INCLUDE_PATH"
CMAKE_LIBRARY_PATH=`"${R_HOME}/bin/Rscript" ./tools/translate_to_cmake_flags.R CMAKE_LIBRARY_PATH "$R_LDFLAGS"` ; echo setting CMAKE_LIBRARY_PATH="$CMAKE_LIBRARY_PATH" ; export CMAKE_LIBRARY_PATH="$CMAKE_LIBRARY_PATH"

## Use ./tools/SYMENGINE_BUNDLED file as indicator so that
## this won't run on CRAN machine.
Expand Down Expand Up @@ -101,11 +105,18 @@ if [ -z "$SymEngine_DIR" ]; then

PKG_DIR=`pwd`
cd src/upstream

set -x

$CMAKE_BIN \
-DCMAKE_AR=$AR \
-DCMAKE_RANLIB=$RANLIB \
\
-DCMAKE_C_FLAGS="$CMAKE_C_FLAGS" \
-DCMAKE_CXX_FLAGS="$CMAKE_CXX_FLAGS" \
-DCMAKE_INCLUDE_PATH="$CMAKE_INCLUDE_PATH" \
-DCMAKE_LIBRARY_PATH="$CMAKE_LIBRARY_PATH" \
\
-DCMAKE_BUILD_TYPE=Release \
-DWITH_BFD=no \
-DWITH_SYMENGINE_ASSERT=no \
Expand All @@ -129,6 +140,8 @@ if [ -z "$SymEngine_DIR" ]; then
if [ $? -ne 0 ]; then
exit 1
fi

set +x

cd $PKG_DIR

Expand Down
27 changes: 20 additions & 7 deletions configure.win
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,18 @@ if test -z "$R_CXX"; then
echo >&2 "could not detect C++ compiler with R CMD config"
fi

echo == setting cmake environment variables
echo == setting environment variables for cmake

CC="$R_CC" ; echo setting CC="$CC" ; export CC
CXX="$R_CXX" ; echo setting CXX="$CXX" ; export CXX

echo == translating to cmake variables

CMAKE_C_FLAGS="$R_CFLAGS $R_CPICFLAGS" ; echo setting CMAKE_C_FLAGS="$CMAKE_C_FLAGS"
CMAKE_CXX_FLAGS="$R_CXXFLAGS $R_CXXPICFLAGS" ; echo setting CMAKE_CXX_FLAGS="$CMAKE_CXX_FLAGS"
CMAKE_INCLUDE_PATH=`"${R_HOME}/bin/Rscript" ./tools/translate_to_cmake_flags.R CMAKE_INCLUDE_PATH "$R_CPPFLAGS"` ; echo setting CMAKE_INCLUDE_PATH="$CMAKE_INCLUDE_PATH"
CMAKE_LIBRARY_PATH=`"${R_HOME}/bin/Rscript" ./tools/translate_to_cmake_flags.R CMAKE_LIBRARY_PATH "$R_LDFLAGS"` ; echo setting CMAKE_LIBRARY_PATH="$CMAKE_LIBRARY_PATH"

CMAKE_C_COMPILER="$R_CC" ; echo setting CMAKE_C_COMPILER="$CMAKE_C_COMPILER" ; export CMAKE_C_COMPILER="$CMAKE_C_COMPILER"
CMAKE_C_FLAGS="$R_CFLAGS $R_CPICFLAGS" ; echo setting CMAKE_C_FLAGS="$CMAKE_C_FLAGS" ; export CMAKE_C_FLAGS="$CMAKE_C_FLAGS"
CMAKE_CXX_COMPILER="$R_CXX" ; echo setting CMAKE_CXX_COMPILER="$CMAKE_CXX_COMPILER" ; export CMAKE_CXX_COMPILER="$CMAKE_CXX_COMPILER"
CMAKE_CXX_FLAGS="$R_CXXFLAGS $R_CXXPICFLAGS" ; echo setting CMAKE_CXX_FLAGS="$CMAKE_CXX_FLAGS" ; export CMAKE_CXX_FLAGS="$CMAKE_CXX_FLAGS"
CMAKE_INCLUDE_PATH=`"${R_HOME}/bin/Rscript" ./tools/translate_to_cmake_flags.R CMAKE_INCLUDE_PATH "$R_CPPFLAGS"` ; echo setting CMAKE_INCLUDE_PATH="$CMAKE_INCLUDE_PATH" ; export CMAKE_INCLUDE_PATH="$CMAKE_INCLUDE_PATH"
CMAKE_LIBRARY_PATH=`"${R_HOME}/bin/Rscript" ./tools/translate_to_cmake_flags.R CMAKE_LIBRARY_PATH "$R_LDFLAGS"` ; echo setting CMAKE_LIBRARY_PATH="$CMAKE_LIBRARY_PATH" ; export CMAKE_LIBRARY_PATH="$CMAKE_LIBRARY_PATH"

## Use ./tools/SYMENGINE_BUNDLED file as indicator so that
## this won't run on CRAN machine.
Expand Down Expand Up @@ -101,11 +105,18 @@ if [ -z "$SymEngine_DIR" ]; then

PKG_DIR=`pwd`
cd src/upstream

set -x

$CMAKE_BIN \
-DCMAKE_AR=$AR \
-DCMAKE_RANLIB=$RANLIB \
\
-DCMAKE_C_FLAGS="$CMAKE_C_FLAGS" \
-DCMAKE_CXX_FLAGS="$CMAKE_CXX_FLAGS" \
-DCMAKE_INCLUDE_PATH="$CMAKE_INCLUDE_PATH" \
-DCMAKE_LIBRARY_PATH="$CMAKE_LIBRARY_PATH" \
\
-DCMAKE_BUILD_TYPE=Release \
-DWITH_BFD=no \
-DWITH_SYMENGINE_ASSERT=no \
Expand All @@ -129,6 +140,8 @@ if [ -z "$SymEngine_DIR" ]; then
if [ $? -ne 0 ]; then
exit 1
fi

set +x

cd $PKG_DIR

Expand Down
6 changes: 4 additions & 2 deletions man/symengine.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions man/vecbasic-bindings.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions src/Makevars.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@

CXX_STD = CXX11

PKG_LIBS = @@@PKG_LIBS@@@

PKG_CPPFLAGS = @@@PKG_CPPFLAGS@@@
Expand Down
33 changes: 14 additions & 19 deletions src/rbinding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,35 +26,30 @@ static_assert(std::alignment_of<CRCPBasic>::value
// Some cwrapper helpers ///////////

// Exception handling
const char* cwrapper_exception_message(CWRAPPER_OUTPUT_TYPE id) {
static
void cwrapper_hold(CWRAPPER_OUTPUT_TYPE output) {
if (!output) return;

// Refer:
// https://github.com/symengine/symengine/blob/master/symengine/symengine_exception.h
switch(id) {
switch(output) {
case SYMENGINE_NO_EXCEPTION:
return "SymEngine exception: No exception, it should not go here";
Rf_error("SymEngine exception: No exception, it should not go here");
case SYMENGINE_RUNTIME_ERROR:
return "SymEngine exception: Runtime error";
Rf_error("SymEngine exception: Runtime error");
case SYMENGINE_DIV_BY_ZERO:
return "SymEngine exception: Div by zero";
Rf_error("SymEngine exception: Div by zero");
case SYMENGINE_NOT_IMPLEMENTED:
return "SymEngine exception: Not implemented SymEngine feature";
Rf_error("SymEngine exception: Not implemented SymEngine feature");
case SYMENGINE_DOMAIN_ERROR:
return "SymEngine exception: Domain error";
Rf_error("SymEngine exception: Domain error");
case SYMENGINE_PARSE_ERROR:
return "SymEngine exception: Parse error";
Rf_error("SymEngine exception: Parse error");
default:
return "SymEngine exception: Unexpected SymEngine error code";
Rf_error("SymEngine exception: Unexpected SymEngine error code");
}
}

static inline
void cwrapper_hold(CWRAPPER_OUTPUT_TYPE output) {
if (output)
Rf_error(cwrapper_exception_message(output));
else
return;
}


using namespace Rcpp;

Expand Down Expand Up @@ -961,7 +956,7 @@ void s4DenseMat_mut_addcols(RObject A, RObject B) {
size_t nrow_self = dense_matrix_rows(self);
size_t nrow_value = dense_matrix_rows(value);
if (nrow_self != nrow_value)
Rf_error("Number of rows not equal (%d != %d)\n", nrow_self, nrow_value);
Rf_error("Number of rows not equal (%zu != %zu)\n", nrow_self, nrow_value);
cwrapper_hold(dense_matrix_row_join(self, value));
return;
}
Expand All @@ -972,7 +967,7 @@ void s4DenseMat_mut_addrows(RObject A, RObject B) {
size_t ncol_self = dense_matrix_cols(self);
size_t ncol_value = dense_matrix_cols(value);
if (ncol_self != ncol_value)
Rf_error("Number of cols not equal (%d != %d)\n", ncol_self, ncol_value);
Rf_error("Number of cols not equal (%zu != %zu)\n", ncol_self, ncol_value);
cwrapper_hold(dense_matrix_col_join(self, value));
return;
}
Expand Down
2 changes: 1 addition & 1 deletion tools/bundle_symengine_source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ fi
PKG_DIR=`pwd`

SYMENGINE_REPO="symengine/symengine"
SYMENGINE_COMMIT=ad84b9677e814e6ac328d7127da092d4d8722afe
SYMENGINE_COMMIT=c1fc32cf0902ecd7b1a0e5369c38dd22ad75c726

echo === Bundle source from commit: $SYMENGINE_COMMIT

Expand Down
5 changes: 5 additions & 0 deletions tools/cran_comments/cran-comments_0.2.3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

This version (0.2.3) should fix issues in CRAN check results:
- warning on format specifies type
- remove C++11 requirement
- should also resolve the error (fPIC flag) in Intel test
2 changes: 2 additions & 0 deletions tools/cran_comments/cran-comments_0.2.4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

This version (0.2.4) fixes the build error on MacOS.

0 comments on commit c573238

Please sign in to comment.