Repository navigation
Fix continuous peth nbins - #678
Open
lilytong0919 wants to merge 9 commits into
Open
lilytong0919 wants to merge 9 commits into
lilytong0919 wants to merge 9 commits into
Conversation
This reverts commit 9d38a8b.
…event number of bins consistent until the new data array is created. The final output actually still have the same issue with cutout boundaries. Suspect that is from the `time_support=new_time_support` argument in the return statement.
Just take the median here to get a reasonable dt. Several reasons: 1. Rounding to 9th decimal don't actually eliminate the problem with edge cases (probably also need to be consistent with the `_is_reuglarly_sampled` tolerance value for that to work. 2. `_full_bin_count` will determine `windowsize` with tolerance with a safer logic, so rounding prior to that is unnecessary. But I will need some fix after nbins is determined to makesure the edge bins can fall within the `new_time_support`.
Moved `_full_bin_count` to be an nested function in `_align_regular` since this is probably going to be the only use case. Added tolerance as an argument at the level of `_align_regular`, because this needed for determining number of bins and for snapping edge bins to fit within the new timesupport.
Added tolerance as a variable that will be input to `utils._is_regularly_sampled` and `_align_regular` because they need to be consistent.
Added 3 tests for edge cases of checking regular sampling and checking consistency in number of bin counts.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thank you for opening this PR. Filling out this template will help the maintainers of pynapple to review your contribution.
This PR template has 2 sections. Please fill the first section yourself. Optionally, description of the PR by a LLM can be included in the second section.
Contributor statement
AI Assistance Disclosure
Uses ChatGPT6 for test case generation (and check that the desired behavior is achived by the current modification
Motivation
In issue #671 I mentioned that
compute_perieventgive unstable number of bins on continuous data given the samewindowand timeseries with persumability the samebin_size. I suspected that is due to floating point percision issue when accessing the edge cases.PR description
This PR address the issue by changing the
time_idxandwindowsizecomputation to go through checks with tolerance, and snaptime_idxon the edges when the variation in time_idx is close enought to defined window. The former change allow intial creation ofnew_data_arraythat are consistent in number of bins. The latter prevent the object intializer to crop the data array on either end due totime_idxedge bins falling slightly over the definednew_time_support.Outstanding questions / particular feedback
I moved the definition of tolerance into
compute_perieventand use it as input to both_align_regularand_is_regularly_sampled. I think this ensures the assertion to regular sampling to fail before the program start giving inconsistent behavior on binsize. I am not very certain this does what I intended it to do. But for this I check with a test with random jittering (which is not a test case because this relys on random generation of data which is not so stable). The setting here should be jittering around the boundary cases of regularity check. So we would expect the print statement in theexceptblock to be triggered multiple times, but the final comparison of bin_count only give 1 consistent value.Checklist
Affirm that you have done the following:
doc/, or (for large changes) adding new files to thedoc/folder.I only added a small nested function
_full_bin_countand several if statement. They are properly commented but no docstring is added. Since this PR only meant to makecompute_perieventbehave more stably, I think no need to change it's documentation.AI description of the PR (optional)