-
Notifications
You must be signed in to change notification settings - Fork 20
Fixes on copy behavior in ring buffer window method #638
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
Fixes on copy behavior in ring buffer window method #638
Conversation
74ba702 to
1f914df
Compare
00e0e7e to
0bc072f
Compare
|
Rebased @matthias-wende-frequenz |
8e26c95 to
48ccae1
Compare
|
@matthias-wende-frequenz Ready for review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just two small comments. Looks good otherwise!
Also needs a rebase.
| ) | ||
|
|
||
| @staticmethod | ||
| def _wrapped_buffer_window( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this have to be a static method? I'd suggest to make it a class method as long it's not used outside the class context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you think so, or what is the advantage of a classmethod? I made it static since it's an isolated algorithmic piece which does not need any internal state of the class. Only the buffer argument would change here.
The main motivation was testing purpose (actually contained multiple bugs before), i.e. separate wrapping algorithm from index logic (which will become more tricky in follow-ups). But it can also easily be stripped out when needed elsewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One example for outside usage I could imagine is the periodic feature extractor, which I assume is using similar code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. It doesn't depend on the internal state. Let's keep it as is.
| return datetime.fromtimestamp(i, tz=timezone.utc) | ||
|
|
||
|
|
||
| async def test_access_window_by_index() -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if that's the correct function to add the tests. This was supposed to access the window by integer index, but the tests are accessing by datetime object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The newly added datetime slice tests were added in test_access_window_by_ts_slice. Then a single failure test to for int slices in test_access_window_by_int_slice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I missed that. All good then ;).
Test for expected copy behavior on missing values does not work as documented. Signed-off-by: cwasicki <[email protected]>
The functionality was not working as intended. Moreover the decision whether to enforce a copy or not should be left to the user even if the data contains None values. Signed-off-by: cwasicki <[email protected]>
This just moves the logic into a separate function to allow better testing of the logic. Bug found in the logic will be fixed in later commit. Signed-off-by: cwasicki <[email protected]>
This reworks the method for extracting wrapped buffer to fix a bug in the existing copy behavior for a specific case. Signed-off-by: cwasicki <[email protected]>
Changing the default is motivated by favouring data integrity over performance concerns which are minor in the majority of the expected applications. Also make force_copy a keyword argument. Signed-off-by: cwasicki <[email protected]>
Restore the typical list-like behavior for equal start and end. Would be inconsistent with the forbidden case start > end. Signed-off-by: cwasicki <[email protected]>
Expose window functionality of underlying buffer. Only datetime indices are supported so far. Signed-off-by: cwasicki <[email protected]>
Signed-off-by: cwasicki <[email protected]>
48ccae1 to
4d8de2a
Compare
This PR introduces several copy-related updates to the ring buffer window functionality
Changes:
force_copyas a keyword argument.Part of #214