Skip to content

feat: fill tail with zeros during normalization#202

Open
john-halloran wants to merge 2 commits into
diffpy:mainfrom
john-halloran:norm-fixes
Open

feat: fill tail with zeros during normalization#202
john-halloran wants to merge 2 commits into
diffpy:mainfrom
john-halloran:norm-fixes

Conversation

@john-halloran

Copy link
Copy Markdown
Contributor

This is a feat technically, but will act as more of a fix. The original MATLAB stretched-nmf included a toggle called fillzero that I did not understand or think was important, and therefore didn't implement. Detailed investigation of why we still had worse performance showed this was one of the big reasons.

The fillzero feature is enabled during normalization and means that when components is being stretched, the optimizer treats the area beyond the end of the signal as equaling zero, instead of repeating the final value. When it repeated values, this artificially inflated component intensity at the left and right edges. This, in turn, had cascading effects across the weights and stretch that made them wrong, too. The effect was most extreme during normalization because of the dramatic change in signal magnitude that occurs.

Note that although it looks like one, this isn't intended to be something the user will need to change. It's implemented this way because it matches the MATLAB and fixed normalization issues. In a future PR, I will likely refactor this to be natively part of the algorithm. That will happen as part of a broader cleanup of the normalization process, which currently is entangled in a way that I don't like.

@codecov

codecov Bot commented Jun 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.60%. Comparing base (d7586bc) to head (c0231ef).
⚠️ Report is 10 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #202      +/-   ##
==========================================
- Coverage   77.50%   75.60%   -1.90%     
==========================================
  Files           3        3              
  Lines          40       41       +1     
==========================================
  Hits           31       31              
- Misses          9       10       +1     
🚀 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