Skip to content

code cleanup#790

Draft
manuschneider wants to merge 6 commits into
masterfrom
iostream
Draft

code cleanup#790
manuschneider wants to merge 6 commits into
masterfrom
iostream

Conversation

@manuschneider
Copy link
Copy Markdown
Collaborator

ensures that operator<< writes to the correct ostream
fixes python bindings
removes comments of the form // cout << ...
fixes and orders includes

ensures that operator<< writes to the correct ostream
fixes python bindings
removes comments of the form // cout << ...
fixes and orders includes
@manuschneider manuschneider added codex Pending check/approval Issue fixed, and need feedback labels May 1, 2026
Copy link
Copy Markdown

@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: cba2cb15cb

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/Gncon.cpp Outdated
Comment thread include/Network.hpp Outdated
Comment thread include/Gncon.hpp Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented May 1, 2026

Codecov Report

❌ Patch coverage is 14.70588% with 145 lines in your changes missing coverage. Please review.
✅ Project coverage is 29.21%. Comparing base (ae0cf67) to head (4f626e9).
⚠️ Report is 2 commits behind head on master.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/Symmetry.cpp 0.00% 31 Missing ⚠️
src/BlockFermionicUniTensor.cpp 0.00% 21 Missing ⚠️
src/DenseUniTensor.cpp 40.00% 2 Missing and 13 partials ⚠️
src/BlockUniTensor.cpp 40.00% 5 Missing and 7 partials ⚠️
src/stat/histogram.cpp 0.00% 11 Missing ⚠️
src/backend/Storage_base.cpp 0.00% 8 Missing ⚠️
src/LinOp.cpp 0.00% 7 Missing ⚠️
pybind/unitensor_py.cpp 0.00% 1 Missing and 5 partials ⚠️
include/backend/Scalar.hpp 0.00% 5 Missing ⚠️
src/backend/StorageImplementation.cpp 0.00% 4 Missing ⚠️
... and 14 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #790      +/-   ##
==========================================
- Coverage   29.22%   29.21%   -0.01%     
==========================================
  Files         241      242       +1     
  Lines       35561    35566       +5     
  Branches    14824    14829       +5     
==========================================
- Hits        10394    10392       -2     
- Misses      17941    17947       +6     
- Partials     7226     7227       +1     
Flag Coverage Δ
cpp 28.81% <14.70%> (-0.01%) ⬇️
python 52.71% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
C++ backend 30.42% <14.55%> (-0.01%) ⬇️
Python bindings 17.04% <20.00%> (-0.05%) ⬇️
Python package 52.71% <ø> (ø)
Files with missing lines Coverage Δ
include/Accessor.hpp 63.15% <ø> (ø)
include/Bond.hpp 62.58% <ø> (ø)
src/Accessor.cpp 34.05% <ø> (ø)
src/Bond.cpp 43.18% <ø> (ø)
src/Generator.cpp 58.49% <ø> (ø)
src/Network.cpp 0.00% <ø> (ø)
src/Physics.cpp 12.50% <ø> (ø)
src/Tensor.cpp 15.85% <ø> (ø)
src/backend/Scalar.cpp 95.72% <ø> (ø)
src/backend/algo_internal_cpu/Concate_internal.cpp 100.00% <ø> (ø)
... and 56 more

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 113e5e5...4f626e9. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment on lines 2851 to +2861
*/
void print() const {
this->_impl->print(std::cout);
std::cout << std::string(" Scalar dtype: [") << Type.getname(this->_impl->_dtype)
<< std::string("]") << std::endl;
void print() const { this->print(std::cout); }
/// @cond
void print(std::ostream &os) const {
this->_impl->print(os);
os << std::string(" Scalar dtype: [") << Type.getname(this->_impl->_dtype) << std::string("]")
<< std::endl;
}
/// @endcond
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What is the reason to add new methods which consume ostream?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

std::ostream &operator<<(std::ostream &os ...) functions call the print functions. Previously, those wrote to std::cout, no matter what the ostream in operator<< was. I fixed this. To make all IO options uniform (print(), print_...() etc), I added a version that accepts an ostream always.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I feel a better pattern is creating a new method that compose the output string, and let Scaler::std::ostream &operator<<(std::ostream &os ...) call that method if std::ostream &operator<<(std::ostream &os ...) exist. With the pattern, print() is useless and can be removed.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

We could directly implement it in operator<< (and print() in impl). I outlined it in #868.

@IvanaGyro
Copy link
Copy Markdown
Collaborator

IvanaGyro commented May 3, 2026

You did at least four things in one commit.

ensures that operator<< writes to the correct ostream
fixes python bindings
removes comments of the form // cout << ...
fixes and orders includes

To make a PR review by reviewers easier and more quickly, developers are asked to split their great works into multiple commit by logical feature. You can find many sources talking about this principle and try to review PRs.

5.2 Distributed Git - Contributing to a Project

Next, try to make each commit a logically separate changeset. If you can, try to make your changes digestible – don’t code for a whole weekend on five different issues and then submit them all as one massive commit on Monday. Even if you don’t commit during the weekend, use the staging area on Monday to split your work into at least one commit per issue, with a useful message per commit.

Linux kernel submitting guidelines

Separate each logical change into a separate patch.

For example, if your changes include both bug fixes and performance enhancements for a single driver, separate those changes into two or more patches. If your changes include an API update, and a new driver which uses that new API, separate those into two patches.

On the other hand, if you make a single change to numerous files, group those changes into a single patch. Thus a single logical change is contained within a single patch.

Git Contribution Guidelines

Give an explanation for the change(s) that is detailed enough so that people can judge if it is good thing to do, without reading the actual patch text to determine how well the code does what the explanation promises to do.

If your description starts to get too long, that’s a sign that you probably need to split up your commit to finer grained pieces. That being said, patches which plainly describe the things that help reviewers check the patch, and future maintainers understand the code, are the most beautiful patches. Descriptions that summarize the point in the subject well, and describe the motivation for the change, the approach taken by the change, and if relevant how this differs substantially from the prior version, are all good things to have.

Copy link
Copy Markdown

@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: d4d2e135bb

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/Accessor.cpp
Comment thread include/backend/Storage.hpp Outdated
Copy link
Copy Markdown

@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: 08d7678a1a

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread include/backend/Storage.hpp Outdated
Copy link
Copy Markdown

@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: 1c7407b253

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread include/backend/Storage.hpp Outdated
@manuschneider manuschneider marked this pull request as draft May 6, 2026 02:11
@manuschneider manuschneider removed the Pending check/approval Issue fixed, and need feedback label May 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants