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

Utils tests #215

Merged
merged 23 commits into from
Nov 3, 2023
Merged

Utils tests #215

merged 23 commits into from
Nov 3, 2023

Conversation

jeffjennings
Copy link
Collaborator

Adds tests for the routines in utilities.py that aren't covered by existing tests. These tests check that the routines simply run and that they give the expected numerical results.

Closes #214

@jeffjennings
Copy link
Collaborator Author

jeffjennings commented Nov 2, 2023

The other program that has low test coverage is filter.py; we should probably add tests for those missing routines (three of the functions in CriticalFilter). Do you want to do that (unless you expect those functions to change)? Or I can.

@rbooth200
Copy link
Collaborator

I can add regression tests for two of the functions in filter.py. The function update_power_spectrum_multiple isn't currently used anywhere so I'd leave it untested. Can you check the maths for the other two? The covariance function should be the same as the Hessian in the frank debris paper and the prior is log P(p|beta) in the frank paper.

@jeffjennings
Copy link
Collaborator Author

jeffjennings commented Nov 2, 2023

I can add regression tests for two of the functions in filter.py. The function update_power_spectrum_multiple isn't currently used anywhere so I'd leave it untested. Can you check the maths for the other two? The covariance function should be the same as the Hessian in the frank debris paper and the prior is log P(p|beta) in the frank paper.

Great, changes to filter.py should probably be a separate PR.

Re: math: for log_prior, in the docstring should the - np.sum(p0/pi + (alpha-1)*np.log(p0/pi)) be (change to the last log term) - np.sum(p0/pi + (alpha-1)*np.log(pi) -- (eqns.37-40 in the paper)? If it's correct as it is, the docstring and code are consistent.

For covariance_MAP, (eqn.40 in the debris paper), I'm confused where the 2 comes from in (2 * mqq + Dqq) in l.218, - 0.5 * np.outer(1 / p, 1 / p) * (2 * mqq + Dqq) * Dqq, but otherwise it looks right.

@rbooth200
Copy link
Collaborator

I checked that term - it's the first line in eqn 30, so I think everything is fine. I've added a test that checks both of the missing functions in filter.py and some of the other likelihood functions. We're now up to 86% coverage with ~half the missing lines coming from stats models and make_figs

Copy link
Collaborator

@rbooth200 rbooth200 left a comment

Choose a reason for hiding this comment

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

Approving this. If you're happy with the filter tests, feel free to merge.

@jeffjennings
Copy link
Collaborator Author

Great, thank you

@jeffjennings jeffjennings merged commit 535c63a into master Nov 3, 2023
5 checks passed
@jeffjennings jeffjennings deleted the utils_tests branch November 3, 2023 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Broader test coverage
2 participants