Skip to content
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

Stats.min is incorrect for ordered sliding windows? #12

Open
tvcutsem opened this issue Nov 19, 2014 · 2 comments
Open

Stats.min is incorrect for ordered sliding windows? #12

tvcutsem opened this issue Nov 19, 2014 · 2 comments

Comments

@tvcutsem
Copy link

Given the following code using a fresh checkout of the repository on node v0.10.26:

var windows = eep.EventWorld.make().windows();
var win = windows.sliding(eep.Stats.min, 3);
win = windows.ordered(win);

win.on('emit', function(value) {
  console.log('min:' + value);
});

var values = [1,2,3,4,5,6];
for (var i in values) {
  win.enqueue(values[i]);
}

I get:

min:1
min:1
min:2
min:3

While I would have expected:

min:1
min:2
min:3
min:4

Replacing Stats.min by Stats.max I get the expected behavior, so I suspect there's an issue with Stats.min.

@tvcutsem
Copy link
Author

Update: the problem also occurs with Stats.max, on a different sample. So the error is probably in the ordered window:

var windows = eep.EventWorld.make().windows();
var win = windows.sliding(eep.Stats.max, 3);
win = windows.ordered(win);

win.on('emit', function(value) {
  console.log('max:' + value);
});

var values = [1,2,3,2,1,0];
for (var i in values) {
  win.enqueue(values[i]);
}

Gives:

max:3
max:3
max:3
max:3

Expected:

max:3
max:3
max:3
max:2

@darach
Copy link
Owner

darach commented Nov 20, 2014

It looks like i've broken this (again). Thanks for the testcase!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants