Skip to content

Apply JuliaFormatter to fix code formatting #660

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

ChrisRackauckas
Copy link
Member

Summary

  • Applied JuliaFormatter to ensure consistent code formatting
  • Formatted 76 files to comply with SciML style guide

Changes

 docs/make.jl                                       |   2 +-
 docs/src/api/scipy.md                              |   2 +-
 docs/src/basics/diagnostics_api.md                 |   3 +-
 docs/src/tutorials/large_systems.md                |  45 +++--
 docs/src/tutorials/nonlinear_solve_gpus.md         |  16 +-
 docs/src/tutorials/optimizing_parameterized_ode.md |   6 +-
 docs/src/tutorials/snes_ex2.md                     |   3 +-
 ext/NonlinearSolveFastLevenbergMarquardtExt.jl     |   9 +-
 ext/NonlinearSolveFixedPointAccelerationExt.jl     |   3 +-
 ext/NonlinearSolveMINPACKExt.jl                    |   3 +-
 ext/NonlinearSolveNLSolversExt.jl                  |   3 +-
 ext/NonlinearSolvePETScExt.jl                      |  20 ++-
 ext/NonlinearSolveSIAMFANLEquationsExt.jl          |   6 +-
 ext/NonlinearSolveSpeedMappingExt.jl               |   3 +-
 .../ext/BracketingNonlinearSolveForwardDiffExt.jl  |   4 +-
 .../src/BracketingNonlinearSolve.jl                |  10 +-
 lib/BracketingNonlinearSolve/src/bisection.jl      |   3 +-
 lib/BracketingNonlinearSolve/src/brent.jl          |   3 +-
 lib/BracketingNonlinearSolve/src/falsi.jl          |   3 +-
 lib/BracketingNonlinearSolve/src/ridder.jl         |   3 +-
 .../test/rootfind_tests.jl                         |   8 +-
 .../ext/NonlinearSolveBaseForwardDiffExt.jl        |   3 +-
 lib/NonlinearSolveBase/src/NonlinearSolveBase.jl   |   4 +-
 lib/NonlinearSolveBase/src/autodiff.jl             |  18 +-
 lib/NonlinearSolveBase/src/initialization.jl       |   3 +-
 lib/NonlinearSolveBase/src/polyalg.jl              |   4 +-
 lib/NonlinearSolveBase/src/public.jl               |   1 +
 lib/NonlinearSolveBase/src/solve.jl                |   3 +-
 .../src/termination_conditions.jl                  |   3 +-
 .../src/NonlinearSolveFirstOrder.jl                |   5 +-
 lib/NonlinearSolveFirstOrder/src/forward_diff.jl   |   3 +-
 lib/NonlinearSolveFirstOrder/src/solve.jl          |   6 +-
 .../test/least_squares_tests.jl                    |   6 +-
 .../test/rootfind_tests.jl                         | 190 +++++++++++----------
 .../test/sparsity_tests.jl                         |  23 +--
 .../src/jacobian_handling.jl                       |  12 +-
 .../test/allroots.jl                               |   2 +-
 .../test/single_root.jl                            |   2 +-
 .../ext/NonlinearSolveQuasiNewtonForwardDiffExt.jl |   3 +-
 .../src/NonlinearSolveQuasiNewton.jl               |   1 +
 lib/NonlinearSolveQuasiNewton/src/solve.jl         |  11 +-
 lib/NonlinearSolveQuasiNewton/test/core_tests.jl   |  38 +++--
 lib/NonlinearSolveSciPy/src/NonlinearSolveSciPy.jl | 118 ++++++++-----
 lib/NonlinearSolveSciPy/test/basic_tests.jl        |   2 +-
 lib/NonlinearSolveSciPy/test/runtests.jl           |   4 +-
 lib/NonlinearSolveSciPy/test/wrappers_tests.jl     |  15 +-
 .../NonlinearSolveSpectralMethodsForwardDiffExt.jl |   3 +-
 .../src/NonlinearSolveSpectralMethods.jl           |   1 +
 lib/NonlinearSolveSpectralMethods/src/dfsane.jl    |   3 +-
 lib/NonlinearSolveSpectralMethods/src/solve.jl     |   3 +-
 .../test/core_tests.jl                             |  44 ++---
 lib/SCCNonlinearSolve/src/SCCNonlinearSolve.jl     |   3 +-
 .../src/SciMLJacobianOperators.jl                  |  38 +++--
 lib/SciMLJacobianOperators/test/core_tests.jl      |  24 ++-
 .../ext/SimpleNonlinearSolveChainRulesCoreExt.jl   |   3 +-
 .../ext/SimpleNonlinearSolveReverseDiffExt.jl      |   3 +-
 .../ext/SimpleNonlinearSolveTrackerExt.jl          |   3 +-
 .../src/SimpleNonlinearSolve.jl                    |   1 +
 lib/SimpleNonlinearSolve/src/broyden.jl            |   3 +-
 lib/SimpleNonlinearSolve/src/dfsane.jl             |   3 +-
 lib/SimpleNonlinearSolve/src/halley.jl             |   3 +-
 lib/SimpleNonlinearSolve/src/klement.jl            |   3 +-
 lib/SimpleNonlinearSolve/src/lbroyden.jl           |   6 +-
 lib/SimpleNonlinearSolve/src/raphson.jl            |   3 +-
 lib/SimpleNonlinearSolve/src/trust_region.jl       |   6 +-
 lib/SimpleNonlinearSolve/src/utils.jl              |   9 +-
 .../test/core/forward_diff_tests.jl                |   1 +
 .../test/core/rootfind_tests.jl                    |  21 ++-
 src/NonlinearSolve.jl                              |   3 +-
 src/forward_diff.jl                                |   3 +-
 test/23_test_problems_tests.jl                     | 107 ++++++------
 test/core_tests.jl                                 |   6 +-
 test/cuda_tests.jl                                 |   3 +-
 test/forward_ad_tests.jl                           |   1 -
 test/wrappers/least_squares_tests.jl               |  41 ++---
 test/wrappers/rootfind_tests.jl                    | 100 +++++------
 76 files changed, 635 insertions(+), 454 deletions(-)

This PR was automatically generated by OrgMaintenanceScripts.jl

- Applied JuliaFormatter with SciML style guide
- Formatted 76 files

🤖 Generated by OrgMaintenanceScripts.jl
ChrisRackauckas added a commit to ChrisRackauckas/JuliaFormatter.jl that referenced this pull request Jul 31, 2025
- Add conservative line breaking for mathematical expressions (Binary/Chain nodes)
- Prevent breaking of function calls that are only slightly over margin
- Add comprehensive tests for line break behavior
- Fixes issues seen in SciML/NonlinearSolve.jl#660

The changes make SciMLStyle less aggressive about breaking lines when:
1. Mathematical expressions have few operators and fit within margin + 20 chars
2. Function calls with few arguments fit within margin + 20 chars
3. Short type parameters, array indexing, and other constructs remain intact

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
ChrisRackauckas added a commit to ChrisRackauckas/JuliaFormatter.jl that referenced this pull request Jul 31, 2025
Previously, array indexing on the left-hand side of assignments could be
broken across lines, resulting in undesirable formatting like:

    du[
        i, j, 1] = alpha * expr

This commit adds a custom n_ref! implementation for SciMLStyle that detects
when a RefN (array reference) node is on the LHS of an assignment and prevents
it from being broken across lines. The fix ensures that assignments like:

    du[i, j, 1] = long_expression

Keep the LHS intact while still allowing the RHS to break appropriately.

This addresses the issue seen in SciML/NonlinearSolve.jl#660 where array
assignments were being formatted in an aesthetically unpleasing way.
domluna pushed a commit to domluna/JuliaFormatter.jl that referenced this pull request Jul 31, 2025
…#933)

* Fix unnecessary line breaks in SciMLStyle

- Add conservative line breaking for mathematical expressions (Binary/Chain nodes)
- Prevent breaking of function calls that are only slightly over margin
- Add comprehensive tests for line break behavior
- Fixes issues seen in SciML/NonlinearSolve.jl#660

The changes make SciMLStyle less aggressive about breaking lines when:
1. Mathematical expressions have few operators and fit within margin + 20 chars
2. Function calls with few arguments fit within margin + 20 chars
3. Short type parameters, array indexing, and other constructs remain intact

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>

* Fix array indexing line breaks in SciMLStyle

- Add conservative nesting rule for RefN (array indexing) nodes
- Prevents breaking expressions like du[i, j, 1] when they fit within margin + 30
- Add test to ensure array indexing doesn't break unnecessarily

This addresses the remaining formatting issue where array indices were
being split across lines even for reasonably-sized expressions.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>

* Add comprehensive semantic safety tests for SciMLStyle

- Add tests for whitespace-sensitive array literals (space vs semicolon)
- Test operator precedence preservation
- Test coefficient syntax (2x vs 2 x)
- Test macro scope preservation
- Test string/char/regex/command literals
- Test ternary operator associativity
- Test anonymous functions and comprehensions
- Test broadcasting and type syntax
- Test all Julia language constructs for semantic preservation
- Add 69 new semantic safety tests

These tests ensure the formatter never changes program meaning,
only whitespace and formatting.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>

* Add comprehensive line break quality tests for SciMLStyle

- Add helper function analyze_line_quality to measure line utilization efficiency
- Test single line preservation for simple expressions
- Test efficient breaking of long lines with good space utilization
- Test type parameter wrapping to avoid excessive breaks
- Test array operation formatting preserves structure
- Test function definitions break intelligently based on length
- Test nested expressions maintain logical hierarchy
- Test mathematical expressions break at natural operator boundaries
- Test to avoid orphan parameters on their own lines
- Test keyword argument grouping for readability
- Test preservation of logical grouping (coordinates, pairs)
- Test real-world SciML examples for practical formatting quality

These tests ensure the formatter produces aesthetically pleasing output
that makes efficient use of the 92-character line limit while maintaining
code readability and structure.

* Fix assignment LHS breaking issue

Previously, array indexing on the left-hand side of assignments could be
broken across lines, resulting in undesirable formatting like:

    du[
        i, j, 1] = alpha * expr

This commit adds a custom n_ref! implementation for SciMLStyle that detects
when a RefN (array reference) node is on the LHS of an assignment and prevents
it from being broken across lines. The fix ensures that assignments like:

    du[i, j, 1] = long_expression

Keep the LHS intact while still allowing the RHS to break appropriately.

This addresses the issue seen in SciML/NonlinearSolve.jl#660 where array
assignments were being formatted in an aesthetically unpleasing way.

---------

Co-authored-by: Claude <[email protected]>
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.

1 participant