Skip to content

Add --smear-function option and Lorentzian smearing#309

Merged
sbillinge merged 3 commits into
diffpy:mainfrom
Sparks29032:general-smear
Jul 9, 2026
Merged

Add --smear-function option and Lorentzian smearing#309
sbillinge merged 3 commits into
diffpy:mainfrom
Sparks29032:general-smear

Conversation

@Sparks29032

@Sparks29032 Sparks29032 commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Addresses part of #211. This adds a Lorentzian smearing option.

We will need another PR that allows the user to pass a general smearing function, but the outline for how to do that is already done in this PR and should be relatively straightforward to implement from here.

The default if --smear-function is not enabled is still Gaussian, no no workflow changes will have to be made for those using the Gaussian smearing.

Below are two morphs. The morphed function is a Lorentzian with HWHM 0.1. The target is a Lorentzian with HWHM 0.25. The first image is when Gaussian smearing (and scaling) is applied. The second is when Lorentzian smearing (and scaling) is applied.

Gaussian smearing:
image

Lorentzian smearing:
image

@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.93%. Comparing base (9981f82) to head (a2d64ae).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #309   +/-   ##
=======================================
  Coverage   99.93%   99.93%           
=======================================
  Files          24       24           
  Lines        1570     1624   +54     
=======================================
+ Hits         1569     1623   +54     
  Misses          1        1           
Files with missing lines Coverage Δ
tests/test_morph_func.py 100.00% <100.00%> (ø)
tests/test_morphapp.py 100.00% <100.00%> (ø)
tests/test_morphio.py 100.00% <100.00%> (ø)
tests/test_morphsmear.py 100.00% <100.00%> (ø)
tests/test_refine.py 100.00% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@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.

one small gripe, but a great PR, thanks!

Comment thread tests/test_morphio.py Outdated
sfn = "smear_morph_result.cgr"
save_file = (tmp_path / sfn).resolve().as_posix()

# Test Gaussian default

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.

per group standard, please specify what the expected behavior is for each case, something like
# Test Gaussian default. Expect Gaussian convolution is correctly applied

Comment thread tests/test_morphio.py Outdated
expected = filter(ignore_path, tf)
are_files_same(actual, expected)

# Test explicit Gaussian specification with capitalization

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.

see above and for all the cases

@Sparks29032

Copy link
Copy Markdown
Collaborator Author

@sbillinge Updated headers. Tests for the i/o are in test_morphio.py and only check if the file headers produced are correct and that the new option is handled correctly. No morphs are applied (apply=True with smear=0 in those tests). The actual test for the Lorentzian morph behavior is in test_morphsmear.py.

@sbillinge sbillinge merged commit d4363bd into diffpy:main Jul 9, 2026
7 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