Skip to content

deprecate: deprecate the rest of the methods in recipeorganizer.py#169

Merged
sbillinge merged 21 commits intodiffpy:v3.3.0from
cadenmyers13:recipeorg-dep2
Mar 13, 2026
Merged

deprecate: deprecate the rest of the methods in recipeorganizer.py#169
sbillinge merged 21 commits intodiffpy:v3.3.0from
cadenmyers13:recipeorg-dep2

Conversation

@cadenmyers13
Copy link
Contributor

No description provided.

@cadenmyers13 cadenmyers13 changed the title Recipeorg dep2 deprecate: deprecate the rest of the methods in recipeorganizer.py Mar 9, 2026
@cadenmyers13
Copy link
Contributor Author

@sbillinge ready for review

@codecov
Copy link

codecov bot commented Mar 9, 2026

Codecov Report

❌ Patch coverage is 95.94595% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.40%. Comparing base (1c11b31) to head (c115478).
⚠️ Report is 23 commits behind head on v3.3.0.

Files with missing lines Patch % Lines
tests/test_sgconstraints.py 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           v3.3.0     #169      +/-   ##
==========================================
+ Coverage   78.25%   78.40%   +0.15%     
==========================================
  Files          24       24              
  Lines        3674     3700      +26     
==========================================
+ Hits         2875     2901      +26     
  Misses        799      799              
Files with missing lines Coverage Δ
tests/conftest.py 92.40% <100.00%> (ø)
tests/test_constraint.py 98.30% <100.00%> (+1.33%) ⬆️
tests/test_fitrecipe.py 99.85% <100.00%> (ø)
tests/test_recipeorganizer.py 99.73% <100.00%> (ø)
tests/test_restraint.py 96.87% <100.00%> (ø)
tests/test_sgconstraints.py 10.06% <0.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
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.

please see comment.

# Biso = 8*pi**2*Uiso)
recipe.restrain("delta2_ni", lb=2.22, ub=2.22, scaled=True)
recipe.restrain("Biso_0_ni", lb=0.454, ub=0.454, scaled=True)
recipe.add_restraint("delta2_ni", lb=2.22, ub=2.22, scaled=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I like add_restraint better than constrain_parameter. It is not completely clear to me whether we are constraining parameters or variables or what is happening. Actually, I think that the constraint maps parameters to variables somehow. In that case, to avoid awkwardness, does it make sense to call it add_constraint. I am open to discussion on this, but I since we are deprecating everything, it is really our opportunity to think about this and get it right this time....

Copy link
Contributor Author

@cadenmyers13 cadenmyers13 Mar 11, 2026

Choose a reason for hiding this comment

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

@sbillinge Yeah lets go with add_. I think the words constrain and restrain can also get mixed up in the heads of users (and mine lol). What if we did change,

  • constrain --> add_constraint
  • restrain --> add_penalty or add_bounds or add_soft_bounds

what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We actually have a Restraint class that manages all the restraints as well as _restraints attributes, so this could get confusing if we change... I still am not much of a fan of how similar those two words are

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is a Restraint.penalty method though that calculates the penalty, so add_penalty might be okay

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's go with add_penalty, I like that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sbillinge okay i made the change, see the commit messages and the news items for whats changed

Copy link
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.

I am again not sure about this. Looking at the code, the only penalty we are allowed to add seems to be bounds on a variable, that are presumably soft bounds. I actually think that "restraint" is the right word to use here. We maybe just need to educate people what restraints are, as "soft" constraints, that restrain parameter values within a window by applying a penalty when they move out of the window.

@cadenmyers13
Copy link
Contributor Author

@sbillinge yeah makes sense. I do think it would be nice to have some difference between the two though. Something like add_soft_restraint or something because, even if you know the difference, the name similarity can be a little annoying when writing cmi scripts.

@cadenmyers13
Copy link
Contributor Author

@sbillinge or even add_soft_bounds since we are bounding the parameter with upper and lower bounds. this is a bit more descriptive i think.

@sbillinge
Copy link
Contributor

OK, let's go with add soft bounds. I think this is good because the signature is something like add_soft_bounds(variable_name, lower_bound, upper_bound, penalty) so it reads well.

@sbillinge
Copy link
Contributor

incidentally, let's make sure it is documented well how the bounds are applied in detail and whether the behavior can be controlled in any way by the user, if they want to use their own function for some reason or change how it is weighted.

@cadenmyers13
Copy link
Contributor Author

@sbillinge ready for review. There is a defined penalty equation that is used so the user cannot add their own. We could add this feature though. probably better on a different PR

@sbillinge sbillinge merged commit 614d468 into diffpy:v3.3.0 Mar 13, 2026
6 checks passed
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