Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pre commit #22

Merged
merged 2 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- uses: actions/checkout@v4

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

- uses: r-lib/actions/[email protected]

- uses: r-lib/actions/setup-r-dependencies@v2
Expand All @@ -36,4 +36,3 @@ jobs:
shell: Rscript {0}
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

23 changes: 23 additions & 0 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Pre-commit

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
pre-commit:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v3

- name: Run pre-commit hooks
uses: pre-commit/[email protected]
12 changes: 4 additions & 8 deletions .github/workflows/r.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:

name: R-CMD-check-final

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

jobs:
Expand Down Expand Up @@ -82,7 +82,7 @@ jobs:
name: epiworldR-built-package-${{ matrix.config.os }}-${{ matrix.config.r }}
path: epiworldR_*.tar.gz
retention-days: 7

epiworldShiny:
runs-on: ubuntu-latest
container: rocker/tidyverse:4.4.0
Expand All @@ -98,7 +98,7 @@ jobs:
run: |
install2.r -n 2 shinyjs shinydashboard DT shinycssloaders plotly
installGithub.r UofUEpiBio/epiworldR@${{ github.sha }}

- name: Check the package
run: |
R CMD build .
Expand All @@ -118,11 +118,7 @@ jobs:
run: |
install2.r -n 2 shinyjs shinydashboard DT shinycssloaders plotly
installGithub.r UofUEpiBio/epiworldR@${{ github.sha }}

- name: Check the package
run: |
R CMD check --no-manual epiworldRShiny_*tar.gz




31 changes: 31 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: trailing-whitespace
exclude: ^(inst/|man/|src/cpp11.cpp|playgroud/|R/cpp11.R)
- id: end-of-file-fixer
exclude: ^(inst/|man/|src/cpp11.cpp|playgroud/|R/cpp11.R)
- id: check-yaml
exclude: ^(inst/|man/|src/cpp11.cpp|playgroud/|R/cpp11.R)
- id: check-added-large-files
exclude: ^(inst/|man/|src/cpp11.cpp|playgroud/|R/cpp11.R)
- id: detect-private-key
exclude: ^(inst/|man/|src/cpp11.cpp|playgroud/|R/cpp11.R)

- repo: https://github.com/lorenzwalthert/precommit
rev: v0.4.2
hooks:
- id: style-files
args:
[
'--ignore-start="^# styler: off$"',
'--ignore-stop="^# styler: on$"',
'--strict=FALSE'
]
exclude: ^(inst/|man/|src/cpp11.cpp|playgroud/|R/cpp11.R)
- id: readme-rmd-rendered
# - id: lintr
# args: [--warn_only]
# verbose: true
# exclude: ^(inst/|man/|src/cpp11.cpp|playgroud/|R/cpp11.R)
2 changes: 1 addition & 1 deletion .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
}
],
"version": 4
}
}
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@
"editor.insertSpaces": true,
"editor.detectIndentation": false
}
}
}
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ representative at an online or offline event.
## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at [email protected].
reported to the community leaders responsible for enforcement at [email protected].
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
Expand Down
8 changes: 4 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Version: 0.3-2
Authors@R: c(
person(given="George", family="Vega Yon", role=c("aut","cre"),
email="[email protected]", comment = c(ORCID = "0000-0002-3171-0844")),
person(given="Derek", family="Meyer", role=c("aut"),
person(given="Derek", family="Meyer", role=c("aut"),
email="[email protected]", comment = c(ORCID = "0009-0005-1350-6988")),
person(given="Susan", family="Holmes", role = "rev", comment =
c(what = "JOSS reviewer", ORCID="0000-0002-2208-8168")),
Expand All @@ -17,20 +17,20 @@ Authors@R: c(
Description: A flexible framework for Agent-Based Models (ABM), the 'epiworldR' package provides methods for prototyping disease outbreaks and transmission models using a 'C++' backend, making it very fast. It supports multiple epidemiological models, including the Susceptible-Infected-Susceptible (SIS), Susceptible-Infected-Removed (SIR), Susceptible-Exposed-Infected-Removed (SEIR), and others, involving arbitrary mitigation policies and multiple-disease models. Users can specify infectiousness/susceptibility rates as a function of agents' features, providing great complexity for the model dynamics. Furthermore, 'epiworldR' is ideal for simulation studies featuring large populations.
URL: https://github.com/UofUEpiBio/epiworldR,
https://uofuepibio.github.io/epiworldR/,
https://uofuepibio.github.io/epiworldR-workshop/
https://uofuepibio.github.io/epiworldR-workshop/
BugReports: https://github.com/UofUEpiBio/epiworldR/issues
License: MIT + file LICENSE
RoxygenNote: 7.3.2
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
LinkingTo: cpp11
Suggests:
Suggests:
knitr,
rmarkdown,
tinytest,
netplot,
igraph,
data.table
Imports:
Imports:
utils
VignetteBuilder: knitr
17 changes: 8 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
VERSION := $(shell grep Version DESCRIPTION | sed -e 's/Version: //')


build:
build:
cd .. && R CMD build epiworldR

debug: clean
docker run --rm -ti -w/mnt -v $(PWD):/mnt uofuepibio/epiworldr:debug make docker-debug
docker run --rm -ti -w/mnt -v $(PWD):/mnt uofuepibio/epiworldr:debug make docker-debug

docker-debug:
EPI_CONFIG="-DEPI_DEBUG -Wall -pedantic -g" R CMD INSTALL \
Expand All @@ -15,33 +15,33 @@ docker-debug:
install-dev: clean
sed -i -E 's/@useDynLib\s+[a-zA-Z]+/@useDynLib epiworldRdev/g' R/epiworldR-package.R
sed -i -E 's/useDynLib\(+[a-zA-Z]+/useDynLib(epiworldRdev/g' NAMESPACE
sed -i -E 's/^Package:.+/Package: epiworldRdev/g' DESCRIPTION
sed -i -E 's/^Package:.+/Package: epiworldRdev/g' DESCRIPTION
sed -i -E 's/^library\(epiworldR\)/library(epiworldRdev)/g' README.*
Rscript --vanilla -e 'roxygen2::roxygenize()'
EPI_DEV=yes R CMD INSTALL .& $(MAKE) clean

install:
install:
cd .. && \
R CMD INSTALL epiworldR_$(VERSION).tar.gz


README.md: README.Rmd
Rscript --vanilla -e 'rmarkdown::render("README.Rmd")'

# update:
# wget https://raw.githubusercontent.com/UofUEpiBio/epiworld/master/epiworld.hpp && \
# mv epiworld.hpp inst/include/epiworld.hpp
# mv epiworld.hpp inst/include/epiworld.hpp
local-update:
rsync -avz ../epiworld/include/epiworld inst/include/.

check: build
cd .. && R CMD check epiworldR_*.tar.gz

clean:
clean:
rm -f src/*.dll src/*.so src/*.o
sed -i -E 's/@useDynLib\s+[a-zA-Z]+/@useDynLib epiworldR/g' R/epiworldR-package.R
sed -i -E 's/useDynLib\(+[a-zA-Z]+/useDynLib(epiworldR/g' NAMESPACE
sed -i -E 's/^Package:.+/Package: epiworldR/g' DESCRIPTION
sed -i -E 's/^Package:.+/Package: epiworldR/g' DESCRIPTION
# sed -i -E 's/^\\(name|alias|title)\{[a-zA-Z]+/\\\1{epiworldR/g' man/epiworldR-package.Rd
sed -i -E 's/^library\(epiworldRdev\)/library(epiworldR)/g' README.*

Expand All @@ -52,4 +52,3 @@ docs:

checkv: build
R CMD check --as-cran --use-valgrind epiworldR*.tar.gz

2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* Ports the `Entity` class. Entities are used to group agents within a model.

* Refactors `add_tool`, `add_virus`, and `add_entity` simplifying syntax. Now,
these functions only receive the model and object. Prevalence is
these functions only receive the model and object. Prevalence is
specified in the object itself. `add_tool_n` and `add_virus_n` are now
deprecated.

Expand Down
51 changes: 25 additions & 26 deletions R/ModelDiffNet.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#' Network Diffusion Model
#'
#' The network diffusion model is a simple model that assumes that
#' the probability of adoption of a behavior is proportional to the
#'
#' The network diffusion model is a simple model that assumes that
#' the probability of adoption of a behavior is proportional to the
#' number of adopters in the network.
#'
#' @export
#'
#' @export
#' @param name Name of the model.
#' @param prevalence Prevalence of the disease.
#' @param prob_adopt Probability of adoption.
Expand All @@ -22,52 +22,52 @@
#' \deqn{
#' P(adopt) = \mbox{Logit}^{-1}(prob\_adopt + params * data + exposure)
#' }
#' Where exposure is the number of adopters in the agent's network.
#'
#' Where exposure is the number of adopters in the agent's network.
#'
#' Another important difference is that the transmission network is not
#' necesary useful since adoption in this model is not from a particular
#' neighbor.
#'
#'
#' @examples
#' set.seed(2223)
#' n <- 10000
#'
#'
#' # Generating synthetic data on a matrix with 2 columns.
#' X <- cbind(
#' age = sample(1:100, n, replace = TRUE),
#' female = sample.int(2, n, replace = TRUE) - 1
#' age = sample(1:100, n, replace = TRUE),
#' female = sample.int(2, n, replace = TRUE) - 1
#' )
#'
#'
#' adopt_chatgpt <- ModelDiffNet(
#' "ChatGPT",
#' prevalence = .01,
#' prob_adopt = .1,
#' data = X,
#' params = c(1, 4)
#' )
#'
#'
#' # Simulating a population from smallworld
#' agents_smallworld(adopt_chatgpt, n, 8, FALSE, .01)
#'
#'
#' # Running the model for 50 steps
#' run(adopt_chatgpt, 50)
#'
#'
#' # Plotting the model
#' plot(adopt_chatgpt)
#' @aliases epiworld_diffnet
ModelDiffNet <- function(
name,
prevalence,
prob_adopt,
normalize_exposure = TRUE,
data = matrix(nrow = 0, ncol = 0),
data_cols = 1L:ncol(data),
params = vector("double")
) {
name,
prevalence,
prob_adopt,
normalize_exposure = TRUE,
data = matrix(nrow = 0, ncol = 0),
data_cols = 1L:ncol(data),
params = vector("double")
) {

if (length(data) == 0L)
data_cols <- vector("integer")
else
else
data_cols <- as.integer(data_cols) - 1L

structure(
Expand All @@ -80,7 +80,7 @@ ModelDiffNet <- function(
ncol(data),
data_cols,
params
),
),
class = c("epiworld_diffnet", "epiworld_model")
)

Expand All @@ -94,4 +94,3 @@ ModelDiffNet <- function(
plot.epiworld_diffnet <- function(x, main = get_name(x), ...) {
plot_epi(x, main = main, ...)
}

Loading
Loading