Skip to content

Export symmetrize_operator for custom operator symmetrization - #59

Merged
lkdvos merged 8 commits into
mainfrom
custom
Aug 18, 2026
Merged

lkdvos merged 8 commits into
mainfrom
custom

Conversation

@Yue-Zhengyuan

@Yue-Zhengyuan Yue-Zhengyuan commented Aug 14, 2026 •

Copy link
Copy Markdown
Member

This PR exports module-specific symmetrize_operator functions to symmetrize custom operators.

@codecov

codecov Bot commented Aug 14, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/bosonoperators.jl 95.65% <100.00%> (+0.09%) ⬆️
src/fermionoperators.jl 95.12% <100.00%> (+0.12%) ⬆️
src/hubbardoperators.jl 98.88% <100.00%> (-0.01%) ⬇️
src/quantumgates.jl 100.00% <100.00%> (ø)
src/spinoperators.jl 91.75% <100.00%> (+0.17%) ⬆️
src/tjoperators.jl 97.95% <100.00%> (-0.03%) ⬇️
src/utils.jl 93.18% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Yue-Zhengyuan
Yue-Zhengyuan requested a review from lkdvos August 14, 2026 11:31

@lkdvos lkdvos left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Trying to unpack this here, mostly to see if I'm correctly understanding the goals etc.

Am I correct in saying that this is effectively doing two things:

  1. exposing Module._symmetrize_operator
  2. accepting AbstractArray directly

For the first part, sounds good, although I might advocate to keep the name to be symmetrize_operator instead of custom, specifically for an exported function, and just making that exported.

I'm slightly less certain about the second part, as I guess that is more of a convenience layer on top and I tend to like steering people slightly into TensorKit, since realistically they will have to at some point anyways. If you really think this is necessary, I'd just use dispatch and define a small helper function that does TensorMap(A, *(ComplexSpace.(size.(Ref(A), 1:div(ndims(A), 2))...), *(ComplexSpace.(size.(Ref(A), div(ndims(A), 2)+1:ndims(A))...)), so both versions are supported?

This is also more or less why I don't really see much benefit in asserting equal sizes of the input array, as we probably error right after that in the symmetrization code anyways?

Otherwise definitely looks good, thanks for the addition!

Comment thread src/utils.jl Outdated
@Yue-Zhengyuan

Copy link
Copy Markdown
Member Author

Now I directly export symmetrize_operator, accepting an AbstractTensorMap as input. For fermionic systems the input should already have FermionParity grading (instead of being completely desymmetrized).

Comment thread test/symmetrize_operator.jl Outdated
@Yue-Zhengyuan Yue-Zhengyuan changed the title Feature: Create custom operators from plain Arrays Export symmetrize_operator for construction of custom operators Aug 15, 2026
@Yue-Zhengyuan
Yue-Zhengyuan requested a review from lkdvos August 15, 2026 10:04
lkdvos
lkdvos previously approved these changes Aug 15, 2026

@lkdvos lkdvos left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Except for removing the extra tests, looks great to me!
You might want to also immediately bump the version for a patch release?

@Yue-Zhengyuan Yue-Zhengyuan changed the title Export symmetrize_operator for construction of custom operators Export symmetrize_operator for custom operator symmetrization Aug 15, 2026
@Yue-Zhengyuan

Copy link
Copy Markdown
Member Author

I still want to take a closer look at the t-J case with slave_fermion = true and see if _maybe_slave_fermion can be optimized away.

@Yue-Zhengyuan

Copy link
Copy Markdown
Member Author

Let's not release 0.3.1 immediately. I also want to export the function to add charges in a separate PR.

@Yue-Zhengyuan
Yue-Zhengyuan requested a review from lkdvos August 16, 2026 05:44
lkdvos
lkdvos previously approved these changes Aug 16, 2026

@lkdvos lkdvos left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Apologies for the second round of review comments, feel free to ignore if you disagree, had some time to kill before a flight ;)

Comment thread docs/src/index.md Outdated
Comment thread src/bosonoperators.jl
Comment thread src/fermionoperators.jl
Comment thread src/tjoperators.jl
@Yue-Zhengyuan

Copy link
Copy Markdown
Member Author

@lkdvos I skipped CI in the last commit since it affects documentation only. Can you help directly merge, or force start the tests?

@lkdvos
lkdvos merged commit 3755705 into main Aug 18, 2026
@lkdvos
lkdvos deleted the custom branch August 18, 2026 07:51
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