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

Remove GLSFitter dependence from Residuals #1618

Merged
merged 23 commits into from
Aug 30, 2023

Conversation

abhisrkckl
Copy link
Contributor

This requires a bit of code duplication, but I think it is worth decoupling these modules. Also, this avoids a bunch of unnecessary fitting steps while computing the chisq.

@abhisrkckl abhisrkckl changed the title Remove GLSFitter dependence from Residuals WIP: Remove GLSFitter dependence from Residuals Aug 14, 2023
@codecov
Copy link

codecov bot commented Aug 17, 2023

Codecov Report

Patch coverage: 87.50% and no project coverage change.

Comparison is base (dbe69cc) 68.24% compared to head (72d817f) 68.24%.
Report is 19 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1618   +/-   ##
=======================================
  Coverage   68.24%   68.24%           
=======================================
  Files          99       99           
  Lines       22786    22806   +20     
  Branches     3918     3920    +2     
=======================================
+ Hits        15551    15565   +14     
- Misses       6274     6278    +4     
- Partials      961      963    +2     
Files Changed Coverage Δ
src/pint/residuals.py 74.81% <78.78%> (+0.27%) ⬆️
src/pint/fitter.py 83.69% <100.00%> (-0.37%) ⬇️
src/pint/models/timing_model.py 83.62% <100.00%> (+0.05%) ⬆️
src/pint/utils.py 60.10% <100.00%> (+0.54%) ⬆️

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@abhisrkckl abhisrkckl changed the title WIP: Remove GLSFitter dependence from Residuals Remove GLSFitter dependence from Residuals Aug 17, 2023
src/pint/utils.py Outdated Show resolved Hide resolved
@dlakaplan
Copy link
Contributor

I assume there is no big performance hit when using this? Or maybe it's even faster?

@abhisrkckl
Copy link
Contributor Author

It's the same code that was in GLSFitter, sans a few unnecessary lines. There is no reason it should be slower.

@dlakaplan
Copy link
Contributor

I agree that there is no reason. and it probably does less copying of objects. but I just wanted to verify empirically.

@abhisrkckl
Copy link
Contributor Author

abhisrkckl commented Aug 17, 2023

I did the profiling. The old code takes about 4 s whereas the new code takes about 1 s.

@dlakaplan
Copy link
Contributor

great! that's what I was hoping.

@abhisrkckl
Copy link
Contributor Author

There is an API change in this that has to be documented.

@dlakaplan
Copy link
Contributor

Is this ready to merge?

@dlakaplan
Copy link
Contributor

I guess on the PINT call last week we were discussing whether or not this would lead to changes in any example notebooks. Have you looked to see what needs to be done?

@abhisrkckl
Copy link
Contributor Author

abhisrkckl commented Aug 29, 2023

I checked. The change doesn't affect any notebooks.

I have updated the docstrings to reflect the API change.

@abhisrkckl
Copy link
Contributor Author

Is this ready to merge?

Yes.

@dlakaplan
Copy link
Contributor

But the understanding_fitters notebook does:

# Not sure how to do this properly yet.
# glsfit2 = pint.fitter.GLSFitter(toas=t, model=glsfit.model, residuals=glsfit.resids)
# glsfit2.fit_toas(maxiter=0)

presumably this is trying to construct residuals and just doing a fit because the API required it?

@abhisrkckl
Copy link
Contributor Author

I'll check this.

@abhisrkckl
Copy link
Contributor Author

But the understanding_fitters notebook does:

I don't think those commented out lines are needed. I have removed them.

The API change is only in Residuals and not GLSFitter. The understanding_fitters notebook does not use Residuals directly at all. So I don't think we need any other change in this file.

@dlakaplan dlakaplan merged commit 3a2910f into nanograv:master Aug 30, 2023
8 checks passed
@abhisrkckl abhisrkckl deleted the gls-chisq branch May 14, 2024 08:43
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.

Residuals object computes the GLS chi-squared using a GLSFitter instance
2 participants