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 a return value to the check_convergence method #69

Merged
merged 6 commits into from
Nov 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions src/pint_pal/lite_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1484,20 +1484,38 @@ def check_convergence(fitter):
Parameters
==========
fitter: `pint.fitter` object

Returns
=======
output_val: string object that corresponds to the printed outputs of the checker
"""
chi2_decrease = fitter.resids_init.chi2-fitter.resids.chi2
print(f"chi-squared decreased during fit by {chi2_decrease}")
message = str(f"chi-squared decreased during fit by {chi2_decrease}")
print(message)
output_val = []
output_val.append(message)
if hasattr(fitter, "converged") and fitter.converged:
print("Fitter has converged")
message = "Fitter has converged"
print(message)
output_val.append(message)
else:
if abs(chi2_decrease)<0.01:
print("Fitter has probably converged")
message = "Fitter has probably converged"
print(message)
output_val.append(message)
elif chi2_decrease<0:
log.warning("Fitter has increased chi2!")
message = "Fitter has increased chi2!"
log.warning(message)
output_val.append(message)
else:
log.warning("Fitter may not have converged")
message = "Fitter may not have converged"
log.warning(message)
output_val.append(message)
if chi2_decrease > 0.01:
log.warning("Input par file is not fully fitted")
message = "Input par file is not fully fitted"
log.warning(message)
output_val.append(message)
return output_val

def file_look(filenm, plot_type = 'profile'):
""" Plots profile, GTpd, or YFp for a single file
Expand Down
Loading