-
Notifications
You must be signed in to change notification settings - Fork 2
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
subsetting a mutaframe can trigger new listeners #5
Comments
I think the new listener is expected because there the subset data frame needs some way to be notified if there are changes in the parent so that it can keep up to date. Maybe @lawremi has ideas? |
I think we need an additional argument like |
Sorry, I haven't had time to look into this, with the Bioc release. Are you On Fri, Mar 30, 2012 at 12:40 PM, Yihui Xie <
|
They are not copied over. It is just that a new listener is added on the original mutaframe. See this example: library(plumbr)
mf = mutaframe(x = rnorm(5), y = rnorm(5))
add_listener(mf, function(i, j) {
print(plumbr:::changed(mf))
})
mf[1, 1] = rnorm(1)
mf2 = mf[1, ] # this will add a listener on mf
mf[1, 1] = rnorm(1) and here are the results: > mf = mutaframe(x = rnorm(5), y = rnorm(5))
> add_listener(mf, function(i, j) {
+ print(plumbr:::changed(mf))
+ })
>
> mf[1, 1] = rnorm(1)
Signal(i = , j = ) with 1 listeners
>
> mf2 = mf[1, ] # this will add a listener on mf
>
> mf[1, 1] = rnorm(1)
Signal(i = , j = ) with 2 listeners After I subset > objectSignals::listeners(plumbr:::changed(mf))
$`1`
function (i, j, ...)
function (i, j)
{
print(plumbr:::changed(mf))
}(i = i, j = j)(i, j)
$`2`
function (event_i, event_j, ...)
function (event_i, event_j)
{
if (shape_changed(event_i, event_j)) {
notify_listeners(child, NULL, NULL)
}
else {
new_i <- match(event_i, i)
incl <- !is.na(new_i)
notify_listeners(child, new_i[incl], event_j[incl])
}
}(event_i = event_i, event_j = event_j)(i, j) |
As Hadley said, this is by design. Subsetting a mutaframe is going to There is a complication though that just occurred to me: there is no easy Getting to your point, yes, I could see how the materialize() strategy is This would not be too different though than just doing an as.data.frame() Michael On Fri, Mar 30, 2012 at 10:32 PM, Yihui Xie <
|
Thanks for the detailed discussion. For now I think I will simply use the |
I have been wondering for a long while why the number of listeners keeps on increasing when the grand tour is running (
qtour()
in cranvas), and today I figured out the reason: simply subsetting a mutaframe can add new listeners on it. Here is an example:Because all plotting functions use
[]
frequently, the number of listeners can increase rapidly in a tour, which makes the tour slower and slower.Is this new listener expected? I see it comes from
[.mutaframe
which usesfilter_proxy()
.Thanks!
The text was updated successfully, but these errors were encountered: