Skip to content

ITensorFormatter#100

Merged
mtfishman merged 6 commits intomainfrom
mf/itfmt
Feb 12, 2026
Merged

ITensorFormatter#100
mtfishman merged 6 commits intomainfrom
mf/itfmt

Conversation

@mtfishman
Copy link
Member

No description provided.

@codecov
Copy link

codecov bot commented Feb 12, 2026

Codecov Report

❌ Patch coverage is 81.25000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.28%. Comparing base (326c9c7) to head (2dfad23).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/indexing.jl 66.66% 2 Missing ⚠️
src/abstractsparsearray.jl 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #100      +/-   ##
==========================================
+ Coverage   79.26%   79.28%   +0.02%     
==========================================
  Files          12       12              
  Lines         786      787       +1     
==========================================
+ Hits          623      624       +1     
  Misses        163      163              
Flag Coverage Δ
docs 30.45% <8.33%> (ø)

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

☔ 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.

@mtfishman mtfishman closed this Feb 12, 2026
@mtfishman mtfishman reopened this Feb 12, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 12, 2026

Your PR no longer requires formatting changes. Thank you for your contribution!

@mtfishman mtfishman marked this pull request as ready for review February 12, 2026 21:49
@mtfishman mtfishman marked this pull request as draft February 12, 2026 22:30
@mtfishman mtfishman marked this pull request as ready for review February 12, 2026 22:33
@mtfishman mtfishman marked this pull request as draft February 12, 2026 22:39
@mtfishman mtfishman marked this pull request as ready for review February 12, 2026 22:48
@mtfishman mtfishman marked this pull request as draft February 12, 2026 22:49
@mtfishman mtfishman marked this pull request as ready for review February 12, 2026 22:50
@mtfishman mtfishman merged commit d97bb1f into main Feb 12, 2026
42 of 50 checks passed
@mtfishman mtfishman deleted the mf/itfmt branch February 12, 2026 23:07
@inline $_f!(::IndexLinear, A::AbstractVector, v, i::Int) = $f!(A, v, i)
@inline $_f!(::IndexLinear, A::AbstractArray, v, i::Int) = $f!(A, v, i)
@inline function $_f!(::IndexLinear, A::AbstractArray, v, I::Vararg{Int, M}) where {M}
@inline function $_f!(
Copy link
Contributor

Choose a reason for hiding this comment

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

Just out of curiosity, this looks quite bad to me, and is basically reverting back to JuliaFormatter. Is this what we want?

Copy link
Member Author

@mtfishman mtfishman Feb 13, 2026

Choose a reason for hiding this comment

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

I agree this one isn't good, and not what I would want in the ideal case. It's an unfortunate side affect of the slightly hacky way we are doing things in https://github.com/ITensor/ITensorFormatter.jl right now, where indeed it is caused by JuliaFormatter.

Basically the goal of ITensorFormatter.jl is to format in a way that is consistent with Runic.jl (i.e. the final output should be a fixed point of Runic formatting) but be more opinionated about formatting/organizing imports and dealing with line wraps in a more automated way. So the ideal would be the following:

  1. In general format like Runic.
  2. Sort lists of explicit imports, and have lists of explicit imports organized into a minimal set of lines that wrap around at the standard 92 character limit (in contrast with JuliaFormatter which splits them each into separate lines for long lists of imports, and Runic which doesn't enforce any wrapping, and also neither one sorts them).
  3. In general bias towards longer lines of code but enforce the 92 character limit.

The reason is that both for my own code and when reviewing code, 2. and 3. have been annoying to try to enforce without an automated solution in the formatter, and I think Runic is too unopinionated about those issues.

Basically neither Runic nor JuliaFormatter gives us a good solution to 2. and 3., so for 2. (import sorting) we rolled our own solution in ITensorFormatter.jl based on code for that defined in LanguageServer.jl. The strategy for 3. is to use a pass of JuliaFormatter with join_lines_based_on_source set to true to try to preserve longer lines where they exist in the code already but add line breaks if they go beyond 92 characters, this case seemed to be too aggressive with splitting into more lines and I'm not sure why.

Modulo weird cases like this, I think the formatting that ITensorFormatter is good enough as a first draft so the goal right now for me is to upgrade from Runic to ITensorFormatter in ITensorActions and ITensorPkgSkeleton, and then later on once that is set up we can try to tweak the rules or role our own solutions to fix weird cases like this. It is definitely unfortunate that ITensorFormatter uses both Runic and JuliaFormatter, again the goal was to role something that is good enough for now. Eventually the goal would be to just use Runic as the primary formatter with some more opinionated fixes on top of it for automated but not overzealous linebreaks, say written with custom code based on JuliaSyntax.

Copy link
Member Author

Choose a reason for hiding this comment

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

See: #101 where I've fixed up some of these uglier formatting changes. I think basically what happened was that when certain types of code runs over the margins, even though join_lines_based_on_source = true, JuliaFormatter biases towards splitting up each argument into separate lines. At least when that happens, we can manually pack arguments onto longer lines and as long as none of them run past the margins it doesn't revert the manual changes, so it seems like the current setup works well in terms of a balance of automation and allowing some manual fixing.

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

Comments