diff --git a/.github/workflows/pr-commands.yaml b/.github/workflows/pr-commands.yaml new file mode 100644 index 0000000..3f40bf9 --- /dev/null +++ b/.github/workflows/pr-commands.yaml @@ -0,0 +1,125 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + issue_comment: + types: [created] + +name: pr-commands.yaml + +permissions: read-all + +jobs: + document: + if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/document') }} + name: document + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/pr-fetch@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::roxygen2 + needs: pr-document + + - name: Document + run: roxygen2::roxygenise() + shell: Rscript {0} + + - name: commit + run: | + git config --local user.name "$GITHUB_ACTOR" + git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" + git add man/\* NAMESPACE + git commit -m 'Document' + + - uses: r-lib/actions/pr-push@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + + + compile: + if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/compile') }} + name: compile + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/pr-fetch@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::Rcpp + needs: pr-compile + + - name: Compile + run: Rcpp::compileAttributes() + shell: Rscript {0} + + - name: commit + run: | + git config --local user.name "$GITHUB_ACTOR" + git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" + git add man/\* NAMESPACE + git commit -m 'Compile attributes' + + - uses: r-lib/actions/pr-push@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + + style: + if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/style') }} + name: style + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/pr-fetch@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + + - uses: r-lib/actions/setup-r@v2 + + - name: Install dependencies + run: install.packages("styler") + shell: Rscript {0} + + - name: Style + run: styler::style_pkg() + shell: Rscript {0} + + - name: commit + run: | + git config --local user.name "$GITHUB_ACTOR" + git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" + git add \*.R + git commit -m 'Style' + + - uses: r-lib/actions/pr-push@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/submit-cran.yaml b/.github/workflows/submit-cran.yaml new file mode 100644 index 0000000..6457a40 --- /dev/null +++ b/.github/workflows/submit-cran.yaml @@ -0,0 +1,23 @@ +name: Submit to CRAN + +on: + release: + types: [prereleased] + +jobs: + cran-submission: + runs-on: ubuntu-latest + name: Submit package to CRAN + permissions: + contents: read + issues: write # Needed to create issues + steps: + - uses: actions/checkout@v4 + + - name: Submit R package to CRAN + uses: coatless-actions/cran-submission@v1 + with: + pkg-directory: '.' # Directory containing the package + check-directory: 'check' # Directory for check outputs + error-on: 'warning' # Fail on warnings + create-issue: true # Create issues to track submissions diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml new file mode 100644 index 0000000..c3df460 --- /dev/null +++ b/.github/workflows/test-coverage.yaml @@ -0,0 +1,62 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + branches: [main] + pull_request: + +name: test-coverage.yaml + +permissions: read-all + +jobs: + test-coverage: + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::covr, any::xml2 + needs: coverage + + - name: Test coverage + run: | + cov <- covr::package_coverage( + quiet = FALSE, + clean = FALSE, + install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package") + ) + print(cov) + covr::to_cobertura(cov) + shell: Rscript {0} + + - uses: codecov/codecov-action@v5 + with: + # Fail if error if not on PR, or if on PR and token is given + fail_ci_if_error: ${{ github.event_name != 'pull_request' || secrets.CODECOV_TOKEN }} + files: ./cobertura.xml + plugins: noop + disable_search: true + token: ${{ secrets.CODECOV_TOKEN }} + + - name: Show testthat output + if: always() + run: | + ## -------------------------------------------------------------------- + find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true + shell: bash + + - name: Upload test results + if: failure() + uses: actions/upload-artifact@v4 + with: + name: coverage-test-failures + path: ${{ runner.temp }}/package diff --git a/DESCRIPTION b/DESCRIPTION index 305bf5c..2198f4f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -18,4 +18,4 @@ Depends: Rcpp LinkingTo: Rcpp, RcppArmadillo Suggests: testthat, knitr, rmarkdown VignetteBuilder: knitr -RoxygenNote: 7.1.1 +RoxygenNote: 7.3.3 diff --git a/R/deprecated.R b/R/deprecated.R deleted file mode 100644 index 0fdc400..0000000 --- a/R/deprecated.R +++ /dev/null @@ -1,109 +0,0 @@ -# matchingR -- Matching Algorithms in R and C++ -# -# Copyright (C) 2015 Jan Tilly -# Nick Janetos -# -# This file is part of matchingR. -# -# matchingR 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 2 of the License, or -# (at your option) any later version. -# -# matchingR 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. - -#' Deprecated Functions in matchingR -#' -#' These functions are provided for compatibility with older version of -#' the matchingR package. Eventually, these functions will be removed. -#' -#' @rdname matchingR-deprecated -#' @name matchingR-deprecated -#' @param ... generic set of parameters --- see documentation of new functions -#' @docType package -#' @aliases validateInputs checkStability checkPreferenceOrder one2many many2one -#' one2one galeShapleyMatching stableRoommateMatching onesided -#' checkStabilityRoommate validateInputsOneSided checkPreferenceOrderOnesided -#' topTradingCycle checkStabilityTopTradingCycle -#' @section Details: -#' \tabular{rl}{ -#' \code{validateInputs} \tab was replaced by \code{\link{galeShapley.validate}}\cr -#' \code{checkStability} \tab was replaced by \code{\link{galeShapley.checkStability}}\cr -#' \code{checkPreferenceOrder} \tab was replaced by \code{\link{galeShapley.checkPreferences}}\cr -#' \code{one2many} \tab now mapped into \code{\link{galeShapley.collegeAdmissions}}\cr -#' \code{many2one} \tab now mapped into \code{\link{galeShapley.collegeAdmissions}}\cr -#' \code{one2one} \tab was replaced by \code{\link{galeShapley.marriageMarket}}\cr -#' \code{galeShapleyMatching} \tab was replaced by \code{\link{cpp_wrapper_galeshapley}}\cr -#' \code{stableRoommateMatching} \tab was replaced by \code{\link{cpp_wrapper_irving}}\cr -#' \code{onesided} \tab was replaced by \code{\link{roommate}}\cr -#' \code{checkStabilityRoommate} \tab was replaced by \code{\link{cpp_wrapper_irving_check_stability}}\cr -#' \code{validateInputsOneSided} \tab was replaced by \code{\link{roommate.validate}}\cr -#' \code{checkPreferenceOrderOnesided} \tab was replaced by \code{\link{roommate.checkPreferences}}\cr -#' \code{topTradingCycle} \tab was replaced by \code{\link{cpp_wrapper_ttc}}\cr -#' \code{checkStabilityTopTradingCycle} \tab was replaced by \code{\link{cpp_wrapper_ttc_check_stability}}\cr -#' } -#' -validateInputs <- function(...) { - .Deprecated("galeShapley.validate") - galeShapley.validate(...) -} -checkStability <- function(...) { - .Deprecated("galeShapley.checkStability") - galeShapley.checkStability(...) -} -checkPreferenceOrder <- function(...) { - .Deprecated("galeShapley.checkPreferences") - galeShapley.checkPreferences(...) -} -one2many <- function(...) { - .Deprecated("galeShapley.collegeAdmissions") - galeShapley.collegeAdmissions(..., studentOptimal = TRUE) -} -many2one <- function(...) { - .Deprecated("galeShapley.collegeAdmissions") - galeShapley.collegeAdmissions(..., studentOptimal = FALSE) -} -one2one <- function(...) { - .Deprecated("galeShapley.marriageMarket") - galeShapley.marriageMarket(...) -} -galeShapleyMatching <- function(...) { - .Deprecated("cpp_wrapper_galeshapley") - cpp_wrapper_galeshapley(...) -} -stableRoommateMatching <- function(...) { - .Deprecated("cpp_wrapper_irving") - cpp_wrapper_irving(...) -} -onesided <- function(...) { - .Deprecated("roommate") - roommate(...) -} -checkStabilityRoommate <- function(...) { - .Deprecated("cpp_wrapper_irving_check_stability") - cpp_wrapper_irving_check_stability(...) -} -validateInputsOneSided <- function(...) { - .Deprecated("roommate.validate") - roommate.validate(...) -} -checkPreferenceOrderOnesided <- function(...) { - .Deprecated("roommate.checkPreferences") - roommate.checkPreferences(...) -} -topTradingCycle <- function(...) { - .Deprecated("cpp_wrapper_ttc") - cpp_wrapper_ttc(...) -} -checkStabilityTopTradingCycle <- function(...) { - .Deprecated("cpp_wrapper_ttc_check_stability") - toptrading.checkStability(...) -} -toptrading <- function(...) { - .Deprecated("toptrading") - toptrading(...) -} -NULL diff --git a/R/matchingR.R b/R/matchingR.R index 0d1acbf..b7678cc 100644 --- a/R/matchingR.R +++ b/R/matchingR.R @@ -15,7 +15,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -#' @name matchingR-package +#' @name matchingR #' @docType package #' @title matchingR: Matching Algorithms in R and C++ #' @description matchingR is an R package which quickly computes a variety of diff --git a/man/matchingR-deprecated.Rd b/man/matchingR-deprecated.Rd deleted file mode 100644 index 84b0dde..0000000 --- a/man/matchingR-deprecated.Rd +++ /dev/null @@ -1,49 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/deprecated.R -\docType{package} -\name{matchingR-deprecated} -\alias{matchingR-deprecated} -\alias{validateInputs} -\alias{checkStability} -\alias{checkPreferenceOrder} -\alias{one2many} -\alias{many2one} -\alias{one2one} -\alias{galeShapleyMatching} -\alias{stableRoommateMatching} -\alias{onesided} -\alias{checkStabilityRoommate} -\alias{validateInputsOneSided} -\alias{checkPreferenceOrderOnesided} -\alias{topTradingCycle} -\alias{checkStabilityTopTradingCycle} -\title{Deprecated Functions in matchingR} -\usage{ -validateInputs(...) -} -\arguments{ -\item{...}{generic set of parameters --- see documentation of new functions} -} -\description{ -These functions are provided for compatibility with older version of -the matchingR package. Eventually, these functions will be removed. -} -\section{Details}{ - -\tabular{rl}{ - \code{validateInputs} \tab was replaced by \code{\link{galeShapley.validate}}\cr - \code{checkStability} \tab was replaced by \code{\link{galeShapley.checkStability}}\cr - \code{checkPreferenceOrder} \tab was replaced by \code{\link{galeShapley.checkPreferences}}\cr - \code{one2many} \tab now mapped into \code{\link{galeShapley.collegeAdmissions}}\cr - \code{many2one} \tab now mapped into \code{\link{galeShapley.collegeAdmissions}}\cr - \code{one2one} \tab was replaced by \code{\link{galeShapley.marriageMarket}}\cr - \code{galeShapleyMatching} \tab was replaced by \code{\link{cpp_wrapper_galeshapley}}\cr - \code{stableRoommateMatching} \tab was replaced by \code{\link{cpp_wrapper_irving}}\cr - \code{onesided} \tab was replaced by \code{\link{roommate}}\cr - \code{checkStabilityRoommate} \tab was replaced by \code{\link{cpp_wrapper_irving_check_stability}}\cr - \code{validateInputsOneSided} \tab was replaced by \code{\link{roommate.validate}}\cr - \code{checkPreferenceOrderOnesided} \tab was replaced by \code{\link{roommate.checkPreferences}}\cr - \code{topTradingCycle} \tab was replaced by \code{\link{cpp_wrapper_ttc}}\cr - \code{checkStabilityTopTradingCycle} \tab was replaced by \code{\link{cpp_wrapper_ttc_check_stability}}\cr -} -} diff --git a/man/matchingR-package.Rd b/man/matchingR-package.Rd deleted file mode 100644 index b2adc48..0000000 --- a/man/matchingR-package.Rd +++ /dev/null @@ -1,108 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/matchingR.R -\docType{package} -\name{matchingR-package} -\alias{matchingR} -\alias{matchingR-package} -\title{matchingR: Matching Algorithms in R and C++} -\description{ -matchingR is an R package which quickly computes a variety of - matching algorithms for one-sided and two-sided markets. This package - implements - \itemize{ - \item{the Gale-Shapley Algorithm to compute the stable matching for - two-sided markets, such as the stable marriage problem and the - college-admissions problem} - \item{Irving's Algorithm to compute the stable matching for one-sided - markets such as the stable roommates problem} - \item{the top trading cycle algorithm for the indivisible goods trading - problem.} - } - - All matching algorithms are implemented in \code{C++} and can therefore be - computed quickly. The package may be useful when the number of market - participants is large or when many matchings need to be computed (e.g. for - extensive simulations or for estimation purposes). The Gale-Shapley - function of this package has successfully been used to simulate preferences - and compute the matching with 30,000 participants on each side of the - market. - - Matching markets are common in practice and widely studied by - economists. Popular examples include - \itemize{ - \item{the National Resident Matching Program that matches graduates from - medical school to residency programs at teaching hospitals throughout the - United States} - \item{the matching of students to schools including the New York City High - School Match or the the Boston Public School Match (and many more)} - \item{the matching of kidney donors to recipients in kidney exchanges.} - } -} -\examples{ -# stable marriage problem -set.seed(1) -nmen <- 25 -nwomen <- 20 -uM <- matrix(runif(nmen * nwomen), nrow = nwomen, ncol = nmen) -uW <- matrix(runif(nwomen * nmen), nrow = nmen, ncol = nwomen) -results <- galeShapley.marriageMarket(uM, uW) -galeShapley.checkStability(uM, uW, results$proposals, results$engagements) - -# college admissions problem -nstudents <- 25 -ncolleges <- 5 -uStudents <- matrix(runif(nstudents * ncolleges), nrow = ncolleges, ncol = nstudents) -uColleges <- matrix(runif(nstudents * ncolleges), nrow = nstudents, ncol = ncolleges) -results <- galeShapley.collegeAdmissions( - studentUtils = uStudents, - collegeUtils = uColleges, - slots = 4 -) -results -# check stability -galeShapley.checkStability( - uStudents, - uColleges, - results$matched.students, - results$matched.colleges -) - -# stable roommate problem -set.seed(2) -N <- 10 -u <- matrix(runif(N^2), nrow = N, ncol = N) -results <- roommate(utils = u) -results -# check stability -roommate.checkStability(utils = u, matching = results) - -# top trading cycle algorithm -N <- 10 -u <- matrix(runif(N^2), nrow = N, ncol = N) -results <- toptrading(utils = u) -results -# check stability -toptrading.checkStability(utils = u, matching = results) -} -\references{ -Gale, D. and Shapley, L.S. (1962). College admissions and the - stability of marriage. \emph{The American Mathematical Monthly}, 69(1): - 9--15. - -Irving, R. W. (1985). An efficient algorithm for the "stable - roommates" problem. \emph{Journal of Algorithms}, 6(4): 577--595 - -Shapley, L., & Scarf, H. (1974). On cores and indivisibility. - \emph{Journal of Mathematical Economics}, 1(1), 23-37. -} -\seealso{ -Useful links: -\itemize{ - \item \url{https://github.com/jtilly/matchingR/} - \item Report bugs at \url{https://github.com/jtilly/matchingR/issues/} -} - -} -\author{ -Jan Tilly, Nick Janetos -}