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

Use scalar operators and outer negation in if statements #116

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion R/otp-isochrone-batch.R
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ otp_process_results_iso <- function(text, fromID){
response$id <- seq(1, nrow(response))
response$fromPlace <- fromID

if (any(!sf::st_is_valid(response))) {
if (!all(sf::st_is_valid(response))) {
suppressMessages(suppressWarnings(response <- sf::st_make_valid(response)))
}

Expand Down
10 changes: 5 additions & 5 deletions R/otp-plan.R
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
checkmate::assert_logical(distance_balance, len = 1, null.ok = FALSE)
checkmate::assert_logical(get_elevation, len = 1, null.ok = FALSE)

if (distance_balance & (ncores > 1)) {
if (distance_balance && (ncores > 1)) {
if (is.null(fromID)) {
stop("Distance balancing changes the order of the output, so fromID must not be NULL")
}
Expand Down Expand Up @@ -187,13 +187,13 @@
nrfp <- nrow(fromPlace)
nrtp <- nrow(toPlace)
if (nrfp != nrtp) {
if (nrfp > nrtp & nrtp == 1) {
if (nrfp > nrtp && nrtp == 1) {
toPlace <- toPlace[rep(1, times = nrfp), ]
if (!is.null(toID)) {
toID <- toID[rep(1, times = nrfp)]
}
message("repeating toPlace to match length of fromPlace")
} else if (nrtp > nrfp & nrfp == 1) {
} else if (nrtp > nrfp && nrfp == 1) {
fromPlace <- fromPlace[rep(1, times = nrtp), ]
if (!is.null(fromID)) {
fromID <- fromID[rep(1, times = nrtp)]
Expand All @@ -204,7 +204,7 @@
}
}

if (distance_balance & (ncores > 1)) {
if (distance_balance && (ncores > 1)) {
dists <- geodist::geodist(fromPlace, toPlace, paired = TRUE)

# Remove 0m pairs as OTP will fail on them anyway
Expand Down Expand Up @@ -243,7 +243,7 @@

if (otpcon$otp_version >= 2) {
# maxWalkDistance causes itinaries to fail
if (mode == "CAR" | grepl("TRANSIT", mode)) {
if (mode == "CAR" || grepl("TRANSIT", mode)) {

Check warning on line 246 in R/otp-plan.R

View check run for this annotation

Codecov / codecov/patch

R/otp-plan.R#L246

Added line #L246 was not covered by tests
query$maxWalkDistance <- NULL
}
}
Expand Down
12 changes: 6 additions & 6 deletions R/otp-setup.R
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ otp_stop <- function(warn = TRUE, kill_all = TRUE) {
)
}

if (checkmate::testOS("linux") | checkmate::testOS("mac")) {
if (checkmate::testOS("linux") || checkmate::testOS("mac")) {
message("The following Java instances have been found:")
system("ps -A |grep java")
if (!kill_all) {
Expand Down Expand Up @@ -456,7 +456,7 @@ otp_checks <- function(otp = NULL,
chkG <- file.exists(paste0(dir, "/graphs/", router, "/Graph.obj"))
chkg <- file.exists(paste0(dir, "/graphs/", router, "/graph.obj"))

if(!(chkG | chkg)){
if(!(chkG || chkg)){
stop("File does not exist")
}

Expand Down Expand Up @@ -525,7 +525,7 @@ otp_check_java <- function(otp_version = 1.5) {
}

if (otp_version < 2) {
if (java_version >= 1.8 & java_version < 1.9) {
if (java_version >= 1.8 && java_version < 1.9) {
message("You have the correct version of Java for OTP 1.x")
return(TRUE)
}
Expand All @@ -544,8 +544,8 @@ otp_check_java <- function(otp_version = 1.5) {
return(FALSE)
}

if (otp_version >= 2 & otp_version <= 2.1) {
if (java_version >= 1.8 & java_version < 1.9) {
if (otp_version >= 2 && otp_version <= 2.1) {
if (java_version >= 1.8 && java_version < 1.9) {
warning("You have OTP 2.0 or 2.1 but the version of Java for OTP 1.x")
return(FALSE)
}
Expand All @@ -565,7 +565,7 @@ otp_check_java <- function(otp_version = 1.5) {
}

if (otp_version >= 2.2) {
if (java_version >= 1.8 & java_version < 1.9) {
if (java_version >= 1.8 && java_version < 1.9) {
warning("You have OTP 2.2+ but the version of Java for OTP 1.x")
return(FALSE)
}
Expand Down
2 changes: 1 addition & 1 deletion R/utility-functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ parse_leg <- function(leg,
leg$from <- NULL
leg$to <- NULL

if (get_elevation | full_elevation) {
if (get_elevation || full_elevation) {
elevation <- purrr::map(leg$steps, parse_elevation)
} else {
elevation <- list(NULL)
Expand Down
Loading