Skip to content

feat: Initialize a fit recipe with a previous recipe#162

Merged
sbillinge merged 6 commits intodiffpy:v3.3.0from
cadenmyers13:init-w-recipe
Feb 25, 2026
Merged

feat: Initialize a fit recipe with a previous recipe#162
sbillinge merged 6 commits intodiffpy:v3.3.0from
cadenmyers13:init-w-recipe

Conversation

@cadenmyers13
Copy link
Contributor

@cadenmyers13 cadenmyers13 commented Feb 25, 2026

This initializes a fit with everything, not just variables and values

@cadenmyers13
Copy link
Contributor Author

@sbillinge ready for review! this should be much easier to review hopefully 😆

@codecov
Copy link

codecov bot commented Feb 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.16%. Comparing base (a08850f) to head (4b60d8a).
⚠️ Report is 8 commits behind head on v3.3.0.

Additional details and impacted files
@@            Coverage Diff             @@
##           v3.3.0     #162      +/-   ##
==========================================
+ Coverage   71.80%   72.16%   +0.35%     
==========================================
  Files          25       25              
  Lines        3756     3804      +48     
==========================================
+ Hits         2697     2745      +48     
  Misses       1059     1059              
Files with missing lines Coverage Δ
tests/conftest.py 91.78% <100.00%> (+0.29%) ⬆️
tests/test_fitrecipe.py 99.83% <100.00%> (+0.01%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.


for contrib_object in recipe_object._contributions.values():
if contrib_object not in self._contributions.values():
self.add_contribution(contrib_object)
Copy link
Contributor Author

@cadenmyers13 cadenmyers13 Feb 25, 2026

Choose a reason for hiding this comment

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

Used .add_contribution() since it actually takes a contribution object.

Copy link
Contributor

Choose a reason for hiding this comment

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

that's what I am talkin' about. Much better than parsing a results file string.

for restraint in recipe_object._restraints:
if restraint not in self._restraints:
self._restraints.add(restraint)

Copy link
Contributor Author

@cadenmyers13 cadenmyers13 Feb 25, 2026

Choose a reason for hiding this comment

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

Had to use .add() and .update() here because the .restrain(), .constrain(), and .create_new_parameter() methods dont accept the respective objects

Copy link
Contributor

Choose a reason for hiding this comment

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

ok

recipe.constrain(contribution2.B, "0.5*A")
recipe.restrain(contribution1.A, 0.5, 1.5)
recipe.restrain(contribution1.k, 0.8, 1.2)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Improved this so we can actually test for constrain and restrain

@sbillinge
Copy link
Contributor

I will merge but is this missing a ci test? Is it the news check? I am not sure. I wonder if we want to do a quick package update?

@sbillinge sbillinge merged commit 6de334f into diffpy:v3.3.0 Feb 25, 2026
6 checks passed
@cadenmyers13
Copy link
Contributor Author

@sbillinge oh yeah probably. I'll do that

@cadenmyers13 cadenmyers13 deleted the init-w-recipe branch February 25, 2026 19:00
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.

2 participants