Skip to content

Fix unnecessary line splits following Catalyst.jl PR #1306 #2797

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

Merged
merged 1 commit into from
Aug 1, 2025

Conversation

ChrisRackauckas
Copy link
Member

Summary

Fix unnecessary line splits in Julia code following the guidelines established in Catalyst.jl PR #1306. This PR improves code readability by consolidating short expressions that were unnecessarily split across multiple lines.

Background

These formatting issues are being addressed upstream in JuliaFormatter.jl PR #934, which implements algorithmic fixes to prevent these unnecessary line splits. However, since that PR is not yet merged, manual fixes are needed in the meantime to improve code readability.

Changes Made

Fixed 3 instances of problematic line splits in controller files:

  • lib/OrdinaryDiffEqFIRK/src/controllers.jl: 1 arithmetic expression
  • lib/OrdinaryDiffEqCore/src/integrators/controllers.jl: 2 arithmetic expressions

Example Fix

Before:

qgus = (integrator.dtacc / integrator.dt) *
       DiffEqBase.fastpow((EEst^2) / integrator.erracc, expo)

After:

qgus = (integrator.dtacc / integrator.dt) * DiffEqBase.fastpow((EEst^2) / integrator.erracc, expo)

Rationale

Following Catalyst.jl PR #1306's approach:

  • Prioritize readability over strict formatter rules for short expressions
  • Keep semantically related code units together
  • All modified lines stay well under 120 characters (typically 95-110 chars)
  • Use JuliaFormatter as a helpful tool rather than a strict rule enforcer

Note

This is part of a systematic effort to apply the same formatting improvements across multiple SciML repositories including JumpProcesses.jl, LinearSolve.jl, NonlinearSolve.jl, and ModelingToolkit.jl.

🤖 Generated with Claude Code

- Fix 3 instances of unnecessarily split arithmetic expressions
- lib/OrdinaryDiffEqFIRK/src/controllers.jl: 1 instance
- lib/OrdinaryDiffEqCore/src/integrators/controllers.jl: 2 instances

Following Catalyst.jl PR #1306 guidelines for improved readability.

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

Co-Authored-By: Claude <noreply@anthropic.com>
@ChrisRackauckas ChrisRackauckas merged commit 230cf7d into master Aug 1, 2025
180 of 189 checks passed
@ChrisRackauckas ChrisRackauckas deleted the fix-formatter-line-splits branch August 1, 2025 11:41
Copy link
Contributor

github-actions bot commented Aug 2, 2025

Benchmark Results (Julia v1)

Time benchmarks
master b2dcce5... master / b2dcce5...
construction/linear_N50 27.4 ± 0.86 μs 27.5 ± 0.78 μs 0.997 ± 0.042
construction/lotka_volterra 18.4 ± 0.23 μs 18.3 ± 0.2 μs 1 ± 0.017
construction/rober 18.4 ± 0.19 μs 18.4 ± 0.23 μs 1 ± 0.016
nonstiff/fitzhugh_nagumo/BS3 0.152 ± 0.0097 ms 0.144 ± 0.01 ms 1.05 ± 0.1
nonstiff/fitzhugh_nagumo/DP5 0.0975 ± 0.0042 ms 0.0968 ± 0.0097 ms 1.01 ± 0.11
nonstiff/fitzhugh_nagumo/Tsit5 0.115 ± 0.0081 ms 0.115 ± 0.005 ms 0.998 ± 0.083
nonstiff/fitzhugh_nagumo/Vern6 0.169 ± 0.0086 ms 0.167 ± 0.0086 ms 1.01 ± 0.074
nonstiff/fitzhugh_nagumo/Vern7 0.116 ± 0.0082 ms 0.113 ± 0.0088 ms 1.03 ± 0.11
nonstiff/lotka_volterra/BS3 0.307 ± 0.011 ms 0.285 ± 0.01 ms 1.08 ± 0.055
nonstiff/lotka_volterra/DP5 0.0503 ± 0.018 ms 0.0462 ± 0.017 ms 1.09 ± 0.56
nonstiff/lotka_volterra/Tsit5 0.0622 ± 0.023 ms 0.0634 ± 0.024 ms 0.982 ± 0.52
nonstiff/lotka_volterra/Vern6 0.0824 ± 0.012 ms 0.0815 ± 0.011 ms 1.01 ± 0.21
nonstiff/lotka_volterra/Vern7 0.0502 ± 0.021 ms 0.0497 ± 0.021 ms 1.01 ± 0.61
nonstiff/pleiades/BS3 0.0874 ± 0.015 s 0.0864 ± 0.015 s 1.01 ± 0.25
nonstiff/pleiades/DP5 1.24 ± 0.095 ms 1.26 ± 0.091 ms 0.984 ± 0.1
nonstiff/pleiades/Tsit5 15.2 ± 5.2 ms 15.7 ± 5.6 ms 0.967 ± 0.48
nonstiff/pleiades/Vern6 7.37 s 7.34 s 1
nonstiff/pleiades/Vern7 7.9 s 7.87 s 1
scaling/brusselator_2d/16x16 0.306 ± 0.029 s 0.303 ± 0.025 s 1.01 ± 0.13
scaling/brusselator_2d/32x32 7.1 s 7.09 s 1
scaling/brusselator_2d/8x8 11.2 ± 0.19 ms 11.2 ± 0.22 ms 1 ± 0.026
scaling/linear/N10 0.0374 ± 0.017 ms 0.0374 ± 0.017 ms 0.999 ± 0.65
scaling/linear/N100 0.802 ± 0.015 ms 0.792 ± 0.015 ms 1.01 ± 0.028
scaling/linear/N50 0.214 ± 0.011 ms 0.214 ± 0.011 ms 0.997 ± 0.071
stiff/pollution/FBDF 0.586 ± 0.012 ms 0.588 ± 0.013 ms 0.997 ± 0.03
stiff/pollution/KenCarp4 0.55 ± 0.0099 ms 0.55 ± 0.012 ms 0.999 ± 0.028
stiff/pollution/Rodas4 0.76 ± 0.015 ms 0.766 ± 0.017 ms 0.993 ± 0.029
stiff/pollution/Rosenbrock23 1.35 ± 0.031 ms 1.35 ± 0.029 ms 1 ± 0.032
stiff/pollution/TRBDF2 0.509 ± 0.011 ms 0.51 ± 0.012 ms 0.999 ± 0.032
stiff/rober/FBDF 0.602 ± 0.01 ms 0.607 ± 0.01 ms 0.992 ± 0.024
stiff/rober/KenCarp4 0.758 ± 0.02 ms 0.767 ± 0.019 ms 0.988 ± 0.035
stiff/rober/Rodas4 0.398 ± 0.0096 ms 0.397 ± 0.0099 ms 1 ± 0.035
stiff/rober/Rosenbrock23 0.274 ± 0.0094 ms 0.276 ± 0.0093 ms 0.993 ± 0.048
stiff/rober/TRBDF2 1.73 ± 0.015 ms 1.74 ± 0.015 ms 0.998 ± 0.012
stiff/van_der_pol/FBDF 9.94 ± 0.083 ms 9.88 ± 0.091 ms 1.01 ± 0.013
stiff/van_der_pol/KenCarp4 4.75 ± 0.067 ms 4.75 ± 0.064 ms 1 ± 0.019
stiff/van_der_pol/Rodas4 7.18 ± 0.056 ms 7.2 ± 0.052 ms 0.996 ± 0.011
stiff/van_der_pol/Rosenbrock23 21 ± 0.21 ms 21.2 ± 0.16 ms 0.987 ± 0.012
stiff/van_der_pol/TRBDF2 3.07 ± 0.086 ms 2.96 ± 0.085 ms 1.04 ± 0.042
time_to_load 3.2 ± 0.0076 s 3.19 ± 0.0065 s 1 ± 0.0032
Memory benchmarks
master b2dcce5... master / b2dcce5...
construction/linear_N50 0.071 k allocs: 0.0411 MB 0.071 k allocs: 0.0411 MB 1
construction/lotka_volterra 0.065 k allocs: 2.45 kB 0.065 k allocs: 2.45 kB 1
construction/rober 0.065 k allocs: 2.42 kB 0.065 k allocs: 2.42 kB 1
nonstiff/fitzhugh_nagumo/BS3 3.69 k allocs: 0.164 MB 3.69 k allocs: 0.164 MB 1
nonstiff/fitzhugh_nagumo/DP5 2.63 k allocs: 0.127 MB 2.63 k allocs: 0.127 MB 1
nonstiff/fitzhugh_nagumo/Tsit5 4 k allocs: 0.182 MB 4 k allocs: 0.182 MB 1
nonstiff/fitzhugh_nagumo/Vern6 4.54 k allocs: 0.207 MB 4.54 k allocs: 0.207 MB 1
nonstiff/fitzhugh_nagumo/Vern7 3.91 k allocs: 0.165 MB 3.91 k allocs: 0.165 MB 1
nonstiff/lotka_volterra/BS3 7.88 k allocs: 0.365 MB 7.88 k allocs: 0.365 MB 1
nonstiff/lotka_volterra/DP5 1.21 k allocs: 0.0543 MB 1.21 k allocs: 0.0543 MB 1
nonstiff/lotka_volterra/Tsit5 2.17 k allocs: 0.093 MB 2.17 k allocs: 0.093 MB 1
nonstiff/lotka_volterra/Vern6 2.24 k allocs: 0.0986 MB 2.24 k allocs: 0.0986 MB 1
nonstiff/lotka_volterra/Vern7 1.65 k allocs: 0.0736 MB 1.65 k allocs: 0.0736 MB 1
nonstiff/pleiades/BS3 0.685 M allocs: 0.0675 GB 0.685 M allocs: 0.0675 GB 1
nonstiff/pleiades/DP5 6.63 k allocs: 0.51 MB 6.63 k allocs: 0.51 MB 1
nonstiff/pleiades/Tsit5 0.186 M allocs: 20.4 MB 0.186 M allocs: 20.4 MB 1
nonstiff/pleiades/Vern6 0.038 G allocs: 4.05 GB 0.038 G allocs: 4.05 GB 1
nonstiff/pleiades/Vern7 0.044 G allocs: 4.63 GB 0.044 G allocs: 4.63 GB 1
scaling/brusselator_2d/16x16 3.58 k allocs: 0.152 GB 3.58 k allocs: 0.152 GB 1
scaling/brusselator_2d/32x32 3.4 k allocs: 2.22 GB 3.4 k allocs: 2.22 GB 1
scaling/brusselator_2d/8x8 2.62 k allocs: 8.76 MB 2.62 k allocs: 8.76 MB 1
scaling/linear/N10 0.752 k allocs: 0.0514 MB 0.752 k allocs: 0.0514 MB 1
scaling/linear/N100 2.27 k allocs: 0.901 MB 2.27 k allocs: 0.901 MB 1
scaling/linear/N50 1.66 k allocs: 0.348 MB 1.66 k allocs: 0.348 MB 1
stiff/pollution/FBDF 1.5 k allocs: 0.288 MB 1.5 k allocs: 0.288 MB 1
stiff/pollution/KenCarp4 0.516 k allocs: 0.134 MB 0.516 k allocs: 0.134 MB 1
stiff/pollution/Rodas4 1.28 k allocs: 0.363 MB 1.28 k allocs: 0.363 MB 1
stiff/pollution/Rosenbrock23 2.77 k allocs: 0.819 MB 2.77 k allocs: 0.819 MB 1
stiff/pollution/TRBDF2 0.783 k allocs: 0.168 MB 0.783 k allocs: 0.168 MB 1
stiff/rober/FBDF 2.89 k allocs: 0.137 MB 2.89 k allocs: 0.137 MB 1
stiff/rober/KenCarp4 1.3 k allocs: 0.0575 MB 1.3 k allocs: 0.0575 MB 1
stiff/rober/Rodas4 2.19 k allocs: 0.106 MB 2.19 k allocs: 0.106 MB 1
stiff/rober/Rosenbrock23 2.51 k allocs: 0.117 MB 2.51 k allocs: 0.117 MB 1
stiff/rober/TRBDF2 7.72 k allocs: 0.36 MB 7.72 k allocs: 0.36 MB 1
stiff/van_der_pol/FBDF 0.0444 M allocs: 2.2 MB 0.0444 M allocs: 2.2 MB 1
stiff/van_der_pol/KenCarp4 4.27 k allocs: 0.184 MB 4.27 k allocs: 0.184 MB 1
stiff/van_der_pol/Rodas4 0.0377 M allocs: 1.86 MB 0.0377 M allocs: 1.86 MB 1
stiff/van_der_pol/Rosenbrock23 0.213 M allocs: 9.09 MB 0.213 M allocs: 9.09 MB 1
stiff/van_der_pol/TRBDF2 5.02 k allocs: 0.212 MB 5.02 k allocs: 0.212 MB 1
time_to_load 0.159 k allocs: 11.2 kB 0.159 k allocs: 11.2 kB 1

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