Skip to content

fix: change logic of iterPars method with same type atoms to have same ADPs#178

Open
stevenhua0320 wants to merge 1 commit intodiffpy:mainfrom
stevenhua0320:iterpars-behavior
Open

fix: change logic of iterPars method with same type atoms to have same ADPs#178
stevenhua0320 wants to merge 1 commit intodiffpy:mainfrom
stevenhua0320:iterpars-behavior

Conversation

@stevenhua0320
Copy link
Copy Markdown
Contributor

@sbillinge ready to review. Originally, we checked at the tree level par.names, but all the ADP are stored in its parent level, so with the current logic we could only manually change it from its parent to children. With this modification, we could recursively start on the parent level and iteratively set the ADPs to the equal-type atoms. I have local env installed with latest diffpy.srreal and go through all the tests. I confirmed that with the change that I have here, it will be functioning properly.

(diffpy.srfit_env) huarundong@Stevens-MacBook-Pro-405 diffpy.srfit % pytest
================================================================================================================== test session starts ===================================================================================================================
platform darwin -- Python 3.13.12, pytest-9.0.2, pluggy-1.6.0
rootdir: /Users/huarundong/dbs/diffpy.srfit
configfile: pyproject.toml
plugins: cov-7.1.0, env-1.6.0
collected 135 items                                                                                                                                                                                                                                      

tests/test_builder.py ......                                                                                                                                                                                                                       [  4%]
tests/test_characteristicfunctions.py ssss                                                                                                                                                                                                         [  7%]
tests/test_constraint.py .                                                                                                                                                                                                                         [  8%]
tests/test_contribution.py ..........                                                                                                                                                                                                              [ 15%]
tests/test_diffpyparset.py ...                                                                                                                                                                                                                     [ 17%]
tests/test_equation.py ..                                                                                                                                                                                                                          [ 19%]
tests/test_fitrecipe.py ....................                                                                                                                                                                                                       [ 34%]
tests/test_fitresults.py ...                                                                                                                                                                                                                       [ 36%]
tests/test_literals.py .........                                                                                                                                                                                                                   [ 42%]
tests/test_objcrystparset.py ...........                                                                                                                                                                                                           [ 51%]
tests/test_parameter.py ...                                                                                                                                                                                                                        [ 53%]
tests/test_parameterset.py .                                                                                                                                                                                                                       [ 54%]
tests/test_pdf.py ................                                                                                                                                                                                                                 [ 65%]
tests/test_profile.py ......                                                                                                                                                                                                                       [ 70%]
tests/test_profilegenerator.py ...                                                                                                                                                                                                                 [ 72%]
tests/test_recipeorganizer.py ...............                                                                                                                                                                                                      [ 83%]
tests/test_restraint.py .                                                                                                                                                                                                                          [ 84%]
tests/test_sas.py sss                                                                                                                                                                                                                              [ 86%]
tests/test_sgconstraints.py ...                                                                                                                                                                                                                    [ 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
  /opt/miniconda3/envs/diffpy.srfit_env/lib/python3.13/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
  /Users/huarundong/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__
  /opt/miniconda3/envs/diffpy.srfit_env/lib/python3.13/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__
  /opt/miniconda3/envs/diffpy.srfit_env/lib/python3.13/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()

tests/test_pdf.py: 2 warnings
tests/test_sgconstraints.py: 32 warnings
  /opt/miniconda3/envs/diffpy.srfit_env/lib/python3.13/site-packages/diffpy/structure/symmetryutilities.py:604: DeprecationWarning: 'diffpy.structure.expandPosition' is deprecated and will be removed in version 4.0.0. Please use 'diffpy.structure.expand_position' instead.
    sites, ops, mult = expandPosition(spacegroup, xyz, sgoffset, eps)

tests/test_pdf.py::testGenerator
tests/test_pdf.py::testGenerator
tests/test_pdf.py::test_savetxt
tests/test_pdf.py::test_pickling
tests/test_pdf.py::test_pickling
tests/test_pdf.py::test_pickling
tests/test_pdf.py::test_pickling
  /opt/miniconda3/envs/diffpy.srfit_env/lib/python3.13/site-packages/diffpy/srreal/structureconverters.py:44: DeprecationWarning: 'diffpy.structure.Lattice.abcABG' is deprecated and will be removed in version 4.0.0. Please use 'diffpy.structure.Lattice.cell_parms' instead.
    haslattice = (1, 1, 1, 90, 90, 90) != stru.lattice.abcABG()

tests/test_pdf.py::testGenerator
tests/test_pdf.py::testGenerator
tests/test_pdf.py::test_pickling
tests/test_pdf.py::test_pickling
tests/test_pdf.py::test_pickling
tests/test_pdf.py::test_pickling
  /opt/miniconda3/envs/diffpy.srfit_env/lib/python3.13/site-packages/diffpy/srreal/structureconverters.py:168: DeprecationWarning: 'diffpy.structure.Lattice.abcABG' is deprecated and will be removed in version 4.0.0. Please use 'diffpy.structure.Lattice.cell_parms' instead.
    adpt.setLatPar(*stru.lattice.abcABG())

tests/test_pdf.py::test_pickling
  /Users/huarundong/dbs/diffpy.srfit/tests/test_pdf.py:290: DeprecationWarning: 'diffpy.structure.loadStructure' is deprecated and will be removed in version 4.0.0. Please use 'diffpy.structure.load_structure' instead.
    ni = loadStructure(cif_path)

tests/test_sgconstraints.py::test_ObjCryst_constrain_space_group
  /Users/huarundong/dbs/diffpy.srfit/src/diffpy/srfit/structure/objcrystparset.py:1818: DeprecationWarning: 'diffpy.structure.GetSpaceGroup' is deprecated and will be removed in version 4.0.0. Please use 'diffpy.structure.get_space_group' instead.
    sg = copy.copy(GetSpaceGroup(name))

tests/test_sgconstraints.py::test_ObjCryst_constrain_space_group
tests/test_sgconstraints.py::test_DiffPy_constrain_as_space_group
tests/test_sgconstraints.py::test_constrain_as_space_group_args
tests/test_sgconstraints.py::test_constrain_as_space_group_args
  /Users/huarundong/dbs/diffpy.srfit/src/diffpy/srfit/structure/sgconstraints.py:501: DeprecationWarning: 'diffpy.symmetryutilities.SymmetryConstraints.posparValues' is deprecated and will be removed in version 4.0.0. Please use 'diffpy.symmetryutilities.SymmetryConstraints.pospar_values' instead.
    fpos = g.positionFormulas(xyznames)

tests/test_sgconstraints.py::test_ObjCryst_constrain_space_group
tests/test_sgconstraints.py::test_DiffPy_constrain_as_space_group
tests/test_sgconstraints.py::test_constrain_as_space_group_args
tests/test_sgconstraints.py::test_constrain_as_space_group_args
  /Users/huarundong/dbs/diffpy.srfit/src/diffpy/srfit/structure/sgconstraints.py:601: DeprecationWarning: 'diffpy.symmetryutilities.GeneratorSite.UFormula' is deprecated and will be removed in version 4.0.0. Please use 'diffpy.symmetryutilities.GeneratorSite.u_formula' instead.
    fadp = g.UFormulas(adpnames)

tests/test_sgconstraints.py::test_DiffPy_constrain_as_space_group
tests/test_sgconstraints.py::test_constrain_as_space_group_args
tests/test_sgconstraints.py::test_constrain_as_space_group_args
  /opt/miniconda3/envs/diffpy.srfit_env/lib/python3.13/site-packages/diffpy/structure/parsers/structureparser.py:101: DeprecationWarning: 'diffpy.structure.P_pdffit.parseLines' is deprecated and will be removed in version 4.0.0. Please use 'diffpy.structure.P_pdffit.parse_lines' instead.
    stru = self.parseLines(lines)

tests/test_sgconstraints.py::test_DiffPy_constrain_as_space_group
tests/test_sgconstraints.py::test_constrain_as_space_group_args
  /Users/huarundong/dbs/diffpy.srfit/src/diffpy/srfit/structure/sgconstraints.py:110: DeprecationWarning: 'diffpy.structure.GetSpaceGroup' is deprecated and will be removed in version 4.0.0. Please use 'diffpy.structure.get_space_group' instead.
    sg = GetSpaceGroup(spacegroup)

tests/test_sgconstraints.py::test_constrain_as_space_group_args
  /Users/huarundong/dbs/diffpy.srfit/tests/test_sgconstraints.py:193: DeprecationWarning: 'diffpy.structure.GetSpaceGroup' is deprecated and will be removed in version 4.0.0. Please use 'diffpy.structure.get_space_group' instead.
    sg = GetSpaceGroup("P b n m")

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
====================================================================================================== 128 passed, 7 skipped, 69 warnings in 1.38s =======================================================================================================

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 19, 2026

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #178      +/-   ##
==========================================
+ Coverage   71.63%   71.91%   +0.28%     
==========================================
  Files          25       25              
  Lines        3437     3472      +35     
==========================================
+ Hits         2462     2497      +35     
  Misses        975      975              
Files with missing lines Coverage Δ
tests/test_pdf.py 56.16% <100.00%> (+8.33%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant