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 failing dt test - and solve it with max peak duration #420

Merged
merged 15 commits into from Apr 12, 2021

Conversation

JoranAngevaare
Copy link
Member

@JoranAngevaare JoranAngevaare commented Apr 9, 2021

What is the problem / what does the code in this PR do
Add a test that will push us into #397.

Can you briefly describe how it works?
Make a big bunch of records that should be sufficient to break strax with integer overflows. To solve the issue, we should solve this test.

Can you give a minimal working example (or illustrate with a figure)?
This is the example

@JoranAngevaare JoranAngevaare marked this pull request as draft April 9, 2021 18:11
@JoranAngevaare JoranAngevaare marked this pull request as ready for review April 9, 2021 21:31
@JoranAngevaare JoranAngevaare changed the title add failing dt test add failing dt test - and solve it with max peak duration Apr 9, 2021
@JoranAngevaare
Copy link
Member Author

We must have been really desperate of tests:
afbeelding

@JoranAngevaare JoranAngevaare added Testing Works on testing code bug Something isn't working enhancement New feature or request labels Apr 10, 2021
Copy link
Collaborator

@WenzDaniel WenzDaniel left a comment

Choose a reason for hiding this comment

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

Just some minor comments, in general it is fine.

Comment on lines +39 to +40
# np.iinfo(p['dt'].dtype).max*np.shape(p['data'])[1] = 6553400 ns
# but numba does not like it
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess it will never. Maybe if you specify a fixed signature to the function, which we usually do not.

strax/processing/peak_building.py Outdated Show resolved Hide resolved
tests/test_peak_processing.py Outdated Show resolved Hide resolved
Comment on lines +140 to +148
def retrun_1(x):
"""
Return 1 for all of the input that can be used as a parameter
for the splitting in natural breaks
:param x: any type of array
:return: ones * len(array)
"""
ret = np.ones(len(x))
return ret
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we use a lambda function instead? This looks a bit odd.

Copy link
Member Author

Choose a reason for hiding this comment

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

lambda is very non pep8 right? What would your main motivation be for making this a lambda?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, I to my understanding something like:

function(a, b, c labda x: do_something_simple)

would be the default example for a lambda function. Like used in filter, map etc. It is the only places where I would use them.

Copy link
Member Author

Choose a reason for hiding this comment

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

@WenzDaniel , I just stumbled across the pep8 guidelines, and I must say, I would agree with their reasoning:
https://www.python.org/dev/peps/pep-0008/

tests/test_peak_processing.py Outdated Show resolved Hide resolved
Comment on lines +219 to +232
peaklets = strax.split_peaks(
p, r, to_pe,
algorithm='natural_breaks',
threshold=retrun_1,
split_low=True,
filter_wing_width=70,
min_area=0,
do_iterations=2)
except AssertionError as e:
if not left_extension + max_duration + right_extension < magic_overflow_time:
# Ending up here is the ultimate goal of the tests. This
# means we are hitting github.com/AxFoundation/strax/issues/397
print(f'Great, the test worked, we are getting the assertion '
f'statement for the int overflow')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would be very strange if we ever trigger this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, this was the design of the tests as I first wrote the test and then implemented the solution.

Co-authored-by: Daniel Wenz <43881800+WenzDaniel@users.noreply.github.com>
@WenzDaniel
Copy link
Collaborator

One more thing I noticed that your changes are also present in: https://github.com/AxFoundation/strax/pull/403/files. We have to be careful with the commit history I think.

@JoranAngevaare
Copy link
Member Author

One more thing I noticed that your changes are also present in: https://github.com/AxFoundation/strax/pull/403/files. We have to be careful with the commit history I think.

This is true, it's almost exactly the same so should be relatively easy to resolve the merge-conflicts.

@JoranAngevaare JoranAngevaare merged commit 25c823e into master Apr 12, 2021
@JoranAngevaare JoranAngevaare deleted the dt_test branch April 12, 2021 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request Testing Works on testing code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants