Skip to content

Enable JuliaFormatter#603

Merged
nalimilan merged 3 commits intomasterfrom
nl/format
Apr 18, 2025
Merged

Enable JuliaFormatter#603
nalimilan merged 3 commits intomasterfrom
nl/format

Conversation

@nalimilan
Copy link
Copy Markdown
Member

@nalimilan nalimilan commented Apr 14, 2025

Add a JuliaFormatter style, apply it to the code base, and enable a GitHub workflow to add suggestions to PRs to follow the style. Inspired by discussions at JuliaStats/HypothesisTests.jl#299.

EDIT: the second commit shows what the default style looks like. It's a bit different from the majority of the current code regarding alignment of arguments.

github-actions[bot]

This comment was marked as outdated.

@nalimilan nalimilan mentioned this pull request Apr 14, 2025
3 tasks
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 14, 2025

Codecov Report

Attention: Patch coverage is 95.26627% with 8 lines in your changes missing coverage. Please review.

Project coverage is 94.82%. Comparing base (3d474b2) to head (77da751).
Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
src/glmfit.jl 94.44% 3 Missing ⚠️
src/linpred.jl 93.02% 3 Missing ⚠️
src/glmtools.jl 91.66% 1 Missing ⚠️
src/negbinfit.jl 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #603      +/-   ##
==========================================
- Coverage   94.89%   94.82%   -0.07%     
==========================================
  Files           8        8              
  Lines        1038     1044       +6     
==========================================
+ Hits          985      990       +5     
- Misses         53       54       +1     

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

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

JuliaFormatter

[JuliaFormatter] reported by reviewdog 🐶

ssqr = deviance(x.rr)/dofr


[JuliaFormatter] reported by reviewdog 🐶

levstr = isinteger(level*100) ? string(Integer(level*100)) : string(level*100)


[JuliaFormatter] reported by reviewdog 🐶

hcat(cc, se, tt, p, cc+ci, cc-ci),


[JuliaFormatter] reported by reviewdog 🐶

ret .= quantile(TDist(dofr), (1 - level)/2) .* sqrt.(ret)


[JuliaFormatter] reported by reviewdog 🐶

upper .= prediction - + ret


[JuliaFormatter] reported by reviewdog 🐶

stderror(obj) * quantile(TDist(dof_residual(obj)), (1.0 - level)/2.0) * [1.0 -1.0]


[JuliaFormatter] reported by reviewdog 🐶

k = dof(obj)-1


[JuliaFormatter] reported by reviewdog 🐶

tmp(yi, μi) = (yi+θ)/(μi+θ) + log(μi+θ) - 1 - log(θ) - digamma+yi) + digamma(θ)


[JuliaFormatter] reported by reviewdog 🐶

tmp(yi, μi) = -(yi+θ)/(μi+θ)^2 + 2/(μi+θ) - 1/θ - trigamma+yi) + trigamma(θ)


[JuliaFormatter] reported by reviewdog 🐶

@debug "NegativeBinomial dispersion optimization" iteration=i θ=θ


[JuliaFormatter] reported by reviewdog 🐶

df.weights = repeat(1:5, Int(N/5))


[JuliaFormatter] reported by reviewdog 🐶

88.02760245551447 -0.06772589439264813;


[JuliaFormatter] reported by reviewdog 🐶

f = @formula(0 ~ 1 + G*H)


[JuliaFormatter] reported by reviewdog 🐶

y = logistic.(X*ones(2) + 1/10*randn(rng, n)) .> 1/2


[JuliaFormatter] reported by reviewdog 🐶

@formula(Days ~ Eth+Sex+Age+Lrn),


[JuliaFormatter] reported by reviewdog 🐶

@formula(Days ~ Eth+Sex+Age+Lrn),


[JuliaFormatter] reported by reviewdog 🐶

halfn = round(Int, 0.5*size(quine, 1))


[JuliaFormatter] reported by reviewdog 🐶

gm20a = negbin(@formula(Days ~ Eth+Sex+Age+Lrn), quine, LogLink(); wts = wts)


[JuliaFormatter] reported by reviewdog 🐶

gm20 = negbin(@formula(Days ~ Eth+Sex+Age+Lrn), quine, LogLink(); method = :qr)


[JuliaFormatter] reported by reviewdog 🐶

gm21 = negbin(@formula(Days ~ Eth+Sex+Age+Lrn), quine; method = dmethod)


[JuliaFormatter] reported by reviewdog 🐶

GLM.jl/test/runtests.jl

Lines 1421 to 1422 in 3c7258a

J = newX .* getindex.(GLM.inverselink.(LogitLink(), newX*coef(gm11)), 2)
se_pred = sqrt.(diag(J*vcov(gm11)*J'))


[JuliaFormatter] reported by reviewdog 🐶

se_pred = sqrt.(diag(newX*vcov(mm)*newX'))


[JuliaFormatter] reported by reviewdog 🐶

pred2.prediction - quantile(TDist(dof_residual(mm)), 0.975)*se_pred


[JuliaFormatter] reported by reviewdog 🐶

pred2.prediction + quantile(TDist(dof_residual(mm)), 0.975)*se_pred


[JuliaFormatter] reported by reviewdog 🐶

GLM.jl/test/runtests.jl

Lines 1637 to 1640 in 3c7258a

quantile(
TDist(dof_residual(mm)),
0.975,
)*sqrt.(diag(newX*vcov(mm)*newX') .+ deviance(mm)/dof_residual(mm))


[JuliaFormatter] reported by reviewdog 🐶

GLM.jl/test/runtests.jl

Lines 1650 to 1653 in 3c7258a

quantile(
TDist(dof_residual(mm)),
0.975,
)*sqrt.(diag(newX*vcov(mm)*newX') .+ deviance(mm)/dof_residual(mm))


[JuliaFormatter] reported by reviewdog 🐶

GLM.jl/test/runtests.jl

Lines 1842 to 1844 in 3c7258a

@test preds_transformation.prediction ggplot_prediction atol=1e-3
@test preds_transformation.lower ggplot_lower atol=1e-3
@test preds_transformation.upper ggplot_upper atol=1e-3


[JuliaFormatter] reported by reviewdog 🐶

@test preds_delta.upper .- preds_delta.lower 2 .* 1.96 .* R_glm_se atol=1e-3


[JuliaFormatter] reported by reviewdog 🐶

1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0;


[JuliaFormatter] reported by reviewdog 🐶

Yc = RL\Y


[JuliaFormatter] reported by reviewdog 🐶

Xc1 = RL\X[:, [1]]


[JuliaFormatter] reported by reviewdog 🐶

Xc2 = RL\X


[JuliaFormatter] reported by reviewdog 🐶

GLM.jl/test/runtests.jl

Lines 2088 to 2090 in 3c7258a

Matrix(qr(randn(rng, 100, 5)).Q)*Diagonal(10 .^ (-2.0:1.0:2.0))*Matrix(
qr(randn(rng, 5, 5)).Q,
)'


[JuliaFormatter] reported by reviewdog 🐶

mod = lm(@formula(Result~Treatment), d)


[JuliaFormatter] reported by reviewdog 🐶

y = X*ones(2) + randn(10)


[JuliaFormatter] reported by reviewdog 🐶

@test stderror(mdl) [0.224095414423756, 0.003342439119757, 0.005838227761632] atol=1.0e-8


[JuliaFormatter] reported by reviewdog 🐶

@formula(y~x),


[JuliaFormatter] reported by reviewdog 🐶

contrasts = Dict(:x=>DummyCoding()),


[JuliaFormatter] reported by reviewdog 🐶

mcat = lm(@formula(y~x), (y = 1:25, x = categorical(repeat(1:5, 5))))


[JuliaFormatter] reported by reviewdog 🐶

@formula(y~x),


[JuliaFormatter] reported by reviewdog 🐶

contrasts = Dict(:x=>DummyCoding()),


[JuliaFormatter] reported by reviewdog 🐶

@formula(y~x),


[JuliaFormatter] reported by reviewdog 🐶

@formula(y~x),


[JuliaFormatter] reported by reviewdog 🐶

contrasts = Dict(:x=>DummyCoding()),


[JuliaFormatter] reported by reviewdog 🐶

mcat = fit(LinearModel, @formula(y~x), (y = 1:25, x = categorical(repeat(1:5, 5))))


[JuliaFormatter] reported by reviewdog 🐶

@formula(y~x),


[JuliaFormatter] reported by reviewdog 🐶

contrasts = Dict(:x=>DummyCoding()),


[JuliaFormatter] reported by reviewdog 🐶

@formula(y~x),


[JuliaFormatter] reported by reviewdog 🐶

@formula(y~x),


[JuliaFormatter] reported by reviewdog 🐶

contrasts = Dict(:x=>EffectsCoding()),


[JuliaFormatter] reported by reviewdog 🐶

@formula(y~x),


[JuliaFormatter] reported by reviewdog 🐶

contrasts = Dict(:x=>EffectsCoding()),


[JuliaFormatter] reported by reviewdog 🐶

@formula(y~x),


[JuliaFormatter] reported by reviewdog 🐶

contrasts = Dict(:x=>EffectsCoding()),


[JuliaFormatter] reported by reviewdog 🐶

@formula(y~x),


[JuliaFormatter] reported by reviewdog 🐶

contrasts = Dict(:x=>EffectsCoding()),


[JuliaFormatter] reported by reviewdog 🐶

-0.5493329715011036 0.26350316142056085;


[JuliaFormatter] reported by reviewdog 🐶

f = @formula(0 ~ 1 + G*H)


[JuliaFormatter] reported by reviewdog 🐶

f = @formula(0 ~ 1 + G*H)


[JuliaFormatter] reported by reviewdog 🐶

@test gvif(lm2; scale = true) [1.486330, 2.301648, 1.502666] atol=1e-4


[JuliaFormatter] reported by reviewdog 🐶

@test gvif(gm2; scale = true) [1.486330, 2.301648, 1.502666] atol=1e-4

@JuliaStats JuliaStats deleted a comment from github-actions Bot Apr 15, 2025
@JuliaStats JuliaStats deleted a comment from github-actions Bot Apr 15, 2025
@JuliaStats JuliaStats deleted a comment from github-actions Bot Apr 15, 2025
@JuliaStats JuliaStats deleted a comment from github-actions Bot Apr 15, 2025
@JuliaStats JuliaStats deleted a comment from github-actions Bot Apr 15, 2025
@JuliaStats JuliaStats deleted a comment from github-actions Bot Apr 15, 2025
@JuliaStats JuliaStats deleted a comment from github-actions Bot Apr 15, 2025
@JuliaStats JuliaStats deleted a comment from github-actions Bot Apr 15, 2025
@JuliaStats JuliaStats deleted a comment from github-actions Bot Apr 15, 2025
@JuliaStats JuliaStats deleted a comment from github-actions Bot Apr 15, 2025
@JuliaStats JuliaStats deleted a comment from github-actions Bot Apr 15, 2025
@JuliaStats JuliaStats deleted a comment from github-actions Bot Apr 15, 2025
@JuliaStats JuliaStats deleted a comment from github-actions Bot Apr 15, 2025
@JuliaStats JuliaStats deleted a comment from github-actions Bot Apr 15, 2025
@JuliaStats JuliaStats deleted a comment from github-actions Bot Apr 15, 2025
@JuliaStats JuliaStats deleted a comment from github-actions Bot Apr 15, 2025
@JuliaStats JuliaStats deleted a comment from github-actions Bot Apr 15, 2025
@JuliaStats JuliaStats deleted a comment from github-actions Bot Apr 15, 2025
@JuliaStats JuliaStats deleted a comment from github-actions Bot Apr 15, 2025
@JuliaStats JuliaStats deleted a comment from github-actions Bot Apr 15, 2025
@JuliaStats JuliaStats deleted a comment from github-actions Bot Apr 15, 2025
@JuliaStats JuliaStats deleted a comment from github-actions Bot Apr 15, 2025
@JuliaStats JuliaStats deleted a comment from github-actions Bot Apr 15, 2025
@JuliaStats JuliaStats deleted a comment from github-actions Bot Apr 15, 2025
@JuliaStats JuliaStats deleted a comment from github-actions Bot Apr 15, 2025
@JuliaStats JuliaStats deleted a comment from github-actions Bot Apr 15, 2025
@JuliaStats JuliaStats deleted a comment from github-actions Bot Apr 15, 2025
@JuliaStats JuliaStats deleted a comment from github-actions Bot Apr 15, 2025
@JuliaStats JuliaStats deleted a comment from github-actions Bot Apr 15, 2025
@JuliaStats JuliaStats deleted a comment from github-actions Bot Apr 15, 2025
@JuliaStats JuliaStats deleted a comment from github-actions Bot Apr 15, 2025
@JuliaStats JuliaStats deleted a comment from github-actions Bot Apr 15, 2025
@JuliaStats JuliaStats deleted a comment from github-actions Bot Apr 15, 2025
@devmotion
Copy link
Copy Markdown
Member

Maybe even if we decide to use the default style, a .JuliaFormatter.toml file (in that case empty) should be added to the repo. JuliaFormatter.format traverses the file path upwards until it finds (or in the end doesn't find) a .JuliaFormatter.toml file: https://domluna.github.io/JuliaFormatter.jl/stable/config/ So in principle a configuration higher up in the file tree could cause the formatter to format GLM with a different style.

@JuliaStats JuliaStats deleted a comment from github-actions Bot Apr 17, 2025
@JuliaStats JuliaStats deleted a comment from github-actions Bot Apr 17, 2025
@nalimilan nalimilan merged commit 8f58b34 into master Apr 18, 2025
17 checks passed
@nalimilan nalimilan deleted the nl/format branch April 18, 2025 10:22
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.

3 participants