Visitar URL original
Honor omitted weights and masks in single-mode CP reconstruction by ktz03 · Pull Request #703 · tensorly/tensorly · GitHub
Skip to content

Honor omitted weights and masks in single-mode CP reconstruction - #703

Open
ktz03 wants to merge 1 commit into
tensorly:mainfrom
ktz03:fix/single-mode-reconstruction-702
Open

ktz03 wants to merge 1 commit into
tensorly:mainfrom
ktz03:fix/single-mode-reconstruction-702

Conversation

@ktz03

@ktz03 ktz03 commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Fixes #702.

The one-mode matrix-factor branch of cp_to_tensor returns before the existing implicit-weight fallback and mask application. Omitted weights therefore raise TypeError, and explicit weights with a mask silently produce the unmasked vector.

Move the unit-weight fallback before this branch and apply the supplied mask to its result. Four compact regression/control cases use literal expected vectors and exercise both tuple and CPTensor inputs. They cover a single factor matrix with two component columns; the rank-one vector-factor path from #653 remains separate.

Validation on Windows, CPython 3.12.14, NumPy 2.3.5 and SciPy 1.16.3:

  • Full NumPy suite, including available sparse tests: 981 passed, 12 skipped, 1 xpassed, 35 warnings. The unmodified base has 977 passed with the same skip/XPASS/warning counts. The four new cases are included in these totals.
  • Unmodified NumPy and PyTorch focused regressions: 3 failed, 1 passed in each; the fix passes all four.
  • CP tensor module: 72 passed with NumPy/einsum, PyTorch/core and PyTorch/einsum. These overlapping runs are not additional full-suite cases.
  • Black 26.10.0 checks all 156 source/test files successfully.

PyTorch 2.8.0 was tested on CPU. Existing environments and dependencies were reused without changes. The other backend, Python-version and operating-system matrices, documentation and package builds were not run locally.

@codecov

codecov Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #703      +/-   ##
==========================================
+ Coverage   92.81%   92.82%   +0.01%     
==========================================
  Files         133      133              
  Lines        8863     8876      +13     
==========================================
+ Hits         8226     8239      +13     
  Misses        637      637              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
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.

Single-mode CP reconstruction fails with omitted weights and ignores masks

1 participant