Skip to content

Commit 6747cb3

Browse files
authored
change nan to nothing for fast-math mode (#30)
* change nan to nothing for fast-math mode * update test
1 parent 76b1f6f commit 6747cb3

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

src/ProgressLogging.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ end
257257
"""
258258
function progress(f; name = "")
259259
_id = uuid4()
260-
@logmsg ProgressLevel name progress = NaN _id = _id
260+
@logmsg ProgressLevel name progress = nothing _id = _id
261261
try
262262
f(_id)
263263
finally
@@ -323,7 +323,7 @@ function _withprogress(exprs...)
323323
let $_parentid_var = $(kwargs[:parentid]),
324324
$_id_var = $uuid4(),
325325
$_name_var = $(kwargs[:name])
326-
$m.@logprogress NaN
326+
$m.@logprogress nothing
327327
try
328328
$ex
329329
finally

test/test_withprogress_macro.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ using Test: collect_test_logs
1111
@withprogress @logprogress "hello" 0.1
1212
end
1313
@test length(logs) == 3
14-
@test logs[1].kwargs[:progress] === NaN
14+
@test logs[1].kwargs[:progress] === nothing
1515
@test logs[2].kwargs[:progress] === 0.1
1616
@test logs[3].kwargs[:progress] === "done"
1717
@test logs[1].message == ""
@@ -29,7 +29,7 @@ end
2929
@withprogress name = "hello" @logprogress 0.1
3030
end
3131
@test length(logs) == 3
32-
@test logs[1].kwargs[:progress] === NaN
32+
@test logs[1].kwargs[:progress] === nothing
3333
@test logs[2].kwargs[:progress] === 0.1
3434
@test logs[3].kwargs[:progress] === "done"
3535
@test logs[1].message == "hello"
@@ -47,7 +47,7 @@ end
4747
@withprogress @logprogress 0.1 message = "hello"
4848
end
4949
@test length(logs) == 3
50-
@test logs[1].kwargs[:progress] === NaN
50+
@test logs[1].kwargs[:progress] === nothing
5151
@test logs[2].kwargs[:progress] === 0.1
5252
@test logs[3].kwargs[:progress] === "done"
5353
@test logs[2].kwargs[:message] === "hello"
@@ -63,7 +63,7 @@ end
6363
@withprogress name = "name" @logprogress "hello" 0.1
6464
end
6565
@test length(logs) == 3
66-
@test logs[1].kwargs[:progress] === NaN
66+
@test logs[1].kwargs[:progress] === nothing
6767
@test logs[2].kwargs[:progress] === 0.1
6868
@test logs[3].kwargs[:progress] === "done"
6969
@test logs[1].message == "name"
@@ -95,9 +95,9 @@ end
9595
(l.id, l.message.progress.parentid, string(l.message), l.kwargs[:progress])
9696
for l in logs
9797
) === (
98-
(ids[1], ROOTID, "", NaN),
98+
(ids[1], ROOTID, "", nothing),
9999
(ids[1], ROOTID, "hello", 0.1),
100-
(ids[2], ids[1], "", NaN),
100+
(ids[2], ids[1], "", nothing),
101101
(ids[2], ids[1], "world", 0.2),
102102
(ids[2], ids[1], "", "done"),
103103
(ids[1], ROOTID, "", "done"),
@@ -122,7 +122,7 @@ end
122122
@test [string(l.message) for l in logs] == messages[idxs]
123123
@test isequal(
124124
[l.kwargs[:progress] for l in logs],
125-
[NaN, NaN, 0.5, 1.0, "done", 0.5, NaN, 0.5, 1.0, "done", 1.0, "done"],
125+
[nothing, nothing, 0.5, 1.0, "done", 0.5, nothing, 0.5, 1.0, "done", 1.0, "done"],
126126
)
127127
end
128128

@@ -153,7 +153,7 @@ using Test: @test, @testset, collect_test_logs
153153
ProgressLogging.@withprogress ProgressLogging.@logprogress "hello" 0.1
154154
end
155155
@test length(logs) == 3
156-
@test logs[1].kwargs[:progress] === NaN
156+
@test logs[1].kwargs[:progress] === nothing
157157
@test logs[2].kwargs[:progress] === 0.1
158158
@test logs[3].kwargs[:progress] === "done"
159159
@test logs[1].message == ""

0 commit comments

Comments
 (0)