Skip to content

Commit

Permalink
Rename validate-vars-dict -> check-vars-dict
Browse files Browse the repository at this point in the history
  • Loading branch information
jeancochrane committed Jan 14, 2025
1 parent a6fe42a commit 41eac0e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ repos:
entry: Cannot commit .Rhistory, .RData, .Rds or .rds.
language: fail
files: '\.(Rhistory|RData|Rds|rds)$'
- id: validate-vars-dict
- id: check-vars-dict
name: Validate vars_dict
entry: Rscript scripts/validate-vars-dict.R
entry: Rscript scripts/check-vars-dict.R
files: data/vars_dict.rda
language: r
- repo: https://github.com/astral-sh/ruff-pre-commit
Expand Down
6 changes: 3 additions & 3 deletions scripts/validate-vars-dict.R → scripts/check-vars-dict.R
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Script to check that the `vars_dict` data object is well-formed
load("data/vars_dict.rda")

# Check for duplicate model parameters
non_na_model_vars <- subset(
vars_dict,
!is.na(var_name_model)
)[c("var_name_model", "var_code", "var_value")]

dupes <- non_na_model_vars[which(duplicated(non_na_model_vars)), ]

if (nrow(dupes) > 0) {
dupe_var_names <- dupes$var_name_model
stop(
"Duplicate var_name_model entries in vars_dict: ",
paste(dupe_var_names, collapse = ", ")
paste(dupes$var_name_model, collapse = ", ")
)
}

0 comments on commit 41eac0e

Please sign in to comment.