-
Notifications
You must be signed in to change notification settings - Fork 38
Add c.network.list() #604
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
base: master
Are you sure you want to change the base?
Add c.network.list() #604
Conversation
Drafty still as I did something stupid... I'll add a test or two as well. |
R/c.network.list.R
Outdated
# Check a list elements using all.equal or identical | ||
check_list <- function(lst, fun = all.equal) { | ||
r <- vapply(lst[-1], function(x) isTRUE(fun(x, lst[[1]])), logical(1)) | ||
all(r) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is similar to statnet.common::all_identical()
. Would you mind contributing it (or a version of it) there? Also, it might be worth benchmarking, because the all_identical()
's for
loop seems to perform about 4 times faster.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ha! I missed that. all_identical()
is more efficient for sure, because it exits as soon as an element different from the first is found. I'll use it and drop this.
Perhaps I'll add sth like all_equal()
that will work in a similar manner but use all.equal()
. Such algo might be quirky though as I think of it, because, in general, all.equal()
is not transitive due to numerical tolerance: for some c(x,y,z)
all.equal(x, y)
and all.equal(x, y)
might be true but all.equal(x, z)
might be false...
This should pass the checks as soon as statnet/statnet.common#34 is merged. |
Actually, could you please put the |
89f1fb9
to
19949c3
Compare
@mbojan , I've collapsed the changes to avoid having to merge with a file that no longer exists. One last item is perhaps a unit test or two? |
Ok, will do. I was wondering where the conflict came from. |
I went through and merged a bunch of files in the |
19949c3
to
84e2c96
Compare
I rebased against the current |
Tests added and conflicts resolved. |
b7d05f0
to
e21cfd0
Compare
e21cfd0
to
fe72511
Compare
response = attr(dots[[1]], "response"), | ||
stats = structure( | ||
do.call("rbind", map(dots, ~attr(.x, "stats"))), | ||
monitored = do.call("c", map(dots, ~ attr(attr(.x, "stats"), "monitored"))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "monitored"
attribute has an element for each statistic element, not each realisation, so it should be checked for consistency, not concatenated.
control = attr(dots[[1]], "control"), | ||
response = attr(dots[[1]], "response"), | ||
stats = structure( | ||
do.call("rbind", map(dots, ~attr(.x, "stats"))), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not work for simulate(simplify = FALSE)
, because then attr(., "stats")
is an mcmc.list
, not a matrix.
ff7681f
to
887271b
Compare
Uses the new variant of all_identical() allowing arbitary pairwise-comparison function.
887271b
to
04baa72
Compare
Please don't rebase until I resolve all the issues. |
c.f. #603