Skip to content

feat: add PeakProfiles to profiles.py - #6

Merged
sbillinge merged 6 commits into
diffpy:mainfrom
cadenmyers13:peak-profiles
Oct 28, 2026
Merged

sbillinge merged 6 commits into
diffpy:mainfrom
cadenmyers13:peak-profiles

Conversation

@cadenmyers13

Copy link
Copy Markdown
Contributor

Please merge #5 first.

Adding the first two peak profile components, built on the Component helpers:

  • PseudoVoigtProfile (the default): U, V, W, eta0, eta1, asym0, asym1, asym2, wrapping pyobjcryst's ReflectionProfilePseudoVoigt.
  • TCHProfile: U, V, W, X, Y, Z, P, LGmix, wrapping ReflectionProfilePseudoVoigtTCH. It is symmetric, which is why pseudo-Voigt stays the default for lab data.

Each profile is three short methods. __init__ creates its Parameters from a fresh pyobjcryst profile, with ObjCryst's defaults and limits. install puts a fresh pyobjcryst profile on a pattern's diffraction component, and update pushes the Parameter values into it. pyobjcryst's SetProfile installs a copy, so update always writes into diffraction.GetProfile(). The profiles keep no reference to the pyobjcryst objects, so one profile can serve several patterns. The generator will use that when phases share a profile.

The tests use plain pyobjcryst patterns for PbSO4 (tests/testdata/PbSO4-Wyckoff.cif, from GSAS-II's test inputs), so the profiles are tested before the generator is rebuilt on them. They check that:

  • update gives the same pattern as setting the value directly in pyobjcryst.
  • Every Parameter lands on its own ObjCryst parameter, which catches a typo or swap in the hand-written name mappings.
  • Installing twice is safe.
  • One profile updates two patterns.

BackToBackExponentialProfile (time of flight) stays a stub, because pyobjcryst doesn't bind ObjCryst's TOF profile yet.

Also in this PR: a small cleanup of the Component tests from the previous PR. Two one-line fixtures are inlined, and refinable_par_name is renamed to pyobjcryst_par_name for readability. Test behaviour is unchanged.

CI will fail, as on the previous PR: the tests need pyobjcryst main, and the conda-forge release doesn't have these profile classes. Local results, with pyobjcryst built from main:

tests/test_component.py ..............                       [100%]
tests/test_profiles.py ............                          [100%]
26 passed

What should the reviewer(s) do?

Please review the two profiles and their tests.

@cadenmyers13

Copy link
Copy Markdown
Contributor Author

@sbillinge ready for review. Please merge #5 first.

@sbillinge
sbillinge merged commit 782c70a into diffpy:main Oct 28, 2026
3 of 4 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