Skip to content

Rolling window with select function not behaving correctly #140

@e-tang

Description

@e-tang

When using rollingwindow with the select function, the rolling windows are correct but select function calls the transformer more than it should.

Please see the following test code:

import { assert, expect } from 'chai';
import 'mocha';
import * as dataForge from './index';
import { DataFrame, Series, ISeries, Index } from './index';

var df = new DataFrame({ index: [10, 20, 30, 40, 50], values: [0, 1, 2, 3, 4] });
var counter = 0;
var windows = df
.rollingWindow(2);

var testSeries = windows.select((window) => {
    console.log("counter:" + counter);
    return [window.getIndex().last(), ++counter];
})   
.withIndex(pair => pair[0])
.inflate(pair => pair[1]);

The following are the outputs:

counter:0
counter:1
counter:2
counter:3
counter:4
counter:5
counter:6
counter:7
counter:8
__index__
---------
20       
30       
40       
50  

I think only 4 times should be the correct number.

Metadata

Metadata

Assignees

No one assigned

    Labels

    version-2Saving this for Data-Forge version 2.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions