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

Add Sliding window #10

Merged
merged 60 commits into from
Nov 16, 2018
Merged

Add Sliding window #10

merged 60 commits into from
Nov 16, 2018

Conversation

breznak
Copy link
Member

@breznak breznak commented Jan 19, 2018

Add class providing fast & reusable sliding window implementation

  • simplifies MovingAverage
  • improves compare==
  • fix CI error
  • old,long PR, squash commits before merging

Fixes numenta#1276
Moved from numenta#1277
Please see discussion there

breznak added 30 commits April 11, 2017 11:57
of the Sliding Window / Circular buffer
API change to getSlidingWindow() -> getData()
MA uses internally SlidingWindow
and make const vector<int>& getData()
-this fixes comparison in equals!!
to let use-cases where both MA & sl. window need to be controlled/accessed by the user;
no default constructor T() required now
iterates in linearized order without moving the internal vector/data
@breznak breznak added the ready label Jan 19, 2018
@breznak breznak added backport_upstream What could be useful for upstream backporting code code enhancement, optimization, cleanup..programmer stuff and removed feature new feature, extending API labels Aug 9, 2018
@breznak breznak closed this Aug 30, 2018
@breznak breznak reopened this Aug 30, 2018
@breznak breznak requested a review from dkeeney August 30, 2018 12:40
@breznak
Copy link
Member Author

breznak commented Aug 30, 2018

This should be an easy one, heavily reviewed PR back from Numenta. Add sliding window/circular buffer implementation.
If you see a place where this could simplify code, feel free to put it there.

@dkeeney
Copy link

dkeeney commented Aug 30, 2018 via email

@breznak
Copy link
Member Author

breznak commented Aug 30, 2018

Good point, I was using boost::circular_buffer too, this sprang to life just to get rid of it.
Deque is ofc a good fit, I think we've used it..and later this evolved to fit some sugar with operators etc.

@dkeeney
Copy link

dkeeney commented Aug 30, 2018 via email

@breznak
Copy link
Member Author

breznak commented Aug 30, 2018

oh, well..this is intended as a "lib", so it's perfect if you can see whether the current implementation of SlidingWindow would fit your needs in Link?

@breznak
Copy link
Member Author

breznak commented Nov 15, 2018

@dkeeney please review, if merging, merge as "Squash and merge" this time, to avoid all the fixup commits

Copy link

@dkeeney dkeeney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting implementation.
I wrote one of these once; used a deque rather than a vector. But I did not have the requirement of having to directly index into the elements of the window.

Perhaps you could overload [ ] operator and remap the index such that it always indexes in order. Do the same with the iterator. Then you would not need the getLinearizedData() function and data will always be in queue order. getData() would require copying into a new vector so it would be ordered.
Just thoughts... not a requirement.

@breznak
Copy link
Member Author

breznak commented Nov 16, 2018

..I forgot to implement serialization, dig into it and got stuck on possible design flaw in Serializable (I have problem serializing any object with const member, as serialization assumes default constructor())

@breznak
Copy link
Member Author

breznak commented Nov 16, 2018

Will merge as is, and do the Serialization etc in other PR.

Perhaps you could overload [ ] operator and remap the index such that it always indexes in order. Do the same with the iterator. Then you would not need the getLinearizedData() function and data will always be in queue order. getData() would require copying into a new vector so it would be ordered.

I like this idea. Will add it to comment in that file and revisit when we finish other things in progress

@breznak breznak merged commit 0170c15 into htm-community:master Nov 16, 2018
@breznak breznak deleted the sliding_window branch November 16, 2018 10:03
@breznak breznak mentioned this pull request Feb 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport_upstream What could be useful for upstream backporting code code enhancement, optimization, cleanup..programmer stuff enhancement New feature or request help wanted Extra attention is needed ready
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add implementation of utils::SlidingWindow / Circular buffer
2 participants