re-add removed call function

This commit is contained in:
Dhairya Gandhi 2018-11-08 18:44:57 +05:30
parent 5ec70fe29d
commit 392c3c942b
2 changed files with 9 additions and 0 deletions

View File

@ -11,6 +11,7 @@ function update!(opt, xs)
end
# Callback niceties
call(f, xs...) = f(xs...)
runall(f) = f
runall(fs::AbstractVector) = () -> foreach(call, fs)

View File

@ -1,4 +1,5 @@
using Flux.Optimise
using Flux.Optimise: runall
using Flux.Tracker
using Test
@testset "Optimise" begin
@ -50,4 +51,11 @@ end
cb = Flux.throttle(() -> (i > 3 && Flux.stop()), 1))
@test 3 < i < 50
# Test multiple callbacks
x = 0
fs = [() -> (), () -> x = 1]
cbs = runall(fs)
cbs()
@test x == 1
end