Skip to content

Commit

Permalink
(v2.1.1.9131) implement testthat
Browse files Browse the repository at this point in the history
  • Loading branch information
msberends committed Jan 27, 2025
1 parent 92166c1 commit f039339
Show file tree
Hide file tree
Showing 63 changed files with 172 additions and 267 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,49 +55,44 @@ jobs:
# current development version, check all major OSes:
- {os: macOS-latest, r: 'devel', allowfail: false}
- {os: windows-latest, r: 'devel', allowfail: false}
- {os: ubuntu-latest, r: 'devel', allowfail: false}
- {os: ubuntu-latest, r: 'devel', allowfail: false, http-user-agent: 'release'}

# current 'release' version, check all major OSes:
- {os: macOS-latest, r: 'release', allowfail: false}
- {os: windows-latest, r: 'release', allowfail: false}
- {os: ubuntu-latest, r: 'release', allowfail: false}

# older versions (see also check-old.yaml for even older versions):
# older versions (see also check-old-tinytest.yaml for even older versions):
- {os: ubuntu-latest, r: '4.3', allowfail: false}
- {os: ubuntu-latest, r: '4.2', allowfail: false}
- {os: ubuntu-latest, r: '4.1', allowfail: false}
- {os: ubuntu-latest, r: '4.0', allowfail: false} # when a new R releases, this one has to move to check-old.yaml
- {os: ubuntu-latest, r: '4.0', allowfail: false}
- {os: ubuntu-latest, r: '3.6', allowfail: false}
# when testthat loses support for a version, move it to check-old-tinytest.yaml

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

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

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

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
# use RStudio Package Manager to quickly install packages
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: check
upgrade: 'TRUE'

- uses: r-lib/actions/check-r-package@v2
env:
_R_CHECK_LENGTH_1_CONDITION_: verbose
_R_CHECK_LENGTH_1_LOGIC2_: verbose
# during 'R CMD check', R_LIBS_USER will be overwritten, so:
R_LIBS_USER_GH_ACTIONS: ${{ env.R_LIBS_USER }}
R_RUN_TINYTEST: true

- name: Show tinytest output
if: always()
run: |
find . -name 'tinytest.Rout*' -exec cat '{}' \; || true
shell: bash
with:
upload-snapshots: true
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ jobs:
# this is a required value to run the unit tests:
R_RUN_TINYTEST: true
run: |
mv tests/testthat inst/
rm tests/testthat.R
mv tests/tinytest.R.old tests/tinytest.R
cd ..
R CMD build AMR
R CMD check --as-cran --no-manual --run-donttest AMR_*.tar.gz
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ jobs:
runs-on: ubuntu-latest

steps:

- name: Checkout code
uses: actions/checkout@v3

Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: AMR
Version: 2.1.1.9129
Version: 2.1.1.9131
Date: 2025-01-27
Title: Antimicrobial Resistance Data Analysis
Description: Functions to simplify and standardise antimicrobial resistance (AMR)
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# AMR 2.1.1.9129
# AMR 2.1.1.9131

*(this beta version will eventually become v3.0. We're happy to reach a new major milestone soon, which will be all about the new One Health support! Install this beta using [the instructions here](https://msberends.github.io/AMR/#latest-development-version).)*

Expand Down
2 changes: 1 addition & 1 deletion PythonPackage/AMR/AMR.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 2.2
Name: AMR
Version: 2.1.1.9129
Version: 2.1.1.9131
Summary: A Python wrapper for the AMR R package
Home-page: https://github.com/msberends/AMR
Author: Matthijs Berends
Expand Down
Binary file not shown.
Binary file removed PythonPackage/AMR/dist/amr-2.1.1.9129.tar.gz
Binary file not shown.
Binary file added PythonPackage/AMR/dist/amr-2.1.1.9131.tar.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion PythonPackage/AMR/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='AMR',
version='2.1.1.9129',
version='2.1.1.9131',
packages=find_packages(),
install_requires=[
'rpy2',
Expand Down
2 changes: 1 addition & 1 deletion R/ggplot_pca.R
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ ggplot_pca <- function(x,
g <- g + ggplot2::geom_path(
data = ell,
ggplot2::aes(colour = groups, group = groups),
size = ellipse_size,
linewidth = ellipse_size,
alpha = points_alpha
)
}
Expand Down
10 changes: 4 additions & 6 deletions R/ggplot_sir.R
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,7 @@ ggplot_sir <- function(data,
meet_criteria(caption, allow_class = "character", has_length = 1, allow_NULL = TRUE)
meet_criteria(x.title, allow_class = "character", has_length = 1, allow_NULL = TRUE)
meet_criteria(y.title, allow_class = "character", has_length = 1, allow_NULL = TRUE)

# we work with aes_string later on

x_deparse <- deparse(substitute(x))
if (x_deparse != "x") {
x <- x_deparse
Expand Down Expand Up @@ -309,8 +308,7 @@ geom_sir <- function(position = NULL,
if (identical(position, "fill")) {
position <- ggplot2::position_fill(vjust = 0.5, reverse = TRUE)
}

# we work with aes_string later on

x_deparse <- deparse(substitute(x))
if (x_deparse != "x") {
x <- x_deparse
Expand All @@ -324,7 +322,7 @@ geom_sir <- function(position = NULL,
} else if (tolower(x) %in% tolower(c("SIR", "sir", "interpretations", "result"))) {
x <- "interpretation"
}

ggplot2::geom_col(
data = function(x) {
sir_df(
Expand All @@ -335,7 +333,7 @@ geom_sir <- function(position = NULL,
combine_SI = combine_SI
)
},
mapping = ggplot2::aes_string(x = x, y = y, fill = fill),
mapping = utils::modifyList(ggplot2::aes(), list(x = str2lang(x), y = str2lang(y), fill = str2lang(fill))),
position = position,
...
)
Expand Down
8 changes: 2 additions & 6 deletions R/plotting.R
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,6 @@ facet_sir <- function(facet = c("interpretation", "antibiotic"), nrow = NULL) {
meet_criteria(facet, allow_class = "character", has_length = 1)
meet_criteria(nrow, allow_class = c("numeric", "integer"), has_length = 1, allow_NULL = TRUE, is_positive = TRUE, is_finite = TRUE)

# we work with aes_string later on
facet_deparse <- deparse(substitute(facet))
if (facet_deparse != "facet") {
facet <- facet_deparse
Expand Down Expand Up @@ -1107,13 +1106,10 @@ labels_sir_count <- function(position = NULL,
if (identical(position, "fill")) {
position <- ggplot2::position_fill(vjust = 0.5, reverse = TRUE)
}

x_name <- x
ggplot2::geom_text(
mapping = ggplot2::aes_string(
label = "lbl",
x = x,
y = "value"
),
mapping = utils::modifyList(ggplot2::aes(), list(label = str2lang("lbl"), x = str2lang(x), y = str2lang("value"))),
position = position,
inherit.aes = FALSE,
size = datalabels.size,
Expand Down
27 changes: 17 additions & 10 deletions data-raw/_generate_GPT_knowledge_input.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,22 @@ version="$1"
output_file="data-raw/gpt_training_text_v${version}.txt"

# Clear the output file if it exists
echo "This files contains all context you must know about the AMR package for R." > "$output_file"
echo "This knowledge base contains all context you must know about the AMR package for R. You are a GPT trained to be an assistant for the AMR package in R. You are an incredible R specialist, especially trained in this package and in the tidyverse." > "$output_file"
echo "" >> "$output_file"
echo "First and foremost, you are trained on version ${version}. Remember this whenever someone asks which AMR package version you’re at." >> "$output_file"
echo "--------------------------------" >> "$output_file"
echo "" >> "$output_file"
echo "Below are the contents of the `NAMESPACE` file, the `index.md` file, and all the `man/*.Rd` files (documentation) in the package. Every file content is split using 100 hypens." >> "$output_file"
echo "----------------------------------------------------------------------------------------------------" >> "$output_file"
echo "" >> "$output_file"

# Function to remove header block (delimited by # ======)
remove_header() {
sed '/# =\{6,\}/,/# =\{6,\}/d' "$1"
}

# Process all .R files in the 'R' folder
# # Process all .R files in the 'R' folder
# for file in R/*.R; do
# echo "--------------------------------------------------" >> "$output_file"
# echo "THE PART HEREAFTER CONTAINS CONTENTS FROM FILE '$file':" >> "$output_file"
# echo -e "\n" >> "$output_file"
# remove_header "$file" >> "$output_file"
Expand All @@ -34,6 +38,7 @@ remove_header() {
# Process important metadata files (DESCRIPTION, NAMESPACE, index.md)
for file in NAMESPACE index.md; do
if [[ -f $file ]]; then
echo "----------------------------------------------------------------------------------------------------" >> "$output_file"
echo "THE PART HEREAFTER CONTAINS CONTENTS FROM FILE '$file':" >> "$output_file"
echo -e "\n" >> "$output_file"
cat "$file" >> "$output_file"
Expand All @@ -43,6 +48,7 @@ done

# Process all .Rd files from the 'man' folder
for file in man/*.Rd; do
echo "----------------------------------------------------------------------------------------------------" >> "$output_file"
echo "THE PART HEREAFTER CONTAINS CONTENTS FROM FILE '$file':" >> "$output_file"
echo -e "\n" >> "$output_file"
remove_header "$file" >> "$output_file"
Expand All @@ -51,19 +57,20 @@ done

# Process all .Rmd files in the 'vignettes' folder
for file in vignettes/*.Rmd; do
echo "----------------------------------------------------------------------------------------------------" >> "$output_file"
echo "THE PART HEREAFTER CONTAINS CONTENTS FROM FILE '$file':" >> "$output_file"
echo -e "\n" >> "$output_file"
remove_header "$file" >> "$output_file"
echo -e "\n\n" >> "$output_file"
done

# Process all .Rmd files in the 'vignettes' folder
echo "THE PART HEREAFTER CONTAINS THE README OF OUR PYTHON PACKAGE" >> "$output_file"
echo -e "\n" >> "$output_file"
for file in PythonPackage/AMR/README.md; do
remove_header "$file" >> "$output_file"
echo -e "\n\n" >> "$output_file"
done
# Process README.md
# echo "THE PART HEREAFTER CONTAINS THE README OF OUR PYTHON PACKAGE" >> "$output_file"
# echo -e "\n" >> "$output_file"
# for file in PythonPackage/AMR/README.md; do
# remove_header "$file" >> "$output_file"
# echo -e "\n\n" >> "$output_file"
# done

# Process test files (if available) in the 'tests' folder
# for file in tests/*.R; do
Expand Down
Loading

0 comments on commit f039339

Please sign in to comment.