Skip to content

Conversation

@zmx27
Copy link
Contributor

@zmx27 zmx27 commented Nov 25, 2025

Closes #21

@zmx27
Copy link
Contributor Author

zmx27 commented Nov 25, 2025

@sbillinge I gave my best attempt at this issue. Here is what I did:

  • added a wrapper that emits a DeprecationWarning that also keeps the original behavior
  • updated the test to assert a DeprecationWarning when the deprecated method is called
  • verified there are no other valid references to the setScatteringFactorTableByType method besides the wrapper and the test (there is a call to this method that is commented out, but I didn't count that)

@codecov
Copy link

codecov bot commented Nov 25, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.52%. Comparing base (cd4e94e) to head (80fa501).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #78   +/-   ##
=======================================
  Coverage   98.51%   98.52%           
=======================================
  Files          20       20           
  Lines        3235     3248   +13     
=======================================
+ Hits         3187     3200   +13     
  Misses         48       48           
Files with missing lines Coverage Δ
tests/test_debyepdfcalculator.py 99.39% <100.00%> (+0.05%) ⬆️
🚀 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.

Thanks so much @zmx27 this is great! I don't have a very good way of checking if the code is good or not, but if you can make the tests as I suggest and they pass I guess it is fine!

Please

  1. update the error message from "future release" to give the release number of the next major release....2.0.0 or whatever.
  2. make an issue to remove the capability that has been deprecated. We will have to make a milestone for that major release and we can link that issue to it.
  3. write the tests as requested and make sure they are passing, then let me know. I am not acutally sure how we test the cpp code but figure that out if you would and let m eknow.

Again, gthanks so much.

bp::object DeprecationWarning = builtins.attr("DeprecationWarning");
warnings.attr("warn")(
std::string("setScatteringFactorTableByType is deprecated; "
"assign the 'scatteringfactortable' property directly (for example, use SFTNeutron()/SFTXray())."),
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 give an example of the exact syntax in this help message, as you did in the comment above. But this will be more visible to users.

dpdfc = self.dpdfc
dpdfc.setScatteringFactorTableByType("N")
with self.assertWarns(DeprecationWarning):
dpdfc.setScatteringFactorTableByType("N")
Copy link
Contributor

Choose a reason for hiding this comment

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

this test is good. However, do we also need to run a test where this is done using the new way? We want to make sure that

  1. the functionality works with the new syntax (it may be tested elsewhere, but just check)
  2. the functionality works with the old syntax
  3. the old syntax triggers the deprecation warning
  4. the new syntax doesn't trigger the deprecation warning

@zmx27
Copy link
Contributor Author

zmx27 commented Nov 28, 2025

@sbillinge ready for review

@sbillinge
Copy link
Contributor

Please confirm that you have made an issue in diffpy.srfit to change the call to the new API

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.

Looks good. Please make an issue to remove this method and the tests and I will attach it to a 2.0.0 milestone.

Also, please make an issue in srfiit to change how it is handled in there (and make a PR if possible). Finally, make an issue in diffpy.cmi to check examples for any uses and update them.

Thanks so much.

@sbillinge sbillinge merged commit 495c27e into diffpy:main Dec 1, 2025
7 checks passed
@zmx27
Copy link
Contributor Author

zmx27 commented Dec 2, 2025

I confirm that an issue has been created in diffpy.srfit and diffpy.cmi to look for calls to setScatteringFactorTableByType and update them to the new API. I also confirm that an issue has been made in srreal to remove this method and its corresponding tests.

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.

deprecate setScatteringFactorTableByType

2 participants