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

lineup2() should work with low intensity peaks #920

Merged
merged 9 commits into from
Feb 20, 2024
Merged

Conversation

prjemian
Copy link
Contributor

@prjemian prjemian added the bug label Feb 15, 2024
@prjemian prjemian added this to the 1.6.19 milestone Feb 15, 2024
@prjemian prjemian self-assigned this Feb 15, 2024
@prjemian prjemian marked this pull request as ready for review February 15, 2024 07:33
Copy link
Collaborator

@MDecarabas MDecarabas left a comment

Choose a reason for hiding this comment

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

Small comments, mostly related to style

value = (stats.max_y - stats.min_y) / stats.sigma
return value > peak_factor
value = (stats.max_y - stats.min_y) / stats.stddev_y
return abs(value) > peak_factor
except ZeroDivisionError: # not enough samples
try:
value = abs(stats.max_y / stats.min_y)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we want to keep the format uniform across tries. Line 322 we return abs, line 336 we do the abs before return. Doesn't really matter in the grand scheme but I think it would be nice

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See commit 58d7230

Comment on lines 295 to 310
"peak, base, noise, center, sigma, xlo, xhi, npts, nscans, tol, outcome",
[
[1e5, 1e6, 10, 0.1, 0.2, -0.7, 0.5, 11, 1, 0.05, False], # signal but high background
[1e5, 0, 10, 0.1, 0.2, -0.7, 0.5, 11, 1, 0.05, True], # model peak
[1e5, 1e4, 10, 0.1, 0.2, -0.7, 0.5, 11, 1, 0.1, True], # high background, poor resolution
[1e5, 1e4, 10, 0.1, 0.2, -0.7, 0.5, 11, 2, 0.05, True], # not much better
[-1e5, -1e4, 1e-8, 0.1, 0.2, -0.7, 0.5, 11, 1, 0.1, True],
[1e5, -10, 10, 0.1, 0.2, -0.7, 0.5, 11, 1, 0.05, True],
[1e-5, 0, 1e-8, 0.1, 0.2, -0.7, 0.5, 11, 1, 0.05, True],
[1e-5, 1e-7, 1e-8, 0.1, 0.2, -0.7, 0.5, 11, 1, 0.05, True],
[-1e5, 0, 1e-8, 0.1, 0.2, -0.7, 0.5, 11, 1, 0.05, True],
[0, 0, 1e-8, 0.1, 0.2, -0.7, 0.5, 11, 1, 0.05, False], # only noise
[0, 1, 0.1, 0.1, 0.2, -0.7, 0.5, 11, 1, 0.05, False], # bkg + noise
[0, 1, 100, 0.1, 0.2, -0.7, 0.5, 11, 1, 0.05, False], # bkg + big noise
[0, 0, 0, 0.1, 0.2, -0.7, 0.5, 11, 1, 0.005, None], # no signal ZeroDivisionError
[0, 1, 0, 0.1, 0.2, -0.7, 0.5, 11, 1, 0.005, None], # bkg only ZeroDivisionError
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't know if we ever reuse these values however I think it might be useful/cleaner to store each list in a named variable as opposed to having such a list of lists. Hard to look at and understand what we are seeing, especially if we will be modifying test values.

Ex:

signal_high_background = [1e5, 1e6, 10, 0.1, 0.2, -0.7, 0.5, 11, 1, 0.05, False]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If these are defined as individual lists before the test, it seems easy to dissociate the values with the name. Could a namedtuple be used? If so, the fields of the namedtuple could be the first argument, then a list of the namedtuples would be the second.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

One more commit coming ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like this approach (251bc1e). It forces the person writing the test parameters to explain, in some way, why that set of parameters is used. The namedtuple and the type annotation is the Pythonic way to enforce that the same names are used for all parametrized tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can make that SOP going forward, and backfill the old tests by best efforts.

Copy link
Collaborator

@MDecarabas MDecarabas left a comment

Choose a reason for hiding this comment

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

Smart choice using the named tuples. All looks good to me now!

@prjemian prjemian merged commit 0d7647f into main Feb 20, 2024
13 checks passed
@prjemian prjemian deleted the 919-lineup2-fixes branch February 20, 2024 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lineup2: problem for peaks of height 1
2 participants