Skip to content

Commit

Permalink
Fix #19
Browse files Browse the repository at this point in the history
  • Loading branch information
James-Thorson-NOAA committed Apr 2, 2024
1 parent ffad27d commit dc3887b
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 35 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: dsem
Type: Package
Title: Fit Dynamic Structural Equation Models
Version: 1.2.0
Date: 2024-03-29
Version: 1.2.1
Date: 2024-04-02
Authors@R:
c(person(given = "James",
family = "Thorson",
Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ S3method(vcov,dsem)
export(TMBAIC)
export(as_fitted_DAG)
export(as_sem)
export(checkDepPackageVersion)
export(classify_variables)
export(dsem)
export(dsem_control)
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# dsem 1.2.1

* removing `checkDepPackageVersion(dep_pkg="Matrix", this_pkg="TMB")` from `.onLoad()`
as requested by K. Kristensen

# dsem 1.2.0

* Adding option to specify covariance via argument `covs`
Expand Down
61 changes: 30 additions & 31 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,36 @@
#' @param warn give warning?
#' @return logical: TRUE if the binary versions match
#' @importFrom utils packageVersion
#' @export
checkDepPackageVersion <- function(dep_pkg = "TMB",
this_pkg = "dsem",
write_file = FALSE,
warn = TRUE) {
cur_dep_version <- as.character(packageVersion(dep_pkg))
fn <- sprintf("%s-version", dep_pkg)
if (write_file) {
cat(sprintf("current %s version=%s: writing file\n", dep_pkg, cur_dep_version))
writeLines(cur_dep_version, con = fn)
return(cur_dep_version)
}
fn <- system.file(fn, package=this_pkg)
built_dep_version <- scan(file=fn, what=character(), quiet=TRUE)
result_ok <- identical(built_dep_version, cur_dep_version)
if(warn && !result_ok) {
warning(
"Package version inconsistency detected.\n",
sprintf("%s was built with %s version %s",
this_pkg, dep_pkg, built_dep_version),
"\n",
sprintf("Current %s version is %s",
dep_pkg, cur_dep_version),
"\n",
sprintf("Please re-install %s from source ", this_pkg),
"or restore original ",
sQuote(dep_pkg), " package (see '?reinstalling' for more information)"
)
}
return(result_ok)
}
#checkDepPackageVersion <- function(dep_pkg = "TMB",
# this_pkg = "dsem",
# write_file = FALSE,
# warn = TRUE) {
# cur_dep_version <- as.character(packageVersion(dep_pkg))
# fn <- sprintf("%s-version", dep_pkg)
# if (write_file) {
# cat(sprintf("current %s version=%s: writing file\n", dep_pkg, cur_dep_version))
# writeLines(cur_dep_version, con = fn)
# return(cur_dep_version)
# }
# fn <- system.file(fn, package=this_pkg)
# built_dep_version <- scan(file=fn, what=character(), quiet=TRUE)
# result_ok <- identical(built_dep_version, cur_dep_version)
# if(warn && !result_ok) {
# warning(
# "Package version inconsistency detected.\n",
# sprintf("%s was built with %s version %s",
# this_pkg, dep_pkg, built_dep_version),
# "\n",
# sprintf("Current %s version is %s",
# dep_pkg, cur_dep_version),
# "\n",
# sprintf("Please re-install %s from source ", this_pkg),
# "or restore original ",
# sQuote(dep_pkg), " package (see '?reinstalling' for more information)"
# )
# }
# return(result_ok)
#}

#' @name reinstalling
#' @rdname reinstalling
Expand Down
2 changes: 1 addition & 1 deletion R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# See: https://mail.google.com/mail/u/0/#inbox/QgrcJHsNjpqZNGJhNMVHcfGFDLLMfrvqqHl
.onLoad <- function(libname, pkgname) {
#checkDepPackageVersion(dep_pkg="TMB", this_pkg="dsem")
checkDepPackageVersion(dep_pkg="Matrix", this_pkg="TMB")
#checkDepPackageVersion(dep_pkg="Matrix", this_pkg="TMB")
}

.onUnload <- function(libpath) {
Expand Down

0 comments on commit dc3887b

Please sign in to comment.