Skip to content

chore: update pre-commit - #184

Merged
sbillinge merged 18 commits into
diffpy:mainfrom
danielsirakov:update_pre-commit
Jun 25, 2026
Merged

chore: update pre-commit#184
sbillinge merged 18 commits into
diffpy:mainfrom
danielsirakov:update_pre-commit

Conversation

@danielsirakov

@danielsirakov danielsirakov commented May 31, 2026

Copy link
Copy Markdown
Contributor

@stevenhua0320, ready to review

@stevenhua0320

Copy link
Copy Markdown
Contributor

@danielsirakov same here.

@codecov

codecov Bot commented May 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.74%. Comparing base (a9eae82) to head (564fa2c).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #184      +/-   ##
==========================================
+ Coverage   71.63%   71.74%   +0.11%     
==========================================
  Files          25       25              
  Lines        3437     3437              
==========================================
+ Hits         2462     2466       +4     
+ Misses        975      971       -4     
Files with missing lines Coverage Δ
tests/test_builder.py 100.00% <ø> (ø)
tests/test_characteristicfunctions.py 16.03% <100.00%> (+3.77%) ⬆️
tests/test_constraint.py 96.96% <ø> (ø)
tests/test_contribution.py 99.51% <ø> (ø)
tests/test_equation.py 100.00% <ø> (ø)
tests/test_fitrecipe.py 99.76% <ø> (ø)
tests/test_literals.py 99.17% <ø> (ø)
tests/test_objcrystparset.py 10.27% <ø> (ø)
tests/test_profile.py 99.33% <ø> (ø)
tests/test_recipeorganizer.py 99.69% <ø> (ø)
... and 4 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sbillinge

Copy link
Copy Markdown
Contributor

For some weird reason this is deleting blank lines after the docstring. I asked claude and it seems as if this is a bug in v1.7.8 of docformatter which people have requested fixes for. Please could you try again (let's close this PR so we don't merge all the back and forth history) pinning to 1.7.7 and see what happens?

@stevenhua0320

Copy link
Copy Markdown
Contributor

@danielsirakov could you revisit this one as we have an agreement that deleting line form docformatter is a right fix. So, let's do a review to this one and make sure that everything is right. Thanks!

@sbillinge

Copy link
Copy Markdown
Contributor

The files look Ok. We just need to check if this version is passing pre-commit

@stevenhua0320

Copy link
Copy Markdown
Contributor

@danielsirakov Could you take a look for the failure of black and docformatter? Seems there is a conflict in the formatting of the docstring here. If it is the case, we could do a reformatting as before to get around this. Thanks for your effort.

@danielsirakov

Copy link
Copy Markdown
Contributor Author

@danielsirakov Could you take a look for the failure of black and docformatter? Seems there is a conflict in the formatting of the docstring here. If it is the case, we could do a reformatting as before to get around this. Thanks for your effort.

Sounds good, I'll take a look after I make the last few edits to diffpy.structure

…rfit into update_pre-commit

# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
@danielsirakov

Copy link
Copy Markdown
Contributor Author

I was able to bypass the docformatter and black conflict by changing triple quotes to just using double quotes in 3 files. Let me know if this is an appropriate workaround.

@stevenhua0320, ready to review

@stevenhua0320

Copy link
Copy Markdown
Contributor

@danielsirakov I think we have one left for the conflict here:
tests/test_characteristicfunctions.py
you can check what is conflicting by running it on local and see how we gonna fix this.

@danielsirakov

Copy link
Copy Markdown
Contributor Author

@danielsirakov I think we have one left for the conflict here: tests/test_characteristicfunctions.py you can check what is conflicting by running it on local and see how we gonna fix this.

I think this had something to do with me merging my edits with the bot edits; I just ran the pre-commit, and it edited the file automatically and passed once I ran it again. I'll push again with the pre-commit's edit.

@danielsirakov

Copy link
Copy Markdown
Contributor Author

@stevenhua ready to review

@stevenhua0320

Copy link
Copy Markdown
Contributor

@danielsirakov Still not passing, first you could do the git pull origin <branch-name> to merge the current pre-commit bot update, then do the single black and docformatter sequentially and see what did they edit on the same file.

@danielsirakov

Copy link
Copy Markdown
Contributor Author

@danielsirakov Still not passing, first you could do the git pull origin <branch-name> to merge the current pre-commit bot update, then do the single black and docformatter sequentially and see what did they edit on the same file.

Sorry about that, it said it was passing when I ran the pre-commit before pushing so I’m not sure why that’s happening. I’m not home right now, but I’ll take a look as soon as I’m back.

@sbillinge sbillinge left a comment

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.

I left comments. Let's try moving the failing module level docstrings to the top

Comment thread src/diffpy/srfit/exceptions.py Outdated
Exceptions used for SrFit - specific errors.
"""

"Exceptions used for SrFit - specific errors."

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.

This one should be a docstring I think. Does it work putting it right at the top of the file but with triple quotes?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sorry for the long delay; I've been having technical difficulties with my computer. When I try this, the docformatter and black conflict happens once again. Are there any other workarounds you recommend I should try?

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.

Could you describe how does it conflict with each other, in other words, what does black do initially?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It seems like black is adding a blank line before class, while docformatter is removing it

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.

I believe this is the same scenario that we had before, try to add a #FIXME comment and see if we could get around this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

just pushed, let me know if everything looks fine

@stevenhua0320 ready to review

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.

One more fix is needed, look into the tests/test_characteristicfunctions.py and see how does black and docformatter is conflicting right now. Also don't stay up too late haha.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll take a look right now. Don't worry, I'm gonna hit the hay after this : )

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It looked to be the same scenario as before, and I added a #FIXME line. Let me know if it looks fine

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Interesting, it looks like black and the pre-commit-ci bot have conflict, as the bot removes a line that black adds. What do you recommend we do? Claude recommended I move the import to the top of the file instead of inside the function.

Comment thread src/diffpy/srfit/sas/sasimport.py Outdated
#
##############################################################################
"""Universal import functions for volatile SasView/SansViews API-s."""
"Universal import functions for volatile SasView/SansViews API-s."

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.

This should be a docstring, try moving to the top

Comment thread src/diffpy/srfit/util/argbinders.py Outdated
#
##############################################################################
"""Functions for binding arguments of callable objects."""
"Functions for binding arguments of callable objects."

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.

Docstring

+ "latest sasview API"
)
from sasmodels.sasview_model import find_model, load_standard_models

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.

Could we move this import statement to the top of import modules and check whether it could fix the conflicting behavior while the test module is still valid?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I moved it to the top but I noticed there are other instances of the import statements being in that location, should I delete them all since I have it in the import section now?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Also, how do I check that the test module is still valid?

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.

If they import the same function, you could remove it and test it by running pytest on your terminal; otherwise, you need to add the function name eg:find_model after the import and rerun pytest to see whether the test is running properly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm having trouble running pytest as I don't have the necessary packages downloaded in my environment, and when I tried downloading them, it said that the diffpy-srfit package required Python between 3.11 and 3.13. Should I make a new environment, or try and test it in a different way?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

btw, I'll finish this tomorrow as I'm going to bed

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.

btw, I'll finish this tomorrow as I'm going to bed

No worries, have a good rest for today!

@danielsirakov danielsirakov Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks! You too!

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.

You need to have this installed in editable mode to do testing, but this is standard practice, we should maybe have told you. I also am seeing the CI pre-commit working target hard. Out Is Better of you are running pre-commit locally. We should only see CI pre-commit things very rarely when things go wrong locally. @Rundong can help you get everything set up locally correctly

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sounds good, I'll reach out to Rundong!

@danielsirakov

Copy link
Copy Markdown
Contributor Author

@danielsirakov please make sure that tests are passing locally before pushing. Did you run pytest on everything on your local? It won't catch everything, but anything that fails locally will also fail in CI. This would, most likely, have failed locally.

Sorry for the delay; I was traveling and moving furniture today. I ran pytest locally before pushing, and it passed, so I'm not sure why it's still failing. I'll go back and double-check now, and then I'll add Rundong's try except fix and test again. Once I'm done, I'll open an issue and try to work on a solution with Rundong.

Yes. This happens sometimes. The CI runs tests on a clean environment and locally your tests are running in whatever environment you have on your machine. The CI tests are therefore stricter and a better test of the user experience.

What is meant by a clean environment, and could I make a new environment that matches the one CI tests on in my local to check before pushing?

@sbillinge

Copy link
Copy Markdown
Contributor

Yes. Just create a new 3:14 environment and install whatever is in conda install --file requirements/conda.txt and then pip install diffpy.srfit

@sbillinge

Copy link
Copy Markdown
Contributor

Then run pytest in that env

@danielsirakov

Copy link
Copy Markdown
Contributor Author

thanks, I'll try that now

@danielsirakov

Copy link
Copy Markdown
Contributor Author

When I ran pytest, it wouldn't run because pkg_resources was missing. Is that something I should install, or does this show that it won't work in CI's clean environment?

@sbillinge

Copy link
Copy Markdown
Contributor

You may want to work with Rundong as I didn't think pkg_resources was a dependency in or latest code so there may be a problem with your installation.

@stevenhua0320

Copy link
Copy Markdown
Contributor

When I ran pytest, it wouldn't run because pkg_resources was missing. Is that something I should install, or does this show that it won't work in CI's clean environment?

It might be good to reset the environment that you are running for this package. To do this, first we should have a clean environment that has nothing except for python.

conda create -n <name-of-env> python=3.14

Then activate it

conda activate <name-of-env>

Assuming you have added conda-forge in the channel, then rebuild the environment from the known source directory

conda install --file requirements/conda.txt
conda install pre-commit

and also install the test:

conda install --file requirements/tests.txt

Up till now, we have rebuilt the environment. To test whether our edit is proper, after your edits, you need to run

pip install -e .

and then run pytest as I have told you before. Then you could see the local test message and check whether it is all passing. Before you make any commit, you should run pre-commit run --all-files to do the auto-linting.
I think this covers all the steps that you need to rebuild the local environment.

@danielsirakov

Copy link
Copy Markdown
Contributor Author

When I ran pytest, it wouldn't run because pkg_resources was missing. Is that something I should install, or does this show that it won't work in CI's clean environment?

It might be good to reset the environment that you are running for this package. To do this, first we should have a clean environment that has nothing except for python.

conda create -n <name-of-env> python=3.14

Then activate it

conda activate <name-of-env>

Assuming you have added conda-forge in the channel, then rebuild the environment from the known source directory

conda install --file requirements/conda.txt
conda install pre-commit

and also install the test:

conda install --file requirements/tests.txt

Up till now, we have rebuilt the environment. To test whether our edit is proper, after your edits, you need to run

pip install -e .

and then run pytest as I have told you before. Then you could see the local test message and check whether it is all passing. Before you make any commit, you should run pre-commit run --all-files to do the auto-linting. I think this covers all the steps that you need to rebuild the local environment.

When I run pip install -e . in my Python 3.14 environment, it fails with ERROR: Package 'diffpy-srfit' requires a different Python: 3.14.6 not in '<3.14,>=3.11'. I thought editable mode would bypass this, but it doesn't seem to. Should I update the requires-python constraint in pyproject.toml to include 3.14, or is there another workaround?

@stevenhua0320

Copy link
Copy Markdown
Contributor

When I ran pytest, it wouldn't run because pkg_resources was missing. Is that something I should install, or does this show that it won't work in CI's clean environment?

It might be good to reset the environment that you are running for this package. To do this, first we should have a clean environment that has nothing except for python.

conda create -n <name-of-env> python=3.14

Then activate it

conda activate <name-of-env>

Assuming you have added conda-forge in the channel, then rebuild the environment from the known source directory

conda install --file requirements/conda.txt
conda install pre-commit

and also install the test:

conda install --file requirements/tests.txt

Up till now, we have rebuilt the environment. To test whether our edit is proper, after your edits, you need to run

pip install -e .

and then run pytest as I have told you before. Then you could see the local test message and check whether it is all passing. Before you make any commit, you should run pre-commit run --all-files to do the auto-linting. I think this covers all the steps that you need to rebuild the local environment.

When I run pip install -e . in my Python 3.14 environment, it fails with ERROR: Package 'diffpy-srfit' requires a different Python: 3.14.6 not in '<3.14,>=3.11'. I thought editable mode would bypass this, but it doesn't seem to. Should I update the requires-python constraint in pyproject.toml to include 3.14, or is there another workaround?

Sorry, I forgot this package still not pushing to python=3.14, so we need to make the environment back to python=3.13. To do this, run conda install python=3.13 and after it is successful, run pip install -e .

@danielsirakov

Copy link
Copy Markdown
Contributor Author

With the try except workaround, it passes pytest in the clean environment but only with the extend path in init.py, without the edits it cannot find diffpy.srfit. Should I try pushing with or without the extend path edit to init.py?

@danielsirakov

Copy link
Copy Markdown
Contributor Author

With the try except workaround, it passes pytest in the clean environment but only with the extend path in init.py, without the edits it cannot find diffpy.srfit. Should I try pushing with or without the extend path edit to init.py?

Also, it passes the pre-commit in the clean environment.

@stevenhua0320

Copy link
Copy Markdown
Contributor

With the try except workaround, it passes pytest in the clean environment but only with the extend path in init.py, without the edits it cannot find diffpy.srfit. Should I try pushing with or without the extend path edit to init.py?

With the try except workaround, it passes pytest in the clean environment but only with the extend path in init.py, without the edits it cannot find diffpy.srfit. Should I try pushing with or without the extend path edit to init.py?

You should then commit the changes without __init__.py as it is a misconfigure on local that the environment could not find the directory of the package properly while on Github it does not have the issue.

@danielsirakov

Copy link
Copy Markdown
Contributor Author

With the try except workaround, it passes pytest in the clean environment but only with the extend path in init.py, without the edits it cannot find diffpy.srfit. Should I try pushing with or without the extend path edit to init.py?

With the try except workaround, it passes pytest in the clean environment but only with the extend path in init.py, without the edits it cannot find diffpy.srfit. Should I try pushing with or without the extend path edit to init.py?

You should then commit the changes without __init__.py as it is a misconfigure on local that the environment could not find the directory of the package properly while on Github it does not have the issue.

Sounds good, I'll push now

@danielsirakov

Copy link
Copy Markdown
Contributor Author

@stevenhua0320 ready to review

@stevenhua0320

Copy link
Copy Markdown
Contributor

@danielsirakov Did you confirm that all pytest is passing now? If so please paste the result here and if so I would call Simon to take the review.

@danielsirakov

Copy link
Copy Markdown
Contributor Author

I just double checked again now. Everything passes, but test_characteristicfunctions.py was skipped. I originally thought this was because my environment didn't have sasmodels installed, but I downloaded and tried again, and they were still skipped. I looked into it, and there's a skip message in each of the tests that says "sas characteristic functions not currently working, remove skip when our code is refactored."

@danielsirakov

Copy link
Copy Markdown
Contributor Author

I originally assumed the pytest output meant everything was passing, but now I realize the tests themselves are marked to skip intentionally, so pytest isn't actually running the test logic to verify that the functions work and only verifies that the import statement doesn't crash.

@stevenhua0320

Copy link
Copy Markdown
Contributor

I just double checked again now. Everything passes, but test_characteristicfunctions.py was skipped. I originally thought this was because my environment didn't have sasmodels installed, but I downloaded and tried again, and they were still skipped. I looked into it, and there's a skip message in each of the tests that says "sas characteristic functions not currently working, remove skip when our code is refactored."

Yes, and our convention is that when you go through the test, you need to show the reviewer the output. It is okay that you don't do it this time, but from now on, it is good to paste the test output with a code block. For example:

(paste the result here)

@sbillinge ready for another review.

@danielsirakov

Copy link
Copy Markdown
Contributor Author

Sorry for not pasting it, I just wasn't sure if we needed to run it again due to the skips. Here's my most recent pytest: `(ci_pytest_env) PS C:\Users\danny\dbs\diffpy.srfit> pytest
======================================================================= test session starts ========================================================================
platform win32 -- Python 3.13.14, pytest-9.1.1, pluggy-1.6.0
rootdir: C:\Users\danny\dbs\diffpy.srfit
configfile: pyproject.toml
plugins: cov-7.1.0, env-1.6.0
collected 127 items

tests\test_builder.py ...... [ 4%]
tests\test_characteristicfunctions.py ssss [ 7%]
tests\test_constraint.py . [ 8%]
tests\test_contribution.py .......... [ 16%]
tests\test_diffpyparset.py ... [ 18%]
tests\test_equation.py .. [ 20%]
tests\test_fitrecipe.py .................... [ 36%]
tests\test_fitresults.py ... [ 38%]
tests\test_literals.py ......... [ 45%]
tests\test_objcrystparset.py sssssssssss [ 54%]
tests\test_parameter.py ... [ 56%]
tests\test_parameterset.py . [ 57%]
tests\test_pdf.py ..ssssss [ 63%]
tests\test_profile.py ...... [ 68%]
tests\test_profilegenerator.py ... [ 70%]
tests\test_recipeorganizer.py ............... [ 82%]
tests\test_restraint.py . [ 83%]
tests\test_sas.py sss [ 85%]
tests\test_sgconstraints.py sss [ 88%]
tests\test_tagmanager.py .... [ 91%]
tests\test_version.py . [ 92%]
tests\test_visitors.py .... [ 95%]
tests\test_weakrefcallable.py ...... [100%]

========================================================================= warnings summary =========================================================================
tests/test_contribution.py::TestContribution::testset_profile
C:\Users\danny\miniconda3\envs\ci_pytest_env\Lib\unittest\case.py:238: 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.
callable_obj(*args, **kwargs)

tests/test_diffpyparset.py::testDiffpyStructureParSet
C:\Users\danny\dbs\diffpy.srfit\tests\test_diffpyparset.py:85: DeprecationWarning: 'diffpy.structure.Lattice.setLatPar' is deprecated and will be removed in version 4.0.0. Please use 'diffpy.structure.Lattice.set_latt_parms' instead.
dsstru.lattice.setLatPar(a=3.0, gamma=121)

tests/test_diffpyparset.py::test___repr__
tests/test_diffpyparset.py::test___repr__
C:\Users\danny\miniconda3\envs\ci_pytest_env\Lib\site-packages\diffpy\structure\lattice.py:760: DeprecationWarning: 'diffpy.structure.Lattice.abcABG' is deprecated and will be removed in version 4.0.0. Please use 'diffpy.structure.Lattice.cell_parms' instead.
latpardiff = cartlatpar - self.abcABG()

tests/test_diffpyparset.py::test___repr__
tests/test_diffpyparset.py::test___repr__
C:\Users\danny\miniconda3\envs\ci_pytest_env\Lib\site-packages\diffpy\structure\lattice.py:766: DeprecationWarning: 'diffpy.structure.Lattice.abcABG' is deprecated and will be removed in version 4.0.0. Please use 'diffpy.structure.Lattice.cell_parms' instead.
s = "Lattice(a=%g, b=%g, c=%g, alpha=%g, beta=%g, gamma=%g)" % self.abcABG()

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================================================== 100 passed, 27 skipped, 6 warnings in 2.81s ===========================================================`

@stevenhua0320

Copy link
Copy Markdown
Contributor

Sorry for not pasting it, I just wasn't sure if we needed to run it again due to the skips. Here's my most recent pytest: `(ci_pytest_env) PS C:\Users\danny\dbs\diffpy.srfit> pytest ======================================================================= test session starts ======================================================================== platform win32 -- Python 3.13.14, pytest-9.1.1, pluggy-1.6.0 rootdir: C:\Users\danny\dbs\diffpy.srfit configfile: pyproject.toml plugins: cov-7.1.0, env-1.6.0 collected 127 items

tests\test_builder.py ...... [ 4%] tests\test_characteristicfunctions.py ssss [ 7%] tests\test_constraint.py . [ 8%] tests\test_contribution.py .......... [ 16%] tests\test_diffpyparset.py ... [ 18%] tests\test_equation.py .. [ 20%] tests\test_fitrecipe.py .................... [ 36%] tests\test_fitresults.py ... [ 38%] tests\test_literals.py ......... [ 45%] tests\test_objcrystparset.py sssssssssss [ 54%] tests\test_parameter.py ... [ 56%] tests\test_parameterset.py . [ 57%] tests\test_pdf.py ..ssssss [ 63%] tests\test_profile.py ...... [ 68%] tests\test_profilegenerator.py ... [ 70%] tests\test_recipeorganizer.py ............... [ 82%] tests\test_restraint.py . [ 83%] tests\test_sas.py sss [ 85%] tests\test_sgconstraints.py sss [ 88%] tests\test_tagmanager.py .... [ 91%] tests\test_version.py . [ 92%] tests\test_visitors.py .... [ 95%] tests\test_weakrefcallable.py ...... [100%]

========================================================================= warnings summary ========================================================================= tests/test_contribution.py::TestContribution::testset_profile C:\Users\danny\miniconda3\envs\ci_pytest_env\Lib\unittest\case.py:238: 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. callable_obj(*args, **kwargs)

tests/test_diffpyparset.py::testDiffpyStructureParSet C:\Users\danny\dbs\diffpy.srfit\tests\test_diffpyparset.py:85: DeprecationWarning: 'diffpy.structure.Lattice.setLatPar' is deprecated and will be removed in version 4.0.0. Please use 'diffpy.structure.Lattice.set_latt_parms' instead. dsstru.lattice.setLatPar(a=3.0, gamma=121)

tests/test_diffpyparset.py::test___repr__ tests/test_diffpyparset.py::test___repr__ C:\Users\danny\miniconda3\envs\ci_pytest_env\Lib\site-packages\diffpy\structure\lattice.py:760: DeprecationWarning: 'diffpy.structure.Lattice.abcABG' is deprecated and will be removed in version 4.0.0. Please use 'diffpy.structure.Lattice.cell_parms' instead. latpardiff = cartlatpar - self.abcABG()

tests/test_diffpyparset.py::test___repr__ tests/test_diffpyparset.py::test___repr__ C:\Users\danny\miniconda3\envs\ci_pytest_env\Lib\site-packages\diffpy\structure\lattice.py:766: DeprecationWarning: 'diffpy.structure.Lattice.abcABG' is deprecated and will be removed in version 4.0.0. Please use 'diffpy.structure.Lattice.cell_parms' instead. s = "Lattice(a=%g, b=%g, c=%g, alpha=%g, beta=%g, gamma=%g)" % self.abcABG()

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html =========================================================== 100 passed, 27 skipped, 6 warnings in 2.81s ===========================================================`

Try to do the triple quote next time, which would display the result correctly.

(ci_pytest_env) PS C:\Users\danny\dbs\diffpy.srfit> pytest ======================================================================= test session starts ======================================================================== platform win32 -- Python 3.13.14, pytest-9.1.1, pluggy-1.6.0 rootdir: C:\Users\danny\dbs\diffpy.srfit configfile: pyproject.toml plugins: cov-7.1.0, env-1.6.0 collected 127 items
> 
> tests\test_builder.py ...... [ 4%] tests\test_characteristicfunctions.py ssss [ 7%] tests\test_constraint.py . [ 8%] tests\test_contribution.py .......... [ 16%] tests\test_diffpyparset.py ... [ 18%] tests\test_equation.py .. [ 20%] tests\test_fitrecipe.py .................... [ 36%] tests\test_fitresults.py ... [ 38%] tests\test_literals.py ......... [ 45%] tests\test_objcrystparset.py sssssssssss [ 54%] tests\test_parameter.py ... [ 56%] tests\test_parameterset.py . [ 57%] tests\test_pdf.py ..ssssss [ 63%] tests\test_profile.py ...... [ 68%] tests\test_profilegenerator.py ... [ 70%] tests\test_recipeorganizer.py ............... [ 82%] tests\test_restraint.py . [ 83%] tests\test_sas.py sss [ 85%] tests\test_sgconstraints.py sss [ 88%] tests\test_tagmanager.py .... [ 91%] tests\test_version.py . [ 92%] tests\test_visitors.py .... [ 95%] tests\test_weakrefcallable.py ...... [100%]
> 
> ========================================================================= warnings summary ========================================================================= tests/test_contribution.py::TestContribution::testset_profile C:\Users\danny\miniconda3\envs\ci_pytest_env\Lib\unittest\case.py:238: 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. callable_obj(*args, **kwargs)
> 
> tests/test_diffpyparset.py::testDiffpyStructureParSet C:\Users\danny\dbs\diffpy.srfit\tests\test_diffpyparset.py:85: DeprecationWarning: 'diffpy.structure.Lattice.setLatPar' is deprecated and will be removed in version 4.0.0. Please use 'diffpy.structure.Lattice.set_latt_parms' instead. dsstru.lattice.setLatPar(a=3.0, gamma=121)
> 
> tests/test_diffpyparset.py::test___repr__ tests/test_diffpyparset.py::test___repr__ C:\Users\danny\miniconda3\envs\ci_pytest_env\Lib\site-packages\diffpy\structure\lattice.py:760: DeprecationWarning: 'diffpy.structure.Lattice.abcABG' is deprecated and will be removed in version 4.0.0. Please use 'diffpy.structure.Lattice.cell_parms' instead. latpardiff = cartlatpar - self.abcABG()
> 
> tests/test_diffpyparset.py::test___repr__ tests/test_diffpyparset.py::test___repr__ C:\Users\danny\miniconda3\envs\ci_pytest_env\Lib\site-packages\diffpy\structure\lattice.py:766: DeprecationWarning: 'diffpy.structure.Lattice.abcABG' is deprecated and will be removed in version 4.0.0. Please use 'diffpy.structure.Lattice.cell_parms' instead. s = "Lattice(a=%g, b=%g, c=%g, alpha=%g, beta=%g, gamma=%g)" % self.abcABG()
> 
> -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html =========================================================== 100 passed, 27 skipped, 6 warnings in 2.81s ===========================================================

@danielsirakov

Copy link
Copy Markdown
Contributor Author

I see. Thanks for the help!

@sbillinge
sbillinge merged commit e18fcc0 into diffpy:main Jun 25, 2026
7 checks passed
@sbillinge

Copy link
Copy Markdown
Contributor

Thanks for this @danielsirakov great job. That was more work than we expected but hopefully some good learning was accomplished in the process! Please work with @stevenhua0320 to do the steps to get the next version released.

@danielsirakov

Copy link
Copy Markdown
Contributor Author

Thank you, I definitely learned a lot! Looking forward to working with Rundong on the next release.

sbillinge added a commit that referenced this pull request Jul 7, 2026
* fix: fix Qmax update after load new parsed data

* chore: add news item

* chore: rename the private method

* build: add diffpy.structure back to requirement

* chore: rebuild the documentation with proper metadata handling

* chore: update pre-commit (#184)

* chore: update pre-commit

* [pre-commit.ci] auto fixes from pre-commit hooks

* chore: fix docformatter and black conflict

* chore: run pre-commit for file I missed

* [pre-commit.ci] auto fixes from pre-commit hooks

* chore: add #FIXME workaround

* chore: add #FIXME workaround

* [pre-commit.ci] auto fixes from pre-commit hooks

* chore: add another #FIXME workaround

* chore: add another #FIXME workaround

* [pre-commit.ci] auto fixes from pre-commit hooks

* chore: moved import statement to the top of import modules

* [pre-commit.ci] auto fixes from pre-commit hooks

* chore: added try except workaround

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* release: add support for python 3.14 and remove for 3.11 (#187)

* chore: news

* chore: remove duplicate FIXME line

* chore: fix improperly merged method in ProfileGenerator

---------

Co-authored-by: stevenhua0320 <r.hua@mail.utoronto.ca>
Co-authored-by: Simon Billinge <sbillinge@users.noreply.github.com>
Co-authored-by: Daniel Sirakov <danielsirakov73@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
sbillinge added a commit that referenced this pull request Aug 8, 2026
* deprecate addProfileGenerator

* update api docs

* mock utils and pyobjcryst for doc rendering

* news

* restore api docs

* revert conf.py commit

* deprecate addContribution and replace with add_contribution

* news

* deprecate setEquation and replace with set_equation

* more set_equation replacements

* news

* reorder dep message to prevent merge conflicts

* one final setEquation switch in tests

* pushFitHook deprecation

* popFitHook deprecation

* popFitHook dep message

* getFitHooks and clearFitHooks deprecation

* setWeight deprecation

* news

* news pt2

* addParameterSet deprecation

* news

* docstring typo

* deprecate getEquation in fitcontribution.py

* deprecate getEquation from builder.BaseBuilder

* news

* news typo

* deprecate SimpleRecipe.loadParsedData

* deprecate Profile.loadParsedData

* deprecate Profile.setObservedProfile and SimpleRecipe.setObservedProfile

* news

* setCalculationRange

* setCalculationPoints

* change rebinArray to rebin_array

* make _rebin_array private

* missed deprecation tag in SimpleRecipe

* setResidualEquation deprecation

* getResidualEquation deprecation

* news

* news again

* add test for remove and add param_set

* removeParameterSet deprecation

* scalarResidual deprecation

* addVar deprecation

* delVar deprecation

* newVar deprecation

* news

* news 2

* isFree deprecation

* getValues deprecation

* fix typo in base name

* getNames deprecation

* getBounds deprecation

* getBounds2 deprecation

* add test for boundsToRestraints

* boundsToRestraints deprecation

* make bounds to restraints docstring better

* news

* news 2

* make new test cleaner

* remove minus sign typo causing tests to fail

* formatResults deprecation

* printResults deprecation

* add tests for printResults and formatResults

* write test for saveResults

* test for the addition of a header to results

* saveResults deprecation

* news

* set fixtures to scope=function

* add constraints and restraints for more strict testing

* add initialization test and method

* news

* remove accidental commit

* add test for ValueError

* AUTHORS.rst

* CODE-OF-CONDUCT.rst

* cookiecutter.json

* LICENSE.rst

* LICENSE.rst pt2

* MANIFEST.in

* pyproject.toml

* README.rst

* release_checklist.md

* build-and-publish-docs-on-dispatch.yml

* build-wheel-release-upload.yml

* matrix-and-codecov.yml

* README.rst pt2

* conf.py

* index.rst

* license.rst

* diffpy.srfit.rst

* __init__.py

* __init__.py

* __init__.py

* srfit_app.py

* version.py

* news

* [pre-commit.ci] auto fixes from pre-commit hooks

* resultsDictionary deprecation, added to FitResults

* news

* test for resultsDictionary

* improve test

* add comments describing tests

* rm merge-to-main duplicate workflow

* add __init__ header to README

* pull PR to list branch to fix docformatter failure

* [pre-commit.ci] auto fixes from pre-commit hooks

* fix conftest fixture so it creates new recipe object on each call

* update fixture initial values to be more different

* update expected to accound for the slight difference now

* feat: initialize FitRecipe from a results file or object

* test: tests for the new feature

* add utils objects to get dict from results object or file

* news

* fix accident in test_fitresults

* use get_results_dictionary method to get params_dict

* initializeRecipe deprecation

* add better docstrings to fitrecipe and fitresults

* add 'The' to docstrings

* do linspace with odd number of points

* revert recipe fixture back, explicitly set scope to 'function', and add a new helper function that builds recipe for init testing

* add assert recipes arent equal

* add fixture that returns two identical recipes

* add second recipe to fixture build_recipe_one_contribution

* change fixture name to be plural (build_recipes_one_contribution)

* rm deprecated six and other deprecated python2 objects

* setValue deprecation

* news

* skip test_speed.py

* ignore test_speed.py in codecov

* iterPars deprecation

* registerCalculator deprecation

* registerFunction deprecation in EquationFactory and RecipeOrganizer

* registerStringFunction deprecation

* evaluateEquation deprecation

* isConstrained deprecation

* replace par with parameter

* getConstrainedPars deprecation, and write a test for it :)

* small fix

* clearConstraints deprecation, and write small test

* clean up and fix variable names in restrain and constrain methods

* minor docstring typos

* news

* constrain and unconstrain deprecation

* change name to register_restraint

* restrain deprecation

* unrestrain deprecation

* clearRestraints deprecation

* equationFromString deprecation

* news

* constrain_parameter --> add_constraint

* unconstrain_parameter --> remove_constraint

* add_restraint --> add_penalty

* remove_restraint --> remove_penalty

* register_restraint --> register_penalty

* clear_all_restraints --> clear_all_penalties

* change lb to lower_bound everywhere

* change ub to upper_bound everywhere

* add_penalty --> add_soft_bounds

* remove_penalty --> remove_soft_bounds

* register_penalty --> register_soft_bounds

* clear_all_penalties --> clear_all_soft_bounds

* add more to add_soft_bounds docstring

* more to docstring

* processMetaData --> _process_metadata

* isConst --> is_constant

* change Attributes --> Parameters in all docstrings

* boundRange --> bound_range

* boundWindow --> bound_window

* write tests for bound_window and bound_range

* news

* minor docstring fix

* deprecate PDFParser

* build parse_file and deprecate getNumBank, selectBank, getFormat, getData, and getMetaData

* add ProfileParser to __init__ so it can be imported from fitbase

* add test files as conftest fixture

* use ProfileParser in PDFContribution, replacing PDFParser

* Use ProfileParser instead of PDFParser for fitrecipe testing

* getData --> get_data, and getMetaData --> get_metadata in Profile

* add set_parsed_profile test with ProfileParser

* update examples with new parser

* update test_pdf to reflect new parser

* update old formatted test data to get parser to pass tests

* add test for ProfileParser

* update sas module and test to reflect new changes

* news

* rm comment

* blank commit to fix pre-commit

* run pre-commit autoupdate and run pre-commit

* set python version to 3.13 to pin pre-commit CI

* pin only docformatter to python3.13

* rm python3.13 pin on pre-commit-config for now

* pip pre-commit docformatter to 3.13

* fix: fix iterpars behavior

* [pre-commit.ci] auto fixes from pre-commit hooks

* chore: rename par to parameter

* chore: change docstring, refind test description and structure

* [pre-commit.ci] auto fixes from pre-commit hooks

* chore: change to if else statement in the logic

* chore: refactor pytest fixtures and sync `pyproject.toml` and pre-commit file with main (#188)

* sync pre-commit file and pyproject.toml with main

* refactor pytest fixtures to remove use of triple quotes

* chore: news

* [pre-commit.ci] auto fixes from pre-commit hooks

* fix docformatter and black conflicts

* chore: news v2

* clean up ugly docstring formating

* empty commit

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* chore: merge remaining `main` edits into `v3.3.0` (#189)

* fix: fix Qmax update after load new parsed data

* chore: add news item

* chore: rename the private method

* build: add diffpy.structure back to requirement

* chore: rebuild the documentation with proper metadata handling

* chore: update pre-commit (#184)

* chore: update pre-commit

* [pre-commit.ci] auto fixes from pre-commit hooks

* chore: fix docformatter and black conflict

* chore: run pre-commit for file I missed

* [pre-commit.ci] auto fixes from pre-commit hooks

* chore: add #FIXME workaround

* chore: add #FIXME workaround

* [pre-commit.ci] auto fixes from pre-commit hooks

* chore: add another #FIXME workaround

* chore: add another #FIXME workaround

* [pre-commit.ci] auto fixes from pre-commit hooks

* chore: moved import statement to the top of import modules

* [pre-commit.ci] auto fixes from pre-commit hooks

* chore: added try except workaround

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* release: add support for python 3.14 and remove for 3.11 (#187)

* chore: news

* chore: remove duplicate FIXME line

* chore: fix improperly merged method in ProfileGenerator

---------

Co-authored-by: stevenhua0320 <r.hua@mail.utoronto.ca>
Co-authored-by: Simon Billinge <sbillinge@users.noreply.github.com>
Co-authored-by: Daniel Sirakov <danielsirakov73@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* skpkg: update project to latest scikit-package template (#190)

* skpkg: update project to latest scikit-package template

* Reorganize update message in changelog

Moved the update of the project template from 'Changed' to 'Fixed' section.

---------

Co-authored-by: Simon Billinge <sbillinge@users.noreply.github.com>

* change: Handle uncertainties as `None` rather than `1`s (#193)

* fix: return None instead of 0 for unavailable dx/dy uncertainties

* test: update and add tests for None uncertainty behavior

* chore: add news entry for uncertainty None fix

* test: add tests to ensure new handling of uncertainties doesn't break refinements

* change: update profile.set_observed_profile() to not convert dy to ones if dy is None

* chore: update news file

* Update tests to make it easier to not use a testdata file for interpretability

* add as_list as a fixture

* add comment about how the fixture is used in test

* add three_column case

* use as_list as a fixture

* Fix: Restore extensibility of `ProfileParser` and use `load_data` from `diffpy.utils` (#196)

* Update examples to use the correct parser and add description of how to create your own parser in docs

* update old metadata format to new xPDFsuite and pdfgetx headers. One testdata file for each

* add test for new parser behavior

* change how ProfileParsers work by allowing user to create their own parsers for metadata and the data itself

* update the pre-existing news file with these changes

* Make PDFParser identical to ProfileParser now that ProfileParser defaults to load_data

* update old data metadata formats in testdata files to mirror xPDFsuite (neutron data) and pdfgetx (xray data)

* updated expected metadata in test

* fix docs description of ProfileParser

* update news

* minor docstring fix

* tests for adding metadata upon parsing a file with ProfileParser

* feat: allow user to append metadata when parsing a file with profileparser

* doc: Update docstrings across `fitbase/` and `pdf/` to group standards (#198)

* Update docstrings in fitbase to numpy/group standards

* update docstrings in pdf to np/group standards

* update docstrings in interface and structure to group standards

* news

* use recipe.plot_recipe() to plot fits in examples

* remove plot_results in favor of recipe.plot_recipe() method

* Change plot_recipe to display the contribution name as the title

* add tests for the new plot_recipe behavior

* rm accidentally commited output file

* tidy a test up

* empty commit for CI

* dep: Deprecate characteristic functions containing camel case (#197)

* Deprecate characteristic function camel case names

* Change cf names in example scripts

* add tests for characteristic functions

* news

* deprecate constrainAsSpaceGroup

* update news

* change: emit a warning if a characteristic function goes to a negative value during refinement. The output goes to zero

* Add tests for new CF behavior for non-physical input parameters

* cf news

* empty commit for CI

* change: update how the deprecated characteristic functions handle the signature changes (#199)

* revert parameters in old function signatures to prevent errors when the name is specified in the signature

* Change how the deprecated characteristic functions handle the signature change

* Add test cases for the deprecated functions signature changes

* news

---------

Co-authored-by: Simon Billinge <sbillinge@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: stevenhua0320 <r.hua@mail.utoronto.ca>
Co-authored-by: Daniel Sirakov <danielsirakov73@gmail.com>
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.

3 participants