Skip to content

Commit

Permalink
Merge pull request #232 from UrbanAnalyst/pairwise-flows
Browse files Browse the repository at this point in the history
from/to as coord matrices for #229
  • Loading branch information
mpadge authored Jun 6, 2024
2 parents 13359c0 + bc7f205 commit 84aaea9
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 15 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: dodgr
Title: Distances on Directed Graphs
Version: 0.4.0.011
Version: 0.4.0.014
Authors@R: c(
person("Mark", "Padgham", , "[email protected]", role = c("aut", "cre")),
person("Andreas", "Petutschnig", role = "aut"),
Expand Down
4 changes: 4 additions & 0 deletions R/dists.R
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,10 @@ get_index_id_cols <- function (graph,
is.matrix (pts) ||
is.data.frame (pts)) {
index <- get_pts_index (graph, gr_cols, vert_map, pts)
if ((is.matrix (pts) || is.data.frame (pts)) &&
!any (duplicated (index))) {
rownames (pts) <- vert_map$vert [index]
}
} else {
stop (
"routing points are of unknown form; must be either ",
Expand Down
34 changes: 21 additions & 13 deletions R/flows.R
Original file line number Diff line number Diff line change
Expand Up @@ -202,19 +202,7 @@ dodgr_flows_aggregate <- function (graph,
stop ("flows matrix is not compatible with 'from'/'to' arguments")
}
if (pairwise) {
if (length (from) != length (to)) {
stop (
"'from' and 'to' must be the same length ",
"when using 'pairwise = TRUE'.",
call. = FALSE
)
}
if (nrow (flows) != length (from)) {
stop (
"'flows' must be the same length as 'from' and 'to'",
call. = FALSE
)
}
check_pairwise_from_to (from, to, flows)
}

if (!quiet) {
Expand Down Expand Up @@ -597,6 +585,26 @@ check_k <- function (k, from) {
list (k = k, nk = nk)
}

check_pairwise_from_to <- function (from, to, flows) {

nf <- ifelse (is.vector (from), length (from), nrow (from))
nt <- ifelse (is.vector (to), length (to), nrow (to))

if (nf != nt) {
stop (
"'from' and 'to' must be the same length or dimensions",
"when using 'pairwise = TRUE'.",
call. = FALSE
)
}
if (nrow (flows) != nf) {
stop (
"'flows' must be the same length or dimensions as 'from' and 'to'",
call. = FALSE
)
}
}

get_random_prefix <- function (prefix = "flow",
n = 5) {

Expand Down
2 changes: 1 addition & 1 deletion codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"codeRepository": "https://github.com/UrbanAnalyst/dodgr",
"issueTracker": "https://github.com/UrbanAnalyst/dodgr/issues",
"license": "https://spdx.org/licenses/GPL-3.0",
"version": "0.4.0.011",
"version": "0.4.0.014",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down

0 comments on commit 84aaea9

Please sign in to comment.