From cd10e467fa0126c0dc07eddf46cf19c01dc943ce Mon Sep 17 00:00:00 2001 From: Kohei Watanabe Date: Thu, 5 Oct 2023 20:53:50 +0100 Subject: [PATCH 1/3] Update for Matrix package --- R/textmodel.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/R/textmodel.R b/R/textmodel.R index 93b9a80..d0a2327 100644 --- a/R/textmodel.R +++ b/R/textmodel.R @@ -62,7 +62,7 @@ textmodel_newsmap.dfm <- function(x, y, label = c("all", "max"), smooth = 1.0, d label <- match.arg(label) if (label == "max") { - y <- as(y, "dgTMatrix") + y <- as(as(as(y, "dMatrix"), "generalMatrix"), "TsparseMatrix") s <- sapply(split(y@x, y@i + 1L), max) y@x[y@x < s[y@i + 1L]] <- 0L } @@ -157,7 +157,7 @@ coef.textmodel_newsmap <- function(object, n = 10, ...) { } else { model <- object$model * object$weight } - model <- as(model, "dgTMatrix") + model <- as(as(as(model, "dMatrix"), "generalMatrix"), "TsparseMatrix") temp <- model@x names(temp) <- colnames(object$model)[model@j + 1L] result <- split(temp, factor(model@i + 1L, levels = seq_len(nrow(model)), @@ -266,7 +266,7 @@ get_entropy <- function(x, base = 2) { x <- t(x) x <- dfm_weight(x, "prop") - x <- as(x, "dgTMatrix") + x <- as(as(as(x, "dMatrix"), "generalMatrix"), "TsparseMatrix") result <- unlist(lapply(split(x@x, factor(x@i + 1L, levels = seq_len(nrow(x)))), function(y) sum(y * log(y, base)) * -1), use.names = FALSE) names(result) <- rownames(x) From 2b95a13be98b4cc9f683f0b3c48ffdbd750062c1 Mon Sep 17 00:00:00 2001 From: Kohei Watanabe Date: Thu, 5 Oct 2023 20:56:03 +0100 Subject: [PATCH 2/3] Increment the version --- DESCRIPTION | 2 +- NEWS.md | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 96290a8..0637fa3 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: newsmap Type: Package Title: Semi-Supervised Model for Geographical Document Classification -Version: 0.8.2 +Version: 0.8.3 Authors@R: c(person("Kohei", "Watanabe", email = "watanabe.kohei@gmail.com", role = c("aut", "cre", "cph")), person("Stefan", "Müller", email = "mullers@tcd.ie", role = "aut"), person("Dani", "Madrid-Morales", email = "dani.madrid@my.cityu.edu.hk", role = "aut"), diff --git a/NEWS.md b/NEWS.md index 05ef876..3945b2d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +## Changens in v0.8.3 + +* Fix for changes in the Matrix package v1.5. + ## Changens in v0.8.2 * Add `min_conf` to `predict()` From aff5262d24061fb50b694b9e66ba88162875d2a3 Mon Sep 17 00:00:00 2001 From: Kohei Watanabe Date: Fri, 6 Oct 2023 10:57:43 +0100 Subject: [PATCH 3/3] Update --- .github/workflows/test-coverage.yaml | 58 +++++++++++++++------------- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index 0182b4e..2c5bb50 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -1,46 +1,50 @@ +# 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: - - master + branches: [main, master] pull_request: - branches: - - master + branches: [main, master] name: test-coverage jobs: test-coverage: - runs-on: macOS-latest + runs-on: ubuntu-latest env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - - uses: r-lib/actions/setup-r@v1 + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true - - uses: r-lib/actions/setup-pandoc@v1 + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::covr + needs: coverage - - name: Query dependencies + - name: Test coverage run: | - install.packages('remotes') - saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) - writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") + covr::codecov( + quiet = FALSE, + clean = FALSE, + install_path = file.path(Sys.getenv("RUNNER_TEMP"), "package") + ) shell: Rscript {0} - - name: Cache R packages - uses: actions/cache@v2 - with: - path: ${{ env.R_LIBS_USER }} - key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} - restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- - - - name: Install dependencies + - name: Show testthat output + if: always() run: | - install.packages(c("remotes")) - remotes::install_deps(dependencies = TRUE) - remotes::install_cran("covr") - shell: Rscript {0} + ## -------------------------------------------------------------------- + find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true + shell: bash - - name: Test coverage - run: covr::codecov() - shell: Rscript {0} + - name: Upload test results + if: failure() + uses: actions/upload-artifact@v3 + with: + name: coverage-test-failures + path: ${{ runner.temp }}/package