Skip to content

Commit

Permalink
Merge pull request #177 from KrishnaswamyLab/dev
Browse files Browse the repository at this point in the history
Rmagic v2.0.3
  • Loading branch information
scottgigante authored Nov 20, 2019
2 parents fae72d9 + 8caad8c commit dabadee
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ install:
- cd ..

script:
- python -c "import magic"
- cd Rmagic; R CMD build .
- R CMD check *tar.gz
- cd ../python; pip install --user -q .[test]
Expand Down
23 changes: 14 additions & 9 deletions Rmagic/R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,22 @@ null_equal <- function(x, y) {
}

check_pymagic_version <- function() {
version <- strsplit(pymagic$`__version__`, '\\.')[[1]]
major_version <- 1
minor_version <- 5
if (as.integer(version[1]) < major_version) {
pyversion <- strsplit(pymagic$`__version__`, '\\.')[[1]]
rversion <- strsplit(as.character(packageVersion("Rmagic")), '\\.')[[1]]
major_version <- as.integer(rversion[1])
minor_version <- as.integer(rversion[2])
if (as.integer(pyversion[1]) < major_version) {
warning(paste0("Python MAGIC version ", pymagic$`__version__`, " is out of date (recommended: ",
major_version, ".", minor_version, "). Please update with pip ",
"(e.g. pip install magic-impute) or Rmagic::install.magic()."))
} else if (as.integer(version[2]) < minor_version) {
"(e.g. pip install --upgrade magic-impute) or Rmagic::install.magic()."))
return(FALSE)
} else if (as.integer(pyversion[2]) < minor_version) {
warning(paste0("Python MAGIC version ", pymagic$`__version__`, " is out of date (recommended: ",
major_version, ".", minor_version, "). Consider updating with pip ",
"(e.g. pip install magic-impute) or Rmagic::install.magic()."))
"(e.g. pip install --upgrade magic-impute) or Rmagic::install.magic()."))
return(FALSE)
}
return(TRUE)
}

failed_pymagic_import <- function(e) {
Expand All @@ -37,7 +41,7 @@ failed_pymagic_import <- function(e) {
} else if (length(grep("r\\-reticulate", reticulate::py_config()$python)) > 0) {
# installed, but envs sometimes give weird results
message("Consider removing the 'r-reticulate' environment by running:")
if (grep("virtualenvs", reticulate::py_config()$python)) {
if (length(grep("virtualenvs", reticulate::py_config()$python)) > 0) {
message("reticulate::virtualenv_remove('r-reticulate')")
} else {
message("reticulate::conda_remove('r-reticulate')")
Expand Down Expand Up @@ -66,7 +70,8 @@ load_pymagic <- function() {
#' @export
pymagic_is_available <- function() {
tryCatch({
reticulate::py_module_available("magic")$MAGIC
reticulate::import("magic")$MAGIC
check_pymagic_version()
},
error = function(e) {
FALSE
Expand Down

0 comments on commit dabadee

Please sign in to comment.