Skip to content

Commit

Permalink
Merge pull request #2193 from quanteda/fix-3.2.3-errors
Browse files Browse the repository at this point in the history
Fix 3.2.3 errors from dropped feature dimension label in dfm_weight()
  • Loading branch information
kbenoit committed Dec 8, 2022
2 parents 3059ee9 + d173ad9 commit bff2cee
Show file tree
Hide file tree
Showing 18 changed files with 92 additions and 116 deletions.
45 changes: 8 additions & 37 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Workflow derived from https://github.com/r-lib/actions/tree/master/examples
# 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:
Expand All @@ -10,49 +10,20 @@ name: R-CMD-check

jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
# - {os: macOS-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}

runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-pandoc@v1

- uses: r-lib/actions/setup-r@v1
- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v1
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: rcmdcheck

- uses: r-lib/actions/check-r-package@v1
extra-packages: any::rcmdcheck
needs: check

- name: Show testthat output
if: always()
run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- 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
59 changes: 32 additions & 27 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
@@ -1,45 +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@master
- uses: r-lib/actions/setup-r@v2
with:
r-version: 'release'
use-public-rspm: true

- uses: r-lib/actions/setup-pandoc@master
- 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)
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@v1
with:
path: ${{ env.R_LIBS_USER }}
key: macOS-r-4.0-2-${{ hashFiles('.github/depends.Rds') }}
restore-keys: macOS-r-4.0-2-

- 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
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ BugReports: https://github.com/quanteda/quanteda/issues
LazyData: TRUE
VignetteBuilder: knitr
Language: en-GB
RoxygenNote: 7.2.1
RoxygenNote: 7.2.2
SystemRequirements: C++11
Roxygen: list(markdown = TRUE)
Collate:
Expand Down
4 changes: 2 additions & 2 deletions R/data-documentation.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
#' Young and Soroka (2012) also suggest the use of a pre-processing script to
#' remove specific cases of some words (i.e., "good bye", or "nobody better",
#' which should not be counted as positive). Pre-processing scripts are
#' available at <http://www.snsoroka.com/data-lexicoder/>.
#' available at <https://www.snsoroka.com/data-lexicoder/>.
#' @section License and Conditions:
#' The LSD is available for non-commercial academic purposes only. By using
#' `data_dictionary_LSD2015`, you accept these terms.
Expand All @@ -102,7 +102,7 @@
#' Lexicoder Sentiment Dictionary and related resources.
#
#' Young, L. & Soroka, S. (2012). *Lexicoder Sentiment
#' Dictionary*. Available at <http://www.snsoroka.com/data-lexicoder/>.
#' Dictionary*. Available at <https://www.snsoroka.com/data-lexicoder/>.
#'
#' Young, L. & Soroka, S. (2012). Affective News: The Automated Coding of
#' Sentiment in Political Texts]. \doi{10.1080/10584609.2012.671234}.
Expand Down
4 changes: 2 additions & 2 deletions R/dfm-print.R
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ format_sparsity <- function(x) {
x <- check_double(x, min = 0, max = 1.0)
level <- c(0, 0.0001, 0.9999, 1)
if (any(x == level))
return(sprintf("%.2f%%", x * 100))
v <- c("<0.01%", sprintf("%.2f%%", x * 100), ">99.99%")
return(stringi::stri_sprintf("%.2f%%", x * 100))
v <- c("<0.01%", stringi::stri_sprintf("%.2f%%", x * 100), ">99.99%")
return(v[as.integer(cut(x, level))])
}

4 changes: 3 additions & 1 deletion R/dfm_weight.R
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ dfm_weight.dfm <- function(x,

weight <- Diagonal(x = weight)
colnames(weight) <- colnames(x)
return(as.dfm(x %*% weight))
result <- x %*% weight
dimnames(result) <- dimnames(x)
return(result)

} else {
### for scheme weights
Expand Down
2 changes: 1 addition & 1 deletion R/dictionaries.R
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ check_entries <- function(dict) {
#' Yoshikoder page, from Will Lowe
#' <https://conjugateprior.org/software/yoshikoder/>.
#'
#' Lexicoder format, <http://www.snsoroka.com/data-lexicoder/>
#' Lexicoder format, <https://www.snsoroka.com/data-lexicoder/>
#'
#' @seealso [dfm], [as.dictionary()],
#' [`as.list()`][dictionary2-class], [is.dictionary()]
Expand Down
4 changes: 2 additions & 2 deletions R/message.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

#' Conditionally format messages
#'
#' @param x message template to be passed to [`sprintf()`].
#' @param x message template to be passed to [`stri_sprintf()`].
#' @param values list of values to be used in the template. Coerced to list if vector is given.
#' @param indices list of integer to specify which value to be used.
#' @param pretty if `TRUE`, message is passed to [`prettyNum()`].
Expand Down Expand Up @@ -36,7 +36,7 @@ msg <- function(x, values = NULL, indices = NULL, pretty = TRUE, ...) {
return(x[y])
}, values, indices, SIMPLIFY = FALSE)
}
msg <- do.call(sprintf, c(list(x), values))
msg <- do.call(stringi::stri_sprintf, c(list(x), values))
} else {
msg <- x
}
Expand Down
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ library("badger")
`r badge_devel("quanteda/quanteda", "royalblue")`
[![Downloads](https://cranlogs.r-pkg.org/badges/quanteda)](https://CRAN.R-project.org/package=quanteda)
[![Total Downloads](https://cranlogs.r-pkg.org/badges/grand-total/quanteda?color=orange)](https://CRAN.R-project.org/package=quanteda)
[![R build status](https://github.com/quanteda/quanteda/workflows/R-CMD-check/badge.svg)](https://github.com/quanteda/quanteda/actions)
[![R-CMD-check](https://github.com/quanteda/quanteda/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/quanteda/quanteda/actions/workflows/R-CMD-check.yaml)
[![codecov](https://codecov.io/gh/quanteda/quanteda/branch/master/graph/badge.svg)](https://app.codecov.io/gh/quanteda/quanteda) [![DOI](https://zenodo.org/badge/5424649.svg)](https://zenodo.org/badge/latestdoi/5424649)
[![DOI](http://joss.theoj.org/papers/10.21105/joss.00774/status.svg)](https://doi.org/10.21105/joss.00774)
<!-- badges: end -->
Expand Down
62 changes: 30 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ data](https://cdn.rawgit.com/quanteda/quanteda/master/images/quanteda_logo.svg)]

[![CRAN
Version](https://www.r-pkg.org/badges/version/quanteda)](https://CRAN.R-project.org/package=quanteda)
[![](https://img.shields.io/badge/devel%20version-3.2.3-royalblue.svg)](https://github.com/quanteda/quanteda)
[![](https://img.shields.io/badge/devel%20version-3.2.4-royalblue.svg)](https://github.com/quanteda/quanteda)
[![Downloads](https://cranlogs.r-pkg.org/badges/quanteda)](https://CRAN.R-project.org/package=quanteda)
[![Total
Downloads](https://cranlogs.r-pkg.org/badges/grand-total/quanteda?color=orange)](https://CRAN.R-project.org/package=quanteda)
[![R build
status](https://github.com/quanteda/quanteda/workflows/R-CMD-check/badge.svg)](https://github.com/quanteda/quanteda/actions)
[![R-CMD-check](https://github.com/quanteda/quanteda/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/quanteda/quanteda/actions/workflows/R-CMD-check.yaml)
[![codecov](https://codecov.io/gh/quanteda/quanteda/branch/master/graph/badge.svg)](https://app.codecov.io/gh/quanteda/quanteda)
[![DOI](https://zenodo.org/badge/5424649.svg)](https://zenodo.org/badge/latestdoi/5424649)
[![DOI](http://joss.theoj.org/papers/10.21105/joss.00774/status.svg)](https://doi.org/10.21105/joss.00774)
Expand Down Expand Up @@ -42,24 +41,23 @@ for a full list of the changes.
As of v3.0, we have continued our trend of splitting **quanteda** into
modular packages. These are now the following:

- **quanteda**: contains all of the core natural language processing
and textual data management functions
- **quanteda.textmodels**: contains all of the text models and
supporting functions, namely the `textmodel_*()` functions. This was
split from the main package with the v2 release
- **quanteda.textstats**: statistics for textual data, namely the
`textstat_*()` functions, split with the v3 release
- **quanteda.textplots**: plots for textual data, namely the
`textplot_*()` functions, split with the v3 release
- **quanteda**: contains all of the core natural language processing and
textual data management functions
- **quanteda.textmodels**: contains all of the text models and
supporting functions, namely the `textmodel_*()` functions. This was
split from the main package with the v2 release
- **quanteda.textstats**: statistics for textual data, namely the
`textstat_*()` functions, split with the v3 release
- **quanteda.textplots**: plots for textual data, namely the
`textplot_*()` functions, split with the v3 release

We are working on additional package releases, available in the meantime
from our GitHub pages:

- **quanteda.sentiment**: Functions and lexicons for sentiment
analysis using dictionaries
- **quanteda.tidy**: Extensions for manipulating document variables in
core **quanteda** objects using your favourite **tidyverse**
functions
- **quanteda.sentiment**: Functions and lexicons for sentiment analysis
using dictionaries
- **quanteda.tidy**: Extensions for manipulating document variables in
core **quanteda** objects using your favourite **tidyverse** functions

and more to come.

Expand Down Expand Up @@ -92,10 +90,10 @@ how to use **quanteda**.

### How to Get Help

- Read out documentation at <https://quanteda.io>.
- Submit a question on the [**quanteda** channel on
StackOverflow](https://stackoverflow.com/questions/tagged/quanteda).
- See our [tutorial site](https://tutorials.quanteda.io/).
- Read out documentation at <https://quanteda.io>.
- Submit a question on the [**quanteda** channel on
StackOverflow](https://stackoverflow.com/questions/tagged/quanteda).
- See our [tutorial site](https://tutorials.quanteda.io/).

### How to Cite

Expand All @@ -119,14 +117,14 @@ testimonial here](https://github.com/quanteda/quanteda/issues/461).
Contributions in the form of feedback, comments, code, and bug reports
are most welcome. How to contribute:

- Fork the source code, modify, and issue a [pull
request](https://help.github.com/articles/creating-a-pull-request-from-a-fork/)
through the [project GitHub
page](https://github.com/quanteda/quanteda). See our [Contributor
Code of
Conduct](https://github.com/quanteda/quanteda/blob/master/CONDUCT.md)
and the all-important **quanteda** [Style
Guide](https://github.com/quanteda/quanteda/wiki/Style-guide).
- Issues, bug reports, and wish lists: [File a GitHub
issue](https://github.com/quanteda/quanteda/issues).
- Contact [the maintainer](mailto:kbenoit@lse.ac.uk) by email.
- Fork the source code, modify, and issue a [pull
request](https://help.github.com/articles/creating-a-pull-request-from-a-fork/)
through the [project GitHub
page](https://github.com/quanteda/quanteda). See our [Contributor Code
of
Conduct](https://github.com/quanteda/quanteda/blob/master/CONDUCT.md)
and the all-important **quanteda** [Style
Guide](https://github.com/quanteda/quanteda/wiki/Style-guide).
- Issues, bug reports, and wish lists: [File a GitHub
issue](https://github.com/quanteda/quanteda/issues).
- Contact [the maintainer](mailto:kbenoit@lse.ac.uk) by email.
7 changes: 3 additions & 4 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# Submission notes

Changes to Matrix package coercions required to avoid warnings in forthcoming
Matrix 1.4-2 release.
Fixes test failures caused by recent changes to Matrix package behaviours.

## Test environments

* local macOS 12.5, R 4.2.1
* Ubuntu 20.04 LTS, R 4.2.1
* local macOS 12.6.1, R 4.2.2
* Ubuntu 20.04 LTS, R 4.2.2
* Windows release via devtools::check_win_release()
* Windows devel via devtools::check_win_devel()
* Windows oldrelease via devtools::check_win_oldrelease()
Expand Down
Binary file modified data/data_dictionary_LSD2015.rda
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/articles/pkgdown/examples/japanese_speech_ja.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ for (year in 1947:2017) {
cat(as.character(Sys.time()), year, committee, "\n")
temp <- get_meeting(meetingName = committee, year = year)
if (is.null(temp)) next
saveRDS(temp, file = sprintf("%s/%s_%s.rds", folder_download, year, committee))
saveRDS(temp, file = stringi::stri_sprintf("%s/%s_%s.rds", folder_download, year, committee))
Sys.sleep(10)
}
Expand Down
4 changes: 2 additions & 2 deletions man/data_dictionary_LSD2015.Rd

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

2 changes: 1 addition & 1 deletion man/dictionary.Rd

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

2 changes: 1 addition & 1 deletion man/msg.Rd

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

2 changes: 1 addition & 1 deletion tests/data_creation/update_dictionary_objects.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The dictionary consists of 2,858 "negative" sentiment words and 1,709 "positive"
Please cite this article when using the Lexicoder Sentiment Dictionary and related resources. Young, L. & Soroka, S. (2012). Lexicoder Sentiment Dictionary. Available at http://lexicoder.com.
',
source = "Young, L. & Soroka, S. (2012). Affective News: The Automated Coding of Sentiment in Political Texts. Political Communication, 29(2), 205–231.",
url = "http://www.snsoroka.com/data-lexicoder/",
url = "https://www.snsoroka.com/data-lexicoder/",
license = "The LSD is available for non-commercial academic purposes only. By using data_dictionary_LSD2015, you accept these terms. Please cite the references below when using the dictionary.",
keywords = c("political", "news", "sentiment", "media")
)
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-dfm_weight.R
Original file line number Diff line number Diff line change
Expand Up @@ -270,3 +270,4 @@ test_that("featfreq() works", {
c(a = 4, b = 2, c = 1)
)
})

0 comments on commit bff2cee

Please sign in to comment.