Skip to content

fix: fix Qmax update after load new parsed data#173

Merged
sbillinge merged 3 commits intodiffpy:mainfrom
stevenhua0320:fix-Qmax-update
Apr 7, 2026
Merged

fix: fix Qmax update after load new parsed data#173
sbillinge merged 3 commits intodiffpy:mainfrom
stevenhua0320:fix-Qmax-update

Conversation

@stevenhua0320
Copy link
Copy Markdown
Contributor

@stevenhua0320 stevenhua0320 commented Apr 6, 2026

@sbillinge ready to review. Note that the logic here is pretty the same as before, but the difference is that in the process of loading the metadata, we need to update it right after we load it so that Qmax could be updated. And then we do the self._flush to dump other parameters into the Profile. Since we might need to use it internally multiple times, I made a private function for this. I also did a test on the local for what we can test here #59. Using the script that provided, I confirmed that Qmax is indeed updated when we loadParsedData again.
Closes #59

diffpy.srfit_env) huarundong@Stevens-MacBook-Pro-405 diffpy.srfit % python check_qmax_reload.py test_1.txt test_2.txt
/Users/huarundong/dbs/diffpy.srfit/check_qmax_reload.py:94: DeprecationWarning: 'diffpy.srfit.fitbase.FitContribution.setProfile' is deprecated and will be removed in version 4.0.0. Please use 'diffpy.srfit.fitbase.FitContribution.set_profile' instead.
  contribution.setProfile(profile, xname="r")

Initial generator Q_max from test_1.txt: 25.0

Metadata in new file suggests Q_max should be 40.0, q_max is now 40.0

These are equal

Now setting Qmax manually from the second file metadata...

Metadata in new file suggests Q_max should be 40.0, q_max is now 40.0

These are equal

Result: Qmax already updates on profile reload.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.36%. Comparing base (1e60597) to head (e2b5c46).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #173   +/-   ##
=======================================
  Coverage   69.36%   69.36%           
=======================================
  Files          25       25           
  Lines        3457     3457           
=======================================
  Hits         2398     2398           
  Misses       1059     1059           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

@sbillinge sbillinge left a comment

Choose a reason for hiding this comment

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

one naming suggestion

# Merge the profiles metadata with our own
self.meta.update(self.profile.meta)
self.processMetaData()
def _on_profile_changed(self, other=()):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's call this _on_profile_update maybe?

@sbillinge sbillinge merged commit e173eff into diffpy:main Apr 7, 2026
7 checks passed
@sbillinge
Copy link
Copy Markdown
Contributor

yeh, thans for this @stevenhua0320 .... we finally fixed @rjkoch's bug from 2019!

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.

loadParsedData of Profile class does not update Q_max

2 participants