From f6db19b9ac3d0b9f9cff481da2a22c27767b7cd1 Mon Sep 17 00:00:00 2001 From: Leo Sendelbach Date: Wed, 17 Jan 2024 14:50:01 +0100 Subject: [PATCH] Change NEWS.md and simple style fixes Signed-off by: Leo Sendelbach --- NEWS.md | 13 +++++++------ tests/test-util-networks-misc.R | 2 ++ tests/testing-utils.R | 2 +- util-networks-misc.R | 14 +++++++------- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/NEWS.md b/NEWS.md index 95d8b800..c983c49f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -8,16 +8,18 @@ - Add issue-based artifact-networks (PR #244, 98a93ee721a293410623aafe46890cfba9d81e72, 771bcc8d961d419b53a1e891e9dc536371f1143b) - Add a new `split.data.by.bins` function (not to be confused with a previously existing function that had the same name and was renamed in this context), which splits data based on given activity-based bins (PR #244, ece569ceaf557bb38cd0cfad437b69b30fe8a698, ed5feb214a123b605c9513262f187cfd72b9e1f4) -- Add new `compare.sparse.matrices` function to compare two sparse matrices for equality for testing purposes (PR #248, 9784cdf12d1497ee122e2ae73b768b8c334210d4) -- Add tests for file `util-networks.misc.R` (PR #248, f3202a6f96723d11c170346556d036cf087521c8, 030574b9d0f3435db4032d0e195a3d407fb7244b, 380b02234275127297fcd508772c69db21c216de, 8b803c50d60fc593e4e527a08fd4c2068d801a48, 7335c3dd4d0302b024a66d18701d9800ed3fe806, 6b600df04bec1fe70c272604f274ec5309840e65) +- Add new `assert.sparse.matrices.equal` function to compare two sparse matrices for equality for testing purposes (PR #248, 9784cdf12d1497ee122e2ae73b768b8c334210d4, d9f1a8d90e00a634d7caeb5e7f8f262776496838) +- Add tests for file `util-networks.misc.R` for issue #242 (PR #248, f3202a6f96723d11c170346556d036cf087521c8, 030574b9d0f3435db4032d0e195a3d407fb7244b, 380b02234275127297fcd508772c69db21c216de, 8b803c50d60fc593e4e527a08fd4c2068d801a48, 7335c3dd4d0302b024a66d18701d9800ed3fe806, 6b600df04bec1fe70c272604f274ec5309840e65) ### Changed/Improved - Enhance testing data by adding `add_link` and `referenced_by` issue events which connect issues to form edges in issue-based artifact-networks (PR #244, 9f840c040d552e8639aa82c3dd537c189679b348, ea4fe8d3c84f948af6147cf0137e80181ebb7a1e) - Add input validation for the `bins` parameter in `split.data.time.based` and `split.data.by.bins` (PR #244, ed0a5302ea8c8934d7200b95be7ac1446305af07, 5e5ecbac44d07927b953ae9d4330a616f8224ba7) - Rename `split.data.by.bins` into `split.dataframe.by.bins` as this it what it does (PR #244, ed5feb214a123b605c9513262f187cfd72b9e1f4) -- Enhance `get.author.names.from.network` and `get.author.names.from.data` to always have the same output format, not depending on the `global` flag (PR #248, d87d32564156f13c83ebe3361c2b68e5d0ac16ac, ddbfe68d3e628e82f34e09b36fffe886646986c5) -- Changed `util-tensor.R` to correctly use `get.author.names.from.network` function +- Enhance `get.author.names.from.network` and `get.author.names.from.data` to always have the same output format. Now it doesn't depend on the `global` flag anymore (PR #248, d87d32564156f13c83ebe3361c2b68e5d0ac16ac, ddbfe68d3e628e82f34e09b36fffe886646986c5) +- Change `util-tensor.R` to correctly use the new output format of `get.author.names.from.network` (PR #248, 72b663ebf7169c0da5c687fe215529f3be0c08c5) +- Fix `convert.adjacency.matrix.list.to.array` to throw an error if the function is called with wrong parameters (PR #248, ece2d38b4972745af3a83e06f32317a06465a345, 1a3e510df15f5fa4e920e9fce3e0e162c27cd6d1) +- Rename `compare.networks` to `assert.networks.equal` to better match the purpose of the function (PR #248, d9f1a8d90e00a634d7caeb5e7f8f262776496838) ### Fixed @@ -25,10 +27,9 @@ - Fix an issue in activity-based splitting where elements close to the border of bins might be assigned to the wrong bin. The issue was caused by the usage of `split.data.time.based` inside `split.data.activity.based` to split data into the previously derived bins, when elements close to bin borders share the same timestamps. It is fixed by replacing `split.data.time.based` by `split.data.by.bins` (PR #244, ece569ceaf557bb38cd0cfad437b69b30fe8a698) - Remove the last range when using a sliding-window approach and the last range's elements are fully contained in the second last range (PR #244, 48ef4fa685adf6e5d85281e5b90a8ed8f6aeb197) - Rename vertex attribute `IssueEvent` to `Issue` in multi-networks, to be consistent with bipartite-networks (PR #244, 26d7b7e9fd6d33d1c0a8a08f19c5c2e30346a3d9) -- Fix `get.expanded.adjacency` to work if provided author list does not contain all authors from network and add a warning when that happens because it causes some authors from the network to be lost in the resulting matrix (PR #248, ff59017e114b10812dcfb1704a19e01fc1586a13) +- Fix `get.expanded.adjacency` to work if the provided author list does not contain all authors from network and add a warning when that happens since it causes some authors from the network to be lost in the resulting matrix (PR #248, ff59017e114b10812dcfb1704a19e01fc1586a13) - Fix `get.expanded.adjacency.matrices` to have correct names for the columns and rows (PR #248, e72eff864a1cb1a4aecd430e450d4a6a5044fdf2) - Fix `get.expanded.adjacency.cumulated` so that it works if `weighted` parameter is set to `FALSE` (PR #248, 2fb9a5d446653f6aee808cbfc87c2dafeb9a749a) -- Fix `convert.adjacency.matrix.list.to.array` to throw an error if the function is called with wrong parameters (PR #248, ece2d38b4972745af3a83e06f32317a06465a345, 1a3e510df15f5fa4e920e9fce3e0e162c27cd6d1) ## 4.3 diff --git a/tests/test-util-networks-misc.R b/tests/test-util-networks-misc.R index 64827de5..7a7d56ed 100644 --- a/tests/test-util-networks-misc.R +++ b/tests/test-util-networks-misc.R @@ -112,6 +112,7 @@ test_that("getting all authors of a list of networks, list length 2", { to = "Dieter" ) second.network = igraph::graph.data.frame(second.edges, directed = FALSE, vertices = second.vertices) + ## Act result = get.author.names.from.networks(networks = list(first.network, second.network)) @@ -145,6 +146,7 @@ test_that("getting all authors of a list of networks, list length 2, not global" to = "Dieter" ) second.network = igraph::graph.data.frame(second.edges, directed = FALSE, vertices = second.vertices) + ## Act result = get.author.names.from.networks(networks = list(first.network, second.network), globally = FALSE) diff --git a/tests/testing-utils.R b/tests/testing-utils.R index 4d0bfd4b..dbdc392b 100644 --- a/tests/testing-utils.R +++ b/tests/testing-utils.R @@ -147,7 +147,7 @@ assert.sparse.matrices.equal = function(matrix.expected, matrix.actual) { expected.size = length(matrix.expected) expect_equal(expected.size, length(matrix.actual)) # check if contents are the same - for(i in 1 : expected.size) { + for (i in 1 : expected.size) { expect_equal(matrix.expected[i], matrix.actual[i]) } } \ No newline at end of file diff --git a/util-networks-misc.R b/util-networks-misc.R index ac5f5e54..c1789e91 100644 --- a/util-networks-misc.R +++ b/util-networks-misc.R @@ -147,7 +147,7 @@ get.expanded.adjacency = function(network, authors, weighted = FALSE) { order((rownames(matrix.data)[rownames(matrix.data) %in% authors]))] } - if(network.authors.num > nrow(matrix.data)) { + if (network.authors.num > nrow(matrix.data)) { # write a warning with the number of authors from the network that we ignore warning.string = sprintf("The network had %d authors that will not be displayed in the matrix!", network.authors.num - nrow(matrix.data)) @@ -181,7 +181,7 @@ get.expanded.adjacency.matrices = function(networks, weighted = FALSE){ adjacency.matrices = parallel::mclapply(networks, function(network) { active.authors = igraph::V(network)$name active.authors = sort(active.authors) - return (get.expanded.adjacency(network = network, authors = active.authors, weighted = weighted)) + return(get.expanded.adjacency(network = network, authors = active.authors, weighted = weighted)) }) return(adjacency.matrices) @@ -214,7 +214,7 @@ get.expanded.adjacency.cumulated = function(networks, weighted = FALSE) { ## search for a non-zero entry and set them to an arbitray number (e.g., 42) ## to force that all non-zero entries are correctly set to 1 afterwards - if(length(matrices.cumulated[[m]]@i) > 0) { + if (length(matrices.cumulated[[m]]@i) > 0) { row = matrices.cumulated[[m]]@i[[1]] + 1 col = matrices.cumulated[[m]]@j[[1]] + 1 @@ -241,14 +241,14 @@ convert.adjacency.matrix.list.to.array = function(adjacency.list){ logging::logerror("The method convert.adjacency.matrix.list.to.array received an empty list!") stop("The method convert.adjacency.matrix.list.to.array received an empty list!") } - ## Check if all matrices have equal colomn- and rownames + ## Check if all matrices have equal column- and rownames rownames = rownames(adjacency.list[[1]]) colnames = colnames(adjacency.list[[1]]) - + if (length(adjacency.list) > 1) { - for(i in 2 : length(adjacency.list)) { + for (i in 2 : length(adjacency.list)) { if (!identical(rownames, rownames(adjacency.list[[i]])) || !identical(colnames, colnames(adjacency.list[[i]]))) { - error.string = sprintf("The matrix at position %d has a different col or rownames from the first!", i) + error.string = sprintf("The matrix at position %d has different col or rownames from the first!", i) logging::logerror(error.string) stop(error.string) }