Skip to content

Conversation

@borisdevos
Copy link
Contributor

@borisdevos borisdevos commented Dec 11, 2025

This PR adds some functions which are useful in multifusion settings. I don't know how often Base.oneunit(::SumSpace) is called within MPSKit, so no clue how much I'll actually be using this. I'm also just not sure how I should think of left/rightunitspace of a SumSpace, so I made one choice here that returns a 1-element space.

I kind of freestyled with coming up with tests, so feel free to criticize.

Edit: clearly I made the opposite choice in the tests, having confused myself at some point. So either the tests or the definition of left/rightunitspace need to change.

@codecov
Copy link

codecov bot commented Dec 11, 2025

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #38      +/-   ##
==========================================
+ Coverage   54.56%   54.72%   +0.15%     
==========================================
  Files          17       17              
  Lines        1446     1451       +5     
==========================================
+ Hits          789      794       +5     
  Misses        657      657              

☔ View full report in Codecov by Sentry.
📢 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.


return SumSpace(rightunitspace(first(S)))
end
TensorKit.isunitspace(S::SumSpace{<:GradedSpace}) = all(isunitspace, S.spaces)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
TensorKit.isunitspace(S::SumSpace{<:GradedSpace}) = all(isunitspace, S.spaces)
TensorKit.isunitspace(S::SumSpace) = all(isunitspace, S.spaces; init=false)

This probably doesn't have to be restricted to GradedSpace, and I guess empty spaces are isomorphic to zero spaces so that should return false

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sadly, init isn't a valid keyword argument for all, so I added a janky !isempty check

@lkdvos
Copy link
Owner

lkdvos commented Dec 15, 2025

I think given the rest of the functions, it probably makes sense to remain consistent and indeed return a length 1 SumSpace, although I'm not sure if that is the best option. Presumably it doesn't matter too much though

@lkdvos
Copy link
Owner

lkdvos commented Dec 23, 2025

Can you also increase the patch version? I'll immediately tag a release

@lkdvos lkdvos merged commit 68c83b8 into lkdvos:main Dec 23, 2025
28 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