Skip to content
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
9 changes: 6 additions & 3 deletions R/community.R
Original file line number Diff line number Diff line change
Expand Up @@ -1095,7 +1095,8 @@ as.dendrogram.communities <- function(
object$height <- object$modularity[-1]
object$height <- cumsum(object$height - min(object$height))
}
nMerge <- length(oHgt <- object$height)
oHgt <- object$height
nMerge <- length(oHgt)
if (nMerge != nrow(merges)) {
cli::cli_abort("'merge' and 'height' do not fit!")
}
Expand All @@ -1105,7 +1106,8 @@ as.dendrogram.communities <- function(
leafs <- nrow(merges) + 1
for (k in 1:nMerge) {
x <- merges[k, ] # no sort() anymore!
if (any(neg <- x < leafs + 1)) {
neg <- (x < (leafs + 1))
if (any(neg)) {
h0 <- if (hang < 0) 0 else max(0, oHgt[k] - hang * hMax)
}
if (all(neg)) {
Expand Down Expand Up @@ -1154,7 +1156,8 @@ as.dendrogram.communities <- function(
2
}
attr(zk, "height") <- oHgt[k]
z[[k <- format(k + leafs, scientific = FALSE)]] <- zk
k <- format(k + leafs, scientific = FALSE)
z[[k]] <- zk
}
z <- z[[k]]
class(z) <- "dendrogram"
Expand Down
8 changes: 6 additions & 2 deletions R/hrg.R
Original file line number Diff line number Diff line change
Expand Up @@ -569,9 +569,12 @@ as.dendrogram.igraphHRG <- function(object, hang = 0.01, ...) {

for (k in 1:nMerge) {
x <- merges[k, 1:2]
if (any(neg <- x >= 0)) {
neg <- (x >= 0)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!!!!!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@krlmlr @schochastics small hackathon topic?


if (any(neg)) {
h0 <- if (hang < 0) 0 else max(0, oHgt[k] - hang * hMax)
}

if (all(neg)) {
# two leaves
zk <- as.list(x + 1)
Expand Down Expand Up @@ -607,7 +610,8 @@ as.dendrogram.igraphHRG <- function(object, hang = 0.01, ...) {
2
}
attr(zk, "height") <- oHgt[k]
z[[k <- paste0("g", -merges[k, 3])]] <- zk
k <- paste0("g", -merges[k, 3])
z[[k]] <- zk
}
z <- z[[k]]
class(z) <- "dendrogram"
Expand Down
15 changes: 10 additions & 5 deletions R/par.R
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,18 @@ igraph_i_options <- function(..., .in = parent.frame()) {
temp <- list(...)
if (length(temp) == 1 && is.null(names(temp))) {
arg <- temp[[1]]
switch(
mode(arg),
list = temp <- arg,
character = return(.igraph.pars[arg]),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we can add an exception comment instead but I have to say I had trouble understanding the switch() call.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO switch only makes sense if it is more than 2 option OR if we expect that the list of options might grow in the future.

Independently, I also find this statement confusing

if (mode(arg) == "character") {
return(.igraph.pars[arg])
}

if (mode(arg) != "list") {
cli::cli_abort("invalid argument: {arg}.")
)
}

temp <- arg
}

if (length(temp) == 0) {
return(get_all_options())
}
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-assortativity.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# jarl-ignore-file implicit_assignment: just the way it works

test_that("assortativity works", {
g <- read_graph(f <- gzfile("celegansneural.gml.gz"), format = "gml")

Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-foreign.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# jarl-ignore-file implicit_assignment: just the way it works
test_that("writing Pajek files works", {
# FIXME: Does the Pajek format allow for \r\n line endings on Windows?
# Adapt test depending on that.
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-plot.shapes.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Test shapes() function
# jarl-ignore-file implicit_assignment: just the way it works
test_that("shapes() lists all available shapes", {
all_shapes <- shapes()
expect_type(all_shapes, "character")
Expand Down
Loading