Skip to content

Commit fb78b49

Browse files
oameyeChristophHotterdavid-pl
committed
style: add Formatter
Co-authored-by: Christoph Hotter <[email protected]> Co-authored-by: David Plankensteiner <[email protected]>
1 parent 877aec9 commit fb78b49

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+6343
-4575
lines changed

.github/workflows/Format.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: format-check
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- reopened
8+
- synchronize
9+
- ready_for_review
10+
11+
jobs:
12+
build:
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
matrix:
16+
julia-version: [1]
17+
julia-arch: [x86]
18+
os: [ubuntu-latest]
19+
steps:
20+
- uses: julia-actions/setup-julia@latest
21+
with:
22+
version: ${{ matrix.julia-version }}
23+
24+
- uses: actions/checkout@v4
25+
- name: Install JuliaFormatter and format
26+
# This will use the latest version by default but you can set the version like so:
27+
#
28+
# julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter", version="0.13.0"))'
29+
run: |
30+
julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter"))'
31+
julia -e 'using JuliaFormatter; format(".", verbose=true)'
32+
- name: Format check
33+
run: |
34+
julia -e '
35+
out = Cmd(`git diff`) |> read |> String
36+
if out == ""
37+
exit(0)
38+
else
39+
@error "Some files have not been formatted !!!"
40+
write(stdout, out)
41+
exit(1)
42+
end'

Makefile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
JULIA:=julia
2+
3+
default: help
4+
5+
setup:
6+
${JULIA} -e 'import Pkg; Pkg.add(["JuliaFormatter", "Changelog", "LiveServer"])'
7+
8+
format:
9+
${JULIA} -e 'using JuliaFormatter; format(".")'
10+
11+
servedocs:
12+
${JULIA} --project=docs -e 'using LiveServer; LiveServer.servedocs()'
13+
14+
test:
15+
${JULIA} --project -e 'using Pkg; Pkg.resolve(); Pkg.test()'
16+
17+
docs:
18+
${JULIA} --project=docs -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
19+
${JULIA} --project=docs docs/make.jl
20+
21+
bench:
22+
${JULIA} --project=benchmarks -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
23+
${JULIA} --project=docs benchmarks/runbenchmarks.jl
24+
25+
26+
all: setup format test docs
27+
28+
help:
29+
@echo "The following make commands are available:"
30+
@echo " - make setup: install the dependencies for make command"
31+
@echo " - make format: format codes with JuliaFormatter"
32+
@echo " - make test: run the tests"
33+
@echo " - make docs: instantiate and build the documentation"
34+
@echo " - make servedocs: serve the documentation locally"
35+
@echo " - make bench: run the benchmarks"
36+
@echo " - make all: run every commands in the above order"
37+
38+
.PHONY: default setup format test docs servedocs bench all help

docs/make.jl

Lines changed: 32 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,29 @@ using QuantumCumulants, SecondQuantizedAlgebra
44
ENV["GKSwstype"] = "100" # enable headless mode for GR to suppress warnings when plotting
55

66
pages = [
7-
"index.md",
8-
"theory.md",
9-
"tutorial.md",
10-
"correlation.md",
11-
"symbolic_sums.md",
12-
"implementation.md",
13-
"api.md",
14-
"Examples" => [
15-
"examples/single-atom-laser-spectrum.md"
16-
"examples/mollow.md"
17-
"examples/many-atom-laser.md"
18-
"examples/optomechanical-cooling.md"
19-
"examples/excitation-transport-chain.md"
20-
"examples/ramsey_spectroscopy.md"
21-
"examples/superradiant_laser_indexed.md"
22-
"examples/cavity_antiresonance_indexed.md"
23-
"examples/filter-cavity_indexed.md"
24-
"examples/unique_squeezing.md"
25-
"examples/waveguide.md"
26-
"examples/superradiant-laser.md"
27-
# "examples/heterodyne_detection.md"
28-
]
29-
]
7+
"index.md",
8+
"theory.md",
9+
"tutorial.md",
10+
"correlation.md",
11+
"symbolic_sums.md",
12+
"implementation.md",
13+
"api.md",
14+
"Examples" => [
15+
"examples/single-atom-laser-spectrum.md"
16+
"examples/mollow.md"
17+
"examples/many-atom-laser.md"
18+
"examples/optomechanical-cooling.md"
19+
"examples/excitation-transport-chain.md"
20+
"examples/ramsey_spectroscopy.md"
21+
"examples/superradiant_laser_indexed.md"
22+
"examples/cavity_antiresonance_indexed.md"
23+
"examples/filter-cavity_indexed.md"
24+
"examples/unique_squeezing.md"
25+
"examples/waveguide.md"
26+
"examples/superradiant-laser.md"
27+
# "examples/heterodyne_detection.md"
28+
],
29+
]
3030

3131
using Pkg
3232
status = sprint(io -> Pkg.status("SecondQuantizedAlgebra"; io = io))
@@ -39,17 +39,14 @@ makedocs(
3939
modules = [QuantumCumulants, SecondQuantizedAlgebra],
4040
pages = pages,
4141
remotes = remotes,
42-
checkdocs=:exports,
42+
checkdocs = :exports,
4343
format = Documenter.HTML(
44-
mathengine=MathJax(),
45-
footer="[**Back to GitHub**](https://github.com/qojulia/QuantumCumulants.jl)",
46-
example_size_threshold = 800 * 2^10,
47-
size_threshold_warn = 400 * 2^10,
48-
size_threshold = 600 * 2^10,
49-
)
50-
)
44+
mathengine = MathJax(),
45+
footer = "[**Back to GitHub**](https://github.com/qojulia/QuantumCumulants.jl)",
46+
example_size_threshold = 800 * 2^10,
47+
size_threshold_warn = 400 * 2^10,
48+
size_threshold = 600 * 2^10,
49+
),
50+
)
5151

52-
deploydocs(
53-
repo = "github.com/qojulia/QuantumCumulants.jl.git",
54-
push_preview = false,
55-
)
52+
deploydocs(repo = "github.com/qojulia/QuantumCumulants.jl.git", push_preview = false)

src/QuantumCumulants.jl

Lines changed: 122 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -21,43 +21,135 @@ import QuantumOpticsBase: ⊗, tensor
2121

2222
using Reexport
2323
@reexport using SecondQuantizedAlgebra
24-
using SecondQuantizedAlgebra: QNumber, SNuN, QMul, QAdd, ClusterAon, CallableTransition,
25-
IndexInt, get_indices, commutator, numeric_average, _conj,
26-
_adjoint, get_i, hilbert, inorder!, levels, has_cluster, ismergeable, inadjoint,
27-
undo_average, _average, sym_average, IndexedVariable, DoubleIndexedVariable,
28-
SpecialIndexedAverage, IndexedAverageSum, _inconj, DoubleNumberedVariable,
29-
SingleNumberedVariable, create_index_arrays,
30-
IndexedAverageDoubleSum, getIndName, _to_expression, AvgSums, get_numbers
24+
using SecondQuantizedAlgebra:
25+
QNumber,
26+
SNuN,
27+
QMul,
28+
QAdd,
29+
ClusterAon,
30+
CallableTransition,
31+
IndexInt,
32+
get_indices,
33+
commutator,
34+
numeric_average,
35+
_conj,
36+
_adjoint,
37+
get_i,
38+
hilbert,
39+
inorder!,
40+
levels,
41+
has_cluster,
42+
ismergeable,
43+
inadjoint,
44+
undo_average,
45+
_average,
46+
sym_average,
47+
IndexedVariable,
48+
DoubleIndexedVariable,
49+
SpecialIndexedAverage,
50+
IndexedAverageSum,
51+
_inconj,
52+
DoubleNumberedVariable,
53+
SingleNumberedVariable,
54+
create_index_arrays,
55+
IndexedAverageDoubleSum,
56+
getIndName,
57+
_to_expression,
58+
AvgSums,
59+
get_numbers
3160
const SQA = SecondQuantizedAlgebra
3261

3362
import Base: *, +, -
3463

35-
export HilbertSpace, ProductSpace, , tensor,
36-
QSym, QTerm, @qnumbers,
37-
FockSpace, Destroy, Create,
38-
NLevelSpace, Transition,
39-
PauliSpace, Pauli, SpinSpace, Spin,
40-
MeanfieldEquations,
41-
meanfield, commutator, acts_on,
42-
CNumber, Parameter, @cnumbers, cnumbers, cnumber, RNumber, RealParameter, @rnumbers, rnumbers, rnumber,
43-
cumulant_expansion, get_order, cumulant,
44-
find_missing, complete, complete!, find_operators, fundamental_operators,
45-
unique_ops, unique_ops!, to_numeric, numeric_average, initial_values, get_solution, get_scale_solution,
46-
CorrelationFunction, Spectrum, correlation_u0, correlation_p0,
47-
ClusterSpace,
48-
scale,
49-
transition_superscript,
50-
Index, reorder, IndexedOperator, SingleSum, IndexedVariable, DoubleIndexedVariable,
51-
DoubleSum, indexed_complete, IndexedCorrelationFunction, scale_term,
52-
scaleME, evalME, indexed_complete!, indexed_meanfield, subst_reds, AvgSums, plotME,
53-
IndexedAverageSum, IndexedAverageDoubleSum, SpecialIndexedTerm, find_missing_sums, Σ, ∑,
54-
evaluate, value_map, NumberedOperator, change_index, order_by_index, split_sums, insert_index, eval_term,
55-
MeanfieldNoiseEquations,
56-
IndexedMeanfieldNoiseEquations#, indexed_arithmetic, indexed_noise, simplified_indexed_complete!
64+
export HilbertSpace,
65+
ProductSpace,
66+
,
67+
tensor,
68+
QSym,
69+
QTerm,
70+
@qnumbers,
71+
FockSpace,
72+
Destroy,
73+
Create,
74+
NLevelSpace,
75+
Transition,
76+
PauliSpace,
77+
Pauli,
78+
SpinSpace,
79+
Spin,
80+
MeanfieldEquations,
81+
meanfield,
82+
commutator,
83+
acts_on,
84+
CNumber,
85+
Parameter,
86+
@cnumbers,
87+
cnumbers,
88+
cnumber,
89+
RNumber,
90+
RealParameter,
91+
@rnumbers,
92+
rnumbers,
93+
rnumber,
94+
cumulant_expansion,
95+
get_order,
96+
cumulant,
97+
find_missing,
98+
complete,
99+
complete!,
100+
find_operators,
101+
fundamental_operators,
102+
unique_ops,
103+
unique_ops!,
104+
to_numeric,
105+
numeric_average,
106+
initial_values,
107+
get_solution,
108+
get_scale_solution,
109+
CorrelationFunction,
110+
Spectrum,
111+
correlation_u0,
112+
correlation_p0,
113+
ClusterSpace,
114+
scale,
115+
transition_superscript,
116+
Index,
117+
reorder,
118+
IndexedOperator,
119+
SingleSum,
120+
IndexedVariable,
121+
DoubleIndexedVariable,
122+
DoubleSum,
123+
indexed_complete,
124+
IndexedCorrelationFunction,
125+
scale_term,
126+
scaleME,
127+
evalME,
128+
indexed_complete!,
129+
indexed_meanfield,
130+
subst_reds,
131+
AvgSums,
132+
plotME,
133+
IndexedAverageSum,
134+
IndexedAverageDoubleSum,
135+
SpecialIndexedTerm,
136+
find_missing_sums,
137+
Σ,
138+
∑,
139+
evaluate,
140+
value_map,
141+
NumberedOperator,
142+
change_index,
143+
order_by_index,
144+
split_sums,
145+
insert_index,
146+
eval_term,
147+
MeanfieldNoiseEquations,
148+
IndexedMeanfieldNoiseEquations#, indexed_arithmetic, indexed_noise, simplified_indexed_complete!
57149

58150

59151
source_metadata(source, name) =
60-
Base.ImmutableDict{DataType, Any}(Symbolics.VariableSource, (source, name))
152+
Base.ImmutableDict{DataType,Any}(Symbolics.VariableSource, (source, name))
61153

62154

63155
include("equations.jl")

0 commit comments

Comments
 (0)