Skip to content

Commit

Permalink
Fix bug in reconstruction of 'bins' network-attribute from given ranges
Browse files Browse the repository at this point in the history
Occasionally, the 'bins' attribute did not include the end-date
of the second-last range, as described in Issue #256.

In addition, fix one faulty test.

Signed-off-by: Maximilian Löffler <s8maloef@stud.uni-saarland.de>
  • Loading branch information
MaLoefUDS committed Mar 30, 2024
1 parent 1d3d1a3 commit 8695fbe
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
3 changes: 2 additions & 1 deletion tests/test-split-network-time-based.R
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ patrick::with_parameters_test_that("Split a network time-based (time.period = ..
expected.bins = get.date.from.string(c("2016-07-12 15:58:59", "2016-07-12 15:59:59",
"2016-07-12 16:00:59", "2016-07-12 16:01:59",
"2016-07-12 16:02:59", "2016-07-12 16:03:59",
"2016-07-12 16:04:59", "2016-07-12 16:06:33"))
"2016-07-12 16:04:59", "2016-07-12 16:05:59",
"2016-07-12 16:06:33"))
expect_equal(expected.bins, attr(results, "bins"))

## check networks
Expand Down
6 changes: 2 additions & 4 deletions util-split.R
Original file line number Diff line number Diff line change
Expand Up @@ -815,11 +815,9 @@ split.network.time.based.by.ranges = function(network, ranges, remove.isolates =
)

## convert ranges to bins
bins.starts = sapply(ranges.bounds, function(range) range[1])
bins.end = ranges.bounds[[length(ranges.bounds)]][2]
bins.date = get.date.from.unix.timestamp(c(bins.starts, bins.end))
bins = get.bin.dates.from.ranges(ranges.bounds)
attr(nets.split, "bins") = bins

attr(nets.split, "bins") = bins.date
return(nets.split)
}

Expand Down

0 comments on commit 8695fbe

Please sign in to comment.