Skip to content

Commit a6ea5b5

Browse files
committed
Transitioned to ProgressLogging
1 parent f8a723c commit a6ea5b5

File tree

4 files changed

+26
-8
lines changed

4 files changed

+26
-8
lines changed

Project.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ElectricFields = "2f84ce32-9bb1-11e8-0d9f-3dce90a4beca"
88
FastGaussQuadrature = "442a2c76-b920-505d-bb47-c5924d526838"
99
HCubature = "19dc6840-f33b-545b-b366-655c7e3ffd49"
1010
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
11-
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
11+
ProgressLogging = "33c8b6b6-d38a-422a-b730-caa89a2f386c"
1212
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
1313
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
1414
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
@@ -18,7 +18,6 @@ UnitfulAtomic = "a7773ee8-282e-5fa2-be4e-bd808c38a91a"
1818
ElectricFields = "0.1, 0.2"
1919
FastGaussQuadrature = "0.4.7, 0.5"
2020
HCubature = "1.5"
21-
ProgressMeter = "1.5,1.6"
2221
SpecialFunctions = "1.3,2"
2322
StaticArrays = "1.1"
2423
Unitful = "1.7"

src/StrongFieldApproximation.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ using FastGaussQuadrature
88
using LinearAlgebra
99
using StaticArrays
1010

11-
using ProgressMeter
11+
using ProgressLogging
1212

1313
include("threading.jl")
1414
include("telescope_iterators.jl")

src/dyson_expansions.jl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -469,10 +469,12 @@ function photoelectron_spectrum(k::AbstractArray{T},
469469

470470
cT = complex(eltype(T))
471471
c = similar(k, cT)
472-
p = Progress(length(k))
473-
threaded_range_loop(eachindex(k)) do i
474-
c[i] = integrate_diagram(cT, system, diagram, iref, k[i]; kwargs...)
475-
ProgressMeter.next!(p)
472+
p = Prog(length(k))
473+
@withprogress begin
474+
threaded_range_loop(eachindex(k)) do i
475+
c[i] = integrate_diagram(cT, system, diagram, iref, k[i]; kwargs...)
476+
@inc p
477+
end
476478
end
477479
c
478480
end
@@ -498,7 +500,7 @@ function induced_dipole(system::System, diagram::Diagram; verbosity = 1, kwargs.
498500

499501
memory = get(kwargs, :memory, typemax(Int))
500502

501-
@showprogress for (i,t) in enumerate(t)
503+
@progress for (i,t) in enumerate(t)
502504
𝐝̃ = integrate_diagram(DT, system, diagram, i; imin=i-memory, kwargs...)
503505
𝐝[i] = 2real(𝐝̃)
504506
end

src/threading.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,20 @@ threaded_range_loop(fun::Function, v::AbstractVector) =
2727

2828
threaded_enumerate_range_loop(fun::Function, v::AbstractVector) =
2929
threaded_range_loop(i -> fun(i,v[i]), length(v))
30+
31+
# https://github.com/JuliaLogging/ProgressLogging.jl/issues/44#issuecomment-1923812159
32+
mutable struct Prog
33+
N::Int
34+
@atomic count::Int
35+
end
36+
37+
Prog(N) = Prog(N, 0)
38+
39+
inc!(p::Prog) = @atomic p.count += 1
40+
41+
macro inc(p)
42+
quote
43+
local M = $inc!($p) # It seems to be important to separate this out from the `@logprogress` step since `@logprogress` can double-evaluate
44+
$ProgressLogging.@logprogress M / $p.N
45+
end |> esc
46+
end

0 commit comments

Comments
 (0)