diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 1adf545cd..82d881629 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -4,6 +4,7 @@ on: push: branches: - master + - use-rstantools pull_request: branches: - master @@ -20,55 +21,35 @@ jobs: fail-fast: false matrix: config: - - {os: macOS-latest, r: 'devel', rstan: 'CRAN'} - - {os: macOS-latest, r: 'release', rstan: 'CRAN'} - - {os: windows-latest, r: 'devel', rstan: 'CRAN'} - - {os: windows-latest, r: 'release', rstan: 'CRAN'} - - {os: ubuntu-latest, r: 'devel', rstan: 'CRAN'} - - {os: ubuntu-latest, r: 'release', rstan: 'CRAN'} - - {os: ubuntu-latest, r: 'oldrel', rstan: 'CRAN'} - - - {os: macOS-latest, r: 'release', rstan: 'Preview'} - - {os: windows-latest, r: 'release', rstan: 'Preview'} + - { os: macOS-latest, r: 'devel' } + - { os: macOS-latest, r: 'release' } + - { os: macOS-latest, r: 'oldrel' } + - { os: windows-latest, r: 'devel' } + - { os: windows-latest, r: 'release' } + - { os: windows-latest, r: 'oldrel' } + - { os: ubuntu-latest, r: 'devel' } + - { os: ubuntu-latest, r: 'release' } + - { os: ubuntu-latest, r: 'oldrel' } env: R_REMOTES_NO_ERRORS_FROM_WARNINGS: true RSPM: ${{ matrix.config.rspm }} GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + TESTTHAT_CPUS: 4 steps: - - uses: n1hility/cancel-previous-runs@v2 + - uses: n1hility/cancel-previous-runs@master with: token: ${{ secrets.GITHUB_TOKEN }} - workflow: R-CMD-check.yaml if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/master'" - - uses: actions/checkout@v3 + - uses: actions/checkout@main - - uses: r-lib/actions/setup-r@v2 + - uses: r-lib/actions/setup-r@v2-branch with: r-version: ${{ matrix.config.r }} - - uses: r-lib/actions/setup-pandoc@v2 - - uses: r-lib/actions/setup-r-dependencies@v2 + - uses: r-lib/actions/setup-pandoc@v2-branch + - uses: r-lib/actions/setup-r-dependencies@v2-branch with: - cache-version: 2 extra-packages: any::rcmdcheck any::betareg any::HSAUR3 any::biglm any::gamm4 any::V8 - - - name: Install RStan Preview if Needed - run: | - if ("${{ matrix.config.rstan }}" == "Preview") { - install.packages("rstan", repos = c("https://mc-stan.org/r-packages/", getOption("repos"))) - } - shell: Rscript {0} - - - uses: r-lib/actions/check-r-package@v2 - with: - args: 'c("--no-manual", "--as-cran", "--ignore-vignettes")' - build_args: '"--no-build-vignettes"' - - - name: Upload check results - if: failure() - uses: actions/upload-artifact@main - with: - name: ${{ runner.os }}-r${{ matrix.config.r }}-results - path: check + - uses: r-lib/actions/check-r-package@v2-branch diff --git a/.gitignore b/.gitignore index 62f913f22..e61a23194 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,8 @@ vignettes/*.html vignettes/*_files .DS_Store revdep/* +*.o +*.cc +*.h +src/Makevars +R/stanmodels.R diff --git a/R/stanmodels.R b/R/stanmodels.R deleted file mode 100644 index 422d4cc5f..000000000 --- a/R/stanmodels.R +++ /dev/null @@ -1,37 +0,0 @@ -# Part of the rstanarm package for estimating model parameters -# Copyright (C) 2015, 2016, 2017 Trustees of Columbia University -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 3 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -# This file is only intended to be used during the installation process -# nocov start -MODELS_HOME <- "src" -if (!file.exists(MODELS_HOME)) MODELS_HOME <- sub("R$", "src", getwd()) - -stan_files <- dir(file.path(MODELS_HOME, "stan_files"), - pattern = "stan$", full.names = TRUE) -stanmodels <- lapply(stan_files, function(f) { - model_cppname <- sub("\\.stan$", "", basename(f)) - stanfit <- rstan::stanc(f, allow_undefined = TRUE, - obfuscate_model_name = FALSE) - stanfit$model_cpp <- list(model_cppname = stanfit$model_name, - model_cppcode = stanfit$cppcode) - return(do.call(methods::new, args = c(stanfit[-(1:3)], Class = "stanmodel", - mk_cppmodule = function(x) get(paste0("model_", model_cppname))))) - } -) -names(stanmodels) <- sub("\\.stan$", "", basename(stan_files)) -rm(MODELS_HOME) -# nocov end diff --git a/R/zzz.R b/R/zzz.R index 4d6352c24..700df584d 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -15,11 +15,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -.onLoad <- function(libname, pkgname) { - modules <- paste0("stan_fit4", names(stanmodels), "_mod") - for (m in modules) loadModule(m, what = TRUE) -} - .onAttach <- function(...) { ver <- utils::packageVersion("rstanarm") packageStartupMessage("This is rstanarm version ", ver) diff --git a/configure b/configure new file mode 100755 index 000000000..0246289ab --- /dev/null +++ b/configure @@ -0,0 +1,2 @@ +#! /bin/sh +"${R_HOME}/bin/Rscript" -e "rstantools::rstan_config()" diff --git a/configure.ac b/configure.ac deleted file mode 100644 index 84125f168..000000000 --- a/configure.ac +++ /dev/null @@ -1,62 +0,0 @@ -AC_PREREQ(2.62) -AC_INIT([DESCRIPTION]) - -: ${R_HOME=`R RHOME`} -if test -z "${R_HOME}"; then - echo "could not determine R_HOME" - exit 1 -fi - -LTO=-flto -CXX=$(${R_HOME}/bin/R CMD config CXX) $(LTO) - -AC_LANG(C++) -AC_REQUIRE_CPP -AC_PROG_CXX - -AC_ARG_ENABLE([lto], -[AS_HELP_STRING([--enable-lto],[enable link-time optimization @<:@yes@:>@])], -[want_lto="${enableval}"], [want_lto=yes]) -if test "x${want_lto}" != xno; then - AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[int main (void) { return 0; }]])], - [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no) LTO=""]) -fi - -if test "${GXX}" = yes && test -z "${LTO}"; then - gxx_version=`${CXX} -v 2>&1 | grep "^.*g.. version" | sed -e 's/^.*g.. version *//'` - case ${gxx_version} in - 1.*|2.*|3.*|4.0.*|4.1.*|4.2.*|4.3.*|4.4.*|4.5.*|4.6.*|4.7.*|4.8.*) - AC_MSG_WARN([It is preferable to use g++ version 4.9 or greater with rstanarm.]) - ;; - *) - LTO=-flto=jobserver - esac -fi - -if [[ $CXX == *"clang"* ]] && test -z "${LTO}"; then - clang_version=`${CXX} --version 2>&1 | grep "version"` - if [[ $clang_version == *"Apple"* ]]; then - clang_version=`${CXX} --version 2>&1 | grep "version"` | \ - sed -e 's/^Apple LLVM version *//' - case ${clang_version} in 2.*|3.*|4.*5.*|6.*|7.*|8.*) - AC_MSG_WARN([It is preferable to use Apple LLVM version 9 or greater with rstanarm.]) - ;; - *) - LTO="-flto=thin" - esac - fi - elif - case ${clang_version} in 1.*|2.*|3.1.*|3.2.*|3.3.*|3.4.*|3.5.*|3.6.*|3.7.*|3.8.*) - AC_MSG_WARN([It is preferable to use clang++ version 3.9 or greater with rstanarm.]) - ;; - *) - LTO="-flto=thin" - esac - fi -fi - -AC_SUBST(LTO) -AM_CONDITIONAL(BUILD_LTO, [test "x${want_lto}" != xno]) - -AC_CONFIG_FILES([src/Makevars]) -AC_OUTPUT diff --git a/configure.win b/configure.win new file mode 100755 index 000000000..92acfc59d --- /dev/null +++ b/configure.win @@ -0,0 +1,2 @@ +#! /bin/sh +"${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" -e "rstantools::rstan_config()" diff --git a/inst/include/meta_header.hpp b/inst/include/stan_meta_header.hpp similarity index 100% rename from inst/include/meta_header.hpp rename to inst/include/stan_meta_header.hpp diff --git a/src/stan_files/bernoulli.stan b/inst/stan/bernoulli.stan similarity index 99% rename from src/stan_files/bernoulli.stan rename to inst/stan/bernoulli.stan index 9c7530a63..9fe05cfc3 100644 --- a/src/stan_files/bernoulli.stan +++ b/inst/stan/bernoulli.stan @@ -1,5 +1,5 @@ -#include /pre/Columbia_copyright.stan -#include /pre/license.stan +#include /include/Columbia_copyright.stan +#include /include/license.stan // GLM for a Bernoulli outcome functions { diff --git a/src/stan_files/binomial.stan b/inst/stan/binomial.stan similarity index 97% rename from src/stan_files/binomial.stan rename to inst/stan/binomial.stan index f41037fb1..8e802943a 100644 --- a/src/stan_files/binomial.stan +++ b/inst/stan/binomial.stan @@ -1,5 +1,5 @@ -#include /pre/Columbia_copyright.stan -#include /pre/license.stan +#include /include/Columbia_copyright.stan +#include /include/license.stan // GLM for a binomial outcome functions { diff --git a/src/stan_files/continuous.stan b/inst/stan/continuous.stan similarity index 99% rename from src/stan_files/continuous.stan rename to inst/stan/continuous.stan index 3e2894f57..96aaa3ba3 100644 --- a/src/stan_files/continuous.stan +++ b/inst/stan/continuous.stan @@ -1,5 +1,5 @@ -#include /pre/Columbia_copyright.stan -#include /pre/license.stan +#include /include/Columbia_copyright.stan +#include /include/license.stan // GLM for a Gaussian, Gamma, inverse Gaussian, or Beta outcome functions { diff --git a/src/stan_files/count.stan b/inst/stan/count.stan similarity index 99% rename from src/stan_files/count.stan rename to inst/stan/count.stan index 637b336ad..932fef986 100644 --- a/src/stan_files/count.stan +++ b/inst/stan/count.stan @@ -1,5 +1,5 @@ -#include /pre/Columbia_copyright.stan -#include /pre/license.stan +#include /include/Columbia_copyright.stan +#include /include/license.stan // GLM for a count outcome functions { diff --git a/src/stan_files/data/NKX.stan b/inst/stan/data/NKX.stan similarity index 100% rename from src/stan_files/data/NKX.stan rename to inst/stan/data/NKX.stan diff --git a/src/stan_files/data/data_assoc.stan b/inst/stan/data/data_assoc.stan similarity index 100% rename from src/stan_files/data/data_assoc.stan rename to inst/stan/data/data_assoc.stan diff --git a/src/stan_files/data/data_betareg.stan b/inst/stan/data/data_betareg.stan similarity index 100% rename from src/stan_files/data/data_betareg.stan rename to inst/stan/data/data_betareg.stan diff --git a/src/stan_files/data/data_event.stan b/inst/stan/data/data_event.stan similarity index 100% rename from src/stan_files/data/data_event.stan rename to inst/stan/data/data_event.stan diff --git a/src/stan_files/data/data_glm.stan b/inst/stan/data/data_glm.stan similarity index 100% rename from src/stan_files/data/data_glm.stan rename to inst/stan/data/data_glm.stan diff --git a/src/stan_files/data/data_mvmer.stan b/inst/stan/data/data_mvmer.stan similarity index 100% rename from src/stan_files/data/data_mvmer.stan rename to inst/stan/data/data_mvmer.stan diff --git a/src/stan_files/data/dimensions_mvmer.stan b/inst/stan/data/dimensions_mvmer.stan similarity index 100% rename from src/stan_files/data/dimensions_mvmer.stan rename to inst/stan/data/dimensions_mvmer.stan diff --git a/src/stan_files/data/glmer_stuff.stan b/inst/stan/data/glmer_stuff.stan similarity index 100% rename from src/stan_files/data/glmer_stuff.stan rename to inst/stan/data/glmer_stuff.stan diff --git a/src/stan_files/data/glmer_stuff2.stan b/inst/stan/data/glmer_stuff2.stan similarity index 100% rename from src/stan_files/data/glmer_stuff2.stan rename to inst/stan/data/glmer_stuff2.stan diff --git a/src/stan_files/data/hyperparameters.stan b/inst/stan/data/hyperparameters.stan similarity index 100% rename from src/stan_files/data/hyperparameters.stan rename to inst/stan/data/hyperparameters.stan diff --git a/src/stan_files/data/hyperparameters_assoc.stan b/inst/stan/data/hyperparameters_assoc.stan similarity index 100% rename from src/stan_files/data/hyperparameters_assoc.stan rename to inst/stan/data/hyperparameters_assoc.stan diff --git a/src/stan_files/data/hyperparameters_event.stan b/inst/stan/data/hyperparameters_event.stan similarity index 100% rename from src/stan_files/data/hyperparameters_event.stan rename to inst/stan/data/hyperparameters_event.stan diff --git a/src/stan_files/data/hyperparameters_mvmer.stan b/inst/stan/data/hyperparameters_mvmer.stan similarity index 100% rename from src/stan_files/data/hyperparameters_mvmer.stan rename to inst/stan/data/hyperparameters_mvmer.stan diff --git a/src/stan_files/data/weights_offset.stan b/inst/stan/data/weights_offset.stan similarity index 100% rename from src/stan_files/data/weights_offset.stan rename to inst/stan/data/weights_offset.stan diff --git a/src/stan_files/functions/SSfunctions.stan b/inst/stan/functions/SSfunctions.stan similarity index 100% rename from src/stan_files/functions/SSfunctions.stan rename to inst/stan/functions/SSfunctions.stan diff --git a/src/stan_files/functions/bernoulli_likelihoods.stan b/inst/stan/functions/bernoulli_likelihoods.stan similarity index 100% rename from src/stan_files/functions/bernoulli_likelihoods.stan rename to inst/stan/functions/bernoulli_likelihoods.stan diff --git a/src/stan_files/functions/binomial_likelihoods.stan b/inst/stan/functions/binomial_likelihoods.stan similarity index 100% rename from src/stan_files/functions/binomial_likelihoods.stan rename to inst/stan/functions/binomial_likelihoods.stan diff --git a/src/stan_files/functions/common_functions.stan b/inst/stan/functions/common_functions.stan similarity index 100% rename from src/stan_files/functions/common_functions.stan rename to inst/stan/functions/common_functions.stan diff --git a/src/stan_files/functions/continuous_likelihoods.stan b/inst/stan/functions/continuous_likelihoods.stan similarity index 100% rename from src/stan_files/functions/continuous_likelihoods.stan rename to inst/stan/functions/continuous_likelihoods.stan diff --git a/src/stan_files/functions/count_likelihoods.stan b/inst/stan/functions/count_likelihoods.stan similarity index 100% rename from src/stan_files/functions/count_likelihoods.stan rename to inst/stan/functions/count_likelihoods.stan diff --git a/src/stan_files/functions/jm_functions.stan b/inst/stan/functions/jm_functions.stan similarity index 100% rename from src/stan_files/functions/jm_functions.stan rename to inst/stan/functions/jm_functions.stan diff --git a/src/stan_files/functions/mvmer_functions.stan b/inst/stan/functions/mvmer_functions.stan similarity index 100% rename from src/stan_files/functions/mvmer_functions.stan rename to inst/stan/functions/mvmer_functions.stan diff --git a/src/stan_files/gqs/gen_quantities_mvmer.stan b/inst/stan/gqs/gen_quantities_mvmer.stan similarity index 100% rename from src/stan_files/gqs/gen_quantities_mvmer.stan rename to inst/stan/gqs/gen_quantities_mvmer.stan diff --git a/src/stan_files/pre/Brilleman_copyright.stan b/inst/stan/include/Brilleman_copyright.stan similarity index 100% rename from src/stan_files/pre/Brilleman_copyright.stan rename to inst/stan/include/Brilleman_copyright.stan diff --git a/src/stan_files/pre/Columbia_copyright.stan b/inst/stan/include/Columbia_copyright.stan similarity index 100% rename from src/stan_files/pre/Columbia_copyright.stan rename to inst/stan/include/Columbia_copyright.stan diff --git a/src/stan_files/pre/license.stan b/inst/stan/include/license.stan similarity index 100% rename from src/stan_files/pre/license.stan rename to inst/stan/include/license.stan diff --git a/src/stan_files/jm.stan b/inst/stan/jm.stan similarity index 97% rename from src/stan_files/jm.stan rename to inst/stan/jm.stan index d2d97b068..d17b5325a 100644 --- a/src/stan_files/jm.stan +++ b/inst/stan/jm.stan @@ -1,6 +1,6 @@ -#include /pre/Columbia_copyright.stan -#include /pre/Brilleman_copyright.stan -#include /pre/license.stan +#include /include/Columbia_copyright.stan +#include /include/Brilleman_copyright.stan +#include /include/license.stan // Shared parameter joint model functions { diff --git a/src/stan_files/lm.stan b/inst/stan/lm.stan similarity index 98% rename from src/stan_files/lm.stan rename to inst/stan/lm.stan index b929c5258..798df9f47 100644 --- a/src/stan_files/lm.stan +++ b/inst/stan/lm.stan @@ -1,5 +1,5 @@ -#include /pre/Columbia_copyright.stan -#include /pre/license.stan +#include /include/Columbia_copyright.stan +#include /include/license.stan // GLM for a Gaussian outcome with no link function functions { diff --git a/src/stan_files/model/assoc_evaluate.stan b/inst/stan/model/assoc_evaluate.stan similarity index 100% rename from src/stan_files/model/assoc_evaluate.stan rename to inst/stan/model/assoc_evaluate.stan diff --git a/src/stan_files/model/eta_add_Zb.stan b/inst/stan/model/eta_add_Zb.stan similarity index 100% rename from src/stan_files/model/eta_add_Zb.stan rename to inst/stan/model/eta_add_Zb.stan diff --git a/src/stan_files/model/eta_no_intercept.stan b/inst/stan/model/eta_no_intercept.stan similarity index 100% rename from src/stan_files/model/eta_no_intercept.stan rename to inst/stan/model/eta_no_intercept.stan diff --git a/src/stan_files/model/eta_z_no_intercept.stan b/inst/stan/model/eta_z_no_intercept.stan similarity index 100% rename from src/stan_files/model/eta_z_no_intercept.stan rename to inst/stan/model/eta_z_no_intercept.stan diff --git a/src/stan_files/model/event_lp.stan b/inst/stan/model/event_lp.stan similarity index 100% rename from src/stan_files/model/event_lp.stan rename to inst/stan/model/event_lp.stan diff --git a/src/stan_files/model/make_eta.stan b/inst/stan/model/make_eta.stan similarity index 100% rename from src/stan_files/model/make_eta.stan rename to inst/stan/model/make_eta.stan diff --git a/src/stan_files/model/make_eta_bern.stan b/inst/stan/model/make_eta_bern.stan similarity index 100% rename from src/stan_files/model/make_eta_bern.stan rename to inst/stan/model/make_eta_bern.stan diff --git a/src/stan_files/model/make_eta_tmp.stan b/inst/stan/model/make_eta_tmp.stan similarity index 100% rename from src/stan_files/model/make_eta_tmp.stan rename to inst/stan/model/make_eta_tmp.stan diff --git a/src/stan_files/model/make_eta_tmp2.stan b/inst/stan/model/make_eta_tmp2.stan similarity index 100% rename from src/stan_files/model/make_eta_tmp2.stan rename to inst/stan/model/make_eta_tmp2.stan diff --git a/src/stan_files/model/make_eta_z.stan b/inst/stan/model/make_eta_z.stan similarity index 100% rename from src/stan_files/model/make_eta_z.stan rename to inst/stan/model/make_eta_z.stan diff --git a/src/stan_files/model/mvmer_lp.stan b/inst/stan/model/mvmer_lp.stan similarity index 100% rename from src/stan_files/model/mvmer_lp.stan rename to inst/stan/model/mvmer_lp.stan diff --git a/src/stan_files/model/priors_betareg.stan b/inst/stan/model/priors_betareg.stan similarity index 100% rename from src/stan_files/model/priors_betareg.stan rename to inst/stan/model/priors_betareg.stan diff --git a/src/stan_files/model/priors_glm.stan b/inst/stan/model/priors_glm.stan similarity index 100% rename from src/stan_files/model/priors_glm.stan rename to inst/stan/model/priors_glm.stan diff --git a/src/stan_files/model/priors_mvmer.stan b/inst/stan/model/priors_mvmer.stan similarity index 100% rename from src/stan_files/model/priors_mvmer.stan rename to inst/stan/model/priors_mvmer.stan diff --git a/src/stan_files/mvmer.stan b/inst/stan/mvmer.stan similarity index 94% rename from src/stan_files/mvmer.stan rename to inst/stan/mvmer.stan index 12893f688..ee900267d 100644 --- a/src/stan_files/mvmer.stan +++ b/inst/stan/mvmer.stan @@ -1,6 +1,6 @@ -#include /pre/Columbia_copyright.stan -#include /pre/Brilleman_copyright.stan -#include /pre/license.stan +#include /include/Columbia_copyright.stan +#include /include/Brilleman_copyright.stan +#include /include/license.stan // Multivariate GLM with correlated group-specific terms functions { diff --git a/src/stan_files/parameters/parameters_assoc.stan b/inst/stan/parameters/parameters_assoc.stan similarity index 100% rename from src/stan_files/parameters/parameters_assoc.stan rename to inst/stan/parameters/parameters_assoc.stan diff --git a/src/stan_files/parameters/parameters_betareg.stan b/inst/stan/parameters/parameters_betareg.stan similarity index 100% rename from src/stan_files/parameters/parameters_betareg.stan rename to inst/stan/parameters/parameters_betareg.stan diff --git a/src/stan_files/parameters/parameters_event.stan b/inst/stan/parameters/parameters_event.stan similarity index 100% rename from src/stan_files/parameters/parameters_event.stan rename to inst/stan/parameters/parameters_event.stan diff --git a/src/stan_files/parameters/parameters_glm.stan b/inst/stan/parameters/parameters_glm.stan similarity index 100% rename from src/stan_files/parameters/parameters_glm.stan rename to inst/stan/parameters/parameters_glm.stan diff --git a/src/stan_files/parameters/parameters_mvmer.stan b/inst/stan/parameters/parameters_mvmer.stan similarity index 100% rename from src/stan_files/parameters/parameters_mvmer.stan rename to inst/stan/parameters/parameters_mvmer.stan diff --git a/src/stan_files/polr.stan b/inst/stan/polr.stan similarity index 99% rename from src/stan_files/polr.stan rename to inst/stan/polr.stan index e42688404..107032cf9 100644 --- a/src/stan_files/polr.stan +++ b/inst/stan/polr.stan @@ -1,5 +1,5 @@ -#include /pre/Columbia_copyright.stan -#include /pre/license.stan +#include /include/Columbia_copyright.stan +#include /include/license.stan // GLM for an ordinal outcome with coherent priors functions { diff --git a/src/stan_files/tdata/tdata_betareg.stan b/inst/stan/tdata/tdata_betareg.stan similarity index 100% rename from src/stan_files/tdata/tdata_betareg.stan rename to inst/stan/tdata/tdata_betareg.stan diff --git a/src/stan_files/tdata/tdata_glm.stan b/inst/stan/tdata/tdata_glm.stan similarity index 100% rename from src/stan_files/tdata/tdata_glm.stan rename to inst/stan/tdata/tdata_glm.stan diff --git a/src/stan_files/tdata/tdata_mvmer.stan b/inst/stan/tdata/tdata_mvmer.stan similarity index 100% rename from src/stan_files/tdata/tdata_mvmer.stan rename to inst/stan/tdata/tdata_mvmer.stan diff --git a/src/stan_files/tparameters/tparameters_betareg.stan b/inst/stan/tparameters/tparameters_betareg.stan similarity index 100% rename from src/stan_files/tparameters/tparameters_betareg.stan rename to inst/stan/tparameters/tparameters_betareg.stan diff --git a/src/stan_files/tparameters/tparameters_glm.stan b/inst/stan/tparameters/tparameters_glm.stan similarity index 100% rename from src/stan_files/tparameters/tparameters_glm.stan rename to inst/stan/tparameters/tparameters_glm.stan diff --git a/src/stan_files/tparameters/tparameters_mvmer.stan b/inst/stan/tparameters/tparameters_mvmer.stan similarity index 100% rename from src/stan_files/tparameters/tparameters_mvmer.stan rename to inst/stan/tparameters/tparameters_mvmer.stan diff --git a/src/Makevars b/src/Makevars deleted file mode 100644 index ef92430cb..000000000 --- a/src/Makevars +++ /dev/null @@ -1,24 +0,0 @@ -STANHEADERS_SRC = $(shell "$(R_HOME)/bin$(R_ARCH_BIN)/Rscript" -e "message()" -e "cat(system.file('include', 'src', package = 'StanHeaders', mustWork = TRUE))" -e "message()" | grep "StanHeaders") - -STANC_FLAGS = -DUSE_STANC3 -PKG_CPPFLAGS = -I"../inst/include" -I"$(STANHEADERS_SRC)" -DBOOST_DISABLE_ASSERTS -DEIGEN_NO_DEBUG -DBOOST_MATH_OVERFLOW_ERROR_POLICY=errno_on_error $(STANC_FLAGS) -D_HAS_AUTO_PTR_ETC=0 -PKG_CXXFLAGS = $(shell "$(R_HOME)/bin$(R_ARCH_BIN)/Rscript" -e "RcppParallel::CxxFlags()") $(shell "$(R_HOME)/bin$(R_ARCH_BIN)/Rscript" -e "StanHeaders:::CxxFlags()") $(LTO) -PKG_LIBS = $(shell "$(R_HOME)/bin$(R_ARCH_BIN)/Rscript" -e "RcppParallel::RcppParallelLibs()") $(shell "$(R_HOME)/bin$(R_ARCH_BIN)/Rscript" -e "StanHeaders:::LdFlags()") -SHLIB_LDFLAGS = $(SHLIB_CXXLDFLAGS) -SHLIB_LD = $(SHLIB_CXXLD) - -CXX_STD = CXX17 -SOURCES = $(wildcard stan_files/*.stan) -OBJECTS = $(SOURCES:.stan=.o) init.o - -all: $(SHLIB) - -clean: - RM -rf stan_files/*.o - RM -rf *.so *.o - RM -rf stan_files/*.cc - RM -rf stan_files/*.hpp - - -%.cc: %.stan - "$(R_HOME)/bin$(R_ARCH_BIN)/Rscript" -e "source(file.path('..', 'tools', 'make_cc.R')); make_cc(commandArgs(TRUE))" $< diff --git a/src/Makevars.win b/src/Makevars.win deleted file mode 100644 index 1f5f3573c..000000000 --- a/src/Makevars.win +++ /dev/null @@ -1,31 +0,0 @@ -STANHEADERS_SRC = $(shell "$(R_HOME)/bin$(R_ARCH_BIN)/Rscript" -e "message()" -e "cat(system.file('include', 'src', package = 'StanHeaders', mustWork = TRUE))" -e "message()" | grep "StanHeaders") - -STANC_FLAGS = -DUSE_STANC3 -PKG_CPPFLAGS = -I"../inst/include" -I"$(STANHEADERS_SRC)" -DBOOST_DISABLE_ASSERTS -DEIGEN_NO_DEBUG -DRCPP_PARALLEL_USE_TBB=1 $(STANC_FLAGS) -D_HAS_AUTO_PTR_ETC=0 -PKG_CXXFLAGS = $(shell "$(R_HOME)/bin$(R_ARCH_BIN)/Rscript" -e "RcppParallel::CxxFlags()") $(shell "$(R_HOME)/bin$(R_ARCH_BIN)/Rscript" -e "StanHeaders:::CxxFlags()") -PKG_LIBS = $(shell "$(R_HOME)/bin$(R_ARCH_BIN)/Rscript" -e "RcppParallel::RcppParallelLibs()") $(shell "$(R_HOME)/bin$(R_ARCH_BIN)/Rscript" -e "StanHeaders:::LdFlags()") - -PKG_CXXFLAGS += -flto=jobserver -PKG_LIBS += -Wl,--allow-multiple-definition - -CXX_STD = CXX17 -SOURCES = $(wildcard stan_files/*.stan) -OBJECTS = $(SOURCES:.stan=.o) init.o - -AR = gcc-ar -m$(WIN) -NM = gcc-nm -m$(WIN) -RANLIB = gcc-ranlib -m$(WIN) - -all: $(SHLIB) - -clean: - RM -rf stan_files/*.o - RM -rf *.so *.o - RM -rf stan_files/*.cc - RM -rf stan_files/*.hpp - -%.cc: %.stan - "$(R_HOME)/bin$(R_ARCH_BIN)/Rscript" -e "source(file.path('..', 'tools', 'make_cc.R')); make_cc(commandArgs(TRUE))" $< - - -.phony: clean diff --git a/src/rstanarm-win.def b/src/rstanarm-win.def deleted file mode 100644 index 9ee9b6c97..000000000 --- a/src/rstanarm-win.def +++ /dev/null @@ -1,3 +0,0 @@ -LIBRARY rstanarm.dll -EXPORTS - diff --git a/tests/testthat/include b/tests/testthat/include deleted file mode 120000 index 79818b409..000000000 --- a/tests/testthat/include +++ /dev/null @@ -1 +0,0 @@ -../../inst/include/ \ No newline at end of file diff --git a/tests/testthat/stan_files b/tests/testthat/stan_files deleted file mode 120000 index 89c9fe9d4..000000000 --- a/tests/testthat/stan_files +++ /dev/null @@ -1 +0,0 @@ -../../src/stan_files/ \ No newline at end of file diff --git a/tests/testthat/test_stan_functions.R b/tests/testthat/test_stan_functions.R index 98ea063b0..a75a35f6f 100644 --- a/tests/testthat/test_stan_functions.R +++ b/tests/testthat/test_stan_functions.R @@ -18,8 +18,8 @@ Sys.setenv(USE_CXX17 = 1) set.seed(12345) -MODELS_HOME <- "stan_files" -INCLUDE_DIR <- "include" +MODELS_HOME <- system.file("stan", package = "rstanarm", mustWork = TRUE) +INCLUDE_DIR <- system.file("include", package = "rstanarm", mustWork = TRUE) context("setup") test_that("Stan programs are available", { diff --git a/tools/make_cc.R b/tools/make_cc.R deleted file mode 100644 index a3f0501c9..000000000 --- a/tools/make_cc.R +++ /dev/null @@ -1,47 +0,0 @@ -# Part of the rstanarm package for estimating model parameters -# Copyright (C) 2015, 2016, 2017 Trustees of Columbia University -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 3 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -options(warn = 3L) -options("useFancyQuotes" = FALSE) - -make_cc <- function(file) { - file <- sub("\\.cc$", ".stan", file) - cppcode <- rstan::stanc(file, allow_undefined = TRUE, - obfuscate_model_name = FALSE)$cppcode - cppcode <- sub("(class[[:space:]][A-Za-z_][A-Za-z0-9_]*[[:space:]])", - paste("#include \n", "\\1"), cppcode) - - writeLines(c(readLines(dir("stan_files", pattern = "license.stan", recursive = TRUE, full.names = TRUE)), - "#ifndef MODELS_HPP", "#define MODELS_HPP", "#define STAN__SERVICES__COMMAND_HPP", - "#include ", - cppcode, "#endif"), con = sub("\\.stan$", ".hpp", file)) - - f <- sub("\\.stan$", "", basename(file)) - Rcpp::exposeClass(class = paste0("model_", f), - constructors = list(c("SEXP", "SEXP", "SEXP")), fields = character(), - methods = c("call_sampler", - "param_names", "param_names_oi", "param_fnames_oi", - "param_dims", "param_dims_oi", "update_param_oi", "param_oi_tidx", - "grad_log_prob", "log_prob", - "unconstrain_pars", "constrain_pars", "num_pars_unconstrained", - "unconstrained_param_names", "constrained_param_names"), - file = file.path("stan_files", paste0(f, ".cc")), - header = paste0('#include "', f, '.hpp"'), - module = paste0("stan_fit4", f, "_mod"), - CppClass = "rstan::stan_fit ", - Rfile = FALSE) - return(invisible(NULL)) -}