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

from/to as coord matrices for #229 #232

Merged
merged 3 commits into from
Jun 6, 2024
Merged
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 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", , "mark.padgham@email.com", 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
Loading