-
Notifications
You must be signed in to change notification settings - Fork 17
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
MovingWindow: Create Interface for requesting data and handling the data copy behaviour #214
Comments
I don't understand why we could not design it in a way where the user passes his numpy array by reference the moving window is writing to. This way we could avoid the need for the fill_gaps parameter. In that case the numpy array could be initialised with whatever values the someone wants. |
To me passing in an array feels less like typical behavior of other functions in numpy or pandas.
Since we should not have gaps in the moving window but only NaNs or uninitialized in the beginning, I would name this differently.
That should also work with index, not only datetime. |
This is about the gaps that are coming from the resampler, e.g. due to faulty hardware. Passing the np array is also planned but an independent issue (#530). |
Yes but in this case we would copy the NaN's that are coming from the resampler. This has to be treated differently I think but not 100% sure. |
You are right, we shouldn't copy NaN's. If |
Blocked because we need to fix some bugs in the ring buffer for this to be useful. |
@llucax Which bugs are those? |
OK, if you need any further info about this, ask @matthias-wende-frequenz |
@leandro-lucarella-frequenz but this bug is fixed and merged. Can we unblock the issue? |
Done. |
This PR introduces several copy-related updates to the ring buffer window functionality Changes: * Default Copy Behavior: Changed the default behavior to copy data in the ring buffer window. This is to prioritize data integrity over performance, which is a minor concern for most expected use-cases. Made `force_copy` as a keyword argument. * Moved the logic for extracting wrapped buffers into a separate method to fix a bug and allow for better testing and future maintainability. * Handling None Values: Fixed an issue where None values were being forcibly copied in the ring buffer window. The decision to enforce a copy is now left to the user, even when the data contains None values. * Test Coverage: Added tests for the window method in the ring buffer, including tests for expected copy behavior on missing values. * Fix to return an empty array in case start = end in ring buffer window. * Expose restricted ring buffer window by moving window. Part of #214
@llucax As discussed summary of the (ongoing) work related to this and what I see essential for v1.0. Essential for this issue:
Related to moving window: |
Apart from a very special bug (#646) all associated work has been merged. |
When asking the
MovingWindow
for a subwindow we might return a slice of the buffer, that means a reference to the underlying numpy based ringbuffer.There are cases, e.g. when dealing with small window sizes and high sample rates, where the data might get updated from the data stream before the requested subwindow has been processed.
As a solution we want to tell the
MovingWindow
to return a copy of the data instead of a reference. In order to do that we need to add an interface, such that users can control copy behavior.We might implement a method for the
MovingWindow
as follows.This method should return a sorted numpy array that holds the resampled data from start to end and fills the gaps with the Value that is provided by
fill_gaps
.Summary of the (ongoing) work related to this and what I see essential for v1.0.
Essential for this issue:
For v1.0:
Post v1.0?
Related to moving window:
The text was updated successfully, but these errors were encountered: