Skip to content

Fermion twist#703

Open
manuschneider wants to merge 18 commits intomasterfrom
fermion_twist
Open

Fermion twist#703
manuschneider wants to merge 18 commits intomasterfrom
fermion_twist

Conversation

@manuschneider
Copy link
Collaborator

-Added fermion twists, which corresponds to the P-gates in arXiv:2404.14611
-Cleaned up code and updated documentation
-Made all methods return a pointer to the class to allow for chaining (e.g. UniTensor.contiguous().fermion_twists(). ...)

@codecov
Copy link

codecov bot commented Nov 3, 2025

Codecov Report

❌ Patch coverage is 28.78788% with 47 lines in your changes missing coverage. Please review.
✅ Project coverage is 35.85%. Comparing base (e87c3a2) to head (ba15358).
⚠️ Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
include/UniTensor.hpp 25.00% 24 Missing and 3 partials ⚠️
src/UniTensor_base.cpp 0.00% 12 Missing ⚠️
src/BlockFermionicUniTensor.cpp 55.55% 6 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #703      +/-   ##
==========================================
+ Coverage   32.35%   35.85%   +3.50%     
==========================================
  Files         215      215              
  Lines       36363    33158    -3205     
  Branches    14597    13213    -1384     
==========================================
+ Hits        11764    11889     +125     
+ Misses      22659    19342    -3317     
+ Partials     1940     1927      -13     

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@hunghaoti
Copy link
Collaborator

Is it possible to add some simple unit test?

@manuschneider
Copy link
Collaborator Author

Is it possible to add some simple unit test?

done

@manuschneider manuschneider added the Pending check/approval Issue fixed, and need feedback label Feb 12, 2026
@ianmccul
Copy link
Contributor

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ba15358496

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

idxorder[i] = idxnum - i;
}
this->permute_nosignflip_(idxorder);
this->_rowrank = this->_bonds.size() - this->_rowrank;

Choose a reason for hiding this comment

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

P2 Badge Refresh braket-form cache after rowrank flip

Transpose_() recomputes _is_braket_form inside permute_nosignflip_() using the old rowrank, then line 1928 changes _rowrank again without updating the cache. For fermionic tensors where rowrank changes under transpose (for example rank 4 with rowrank 1), is_braket_form() can return a stale value after transpose, so downstream logic that relies on this flag may branch incorrectly.

Useful? React with 👍 / 👎.

std::vector<std::string>::iterator it;
it = std::find(this->_labels.begin(), this->_labels.end(), label);
cytnx_error_msg(it == this->_labels.end(),
"[ERROR] label %d does not exist in current UniTensor.\n", label.c_str());

Choose a reason for hiding this comment

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

P3 Badge Fix invalid format specifier in twist label error

The error path in twist_(const std::string label) passes label.c_str() to a "%d" format placeholder. This is a type mismatch in varargs formatting and can print garbage or trigger undefined behavior when a missing label is provided, making diagnostics unreliable in exactly the case this check is intended to handle.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Pending check/approval Issue fixed, and need feedback

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants