From 87f72a92a7522609cdff844d523c40a6bf769b08 Mon Sep 17 00:00:00 2001 From: Zentrik Date: Sun, 1 Oct 2023 01:09:47 +0100 Subject: [PATCH] Use `===` instead of `==` Co-authored-by: Christopher Rackauckas --- lib/OptimizationBBO/src/OptimizationBBO.jl | 14 +++++++------- lib/OptimizationOptimisers/src/sophia.jl | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/OptimizationBBO/src/OptimizationBBO.jl b/lib/OptimizationBBO/src/OptimizationBBO.jl index ff1929931..9ef8ccd61 100644 --- a/lib/OptimizationBBO/src/OptimizationBBO.jl +++ b/lib/OptimizationBBO/src/OptimizationBBO.jl @@ -112,7 +112,7 @@ function SciMLBase.__solve(cache::Optimization.OptimizationCache{ cur, state = iterate(cache.data) function _cb(trace) - if cache.callback == Optimization.DEFAULT_CALLBACK + if cache.callback === Optimization.DEFAULT_CALLBACK cb_call = false else cb_call = cache.callback(decompose_trace(trace, cache.progress), x...) @@ -125,7 +125,7 @@ function SciMLBase.__solve(cache::Optimization.OptimizationCache{ BlackBoxOptim.shutdown_optimizer!(trace) #doesn't work end - if cache.data != Optimization.DEFAULT_DATA + if cache.data !== Optimization.DEFAULT_DATA cur, state = iterate(cache.data, state) end cb_call @@ -135,11 +135,11 @@ function SciMLBase.__solve(cache::Optimization.OptimizationCache{ maxtime = Optimization._check_and_convert_maxtime(cache.solver_args.maxtime) _loss = function (θ) - if cache.callback == Optimization.DEFAULT_CALLBACK && cache.data == Optimization.DEFAULT_DATA + if cache.callback === Optimization.DEFAULT_CALLBACK && cache.data === Optimization.DEFAULT_DATA return first(cache.f(θ, cache.p)) - elseif cache.callback == Optimization.DEFAULT_CALLBACK + elseif cache.callback === Optimization.DEFAULT_CALLBACK return first(cache.f(θ, cache.p, cur...)) - elseif cache.data != Optimization.DEFAULT_DATA + elseif cache.data !== Optimization.DEFAULT_DATA x = cache.f(θ, cache.p) return first(x) else @@ -149,8 +149,8 @@ function SciMLBase.__solve(cache::Optimization.OptimizationCache{ end opt_args = __map_optimizer_args(cache, cache.opt; - callback = cache.callback == Optimization.DEFAULT_CALLBACK && - cache.data == Optimization.DEFAULT_DATA ? + callback = cache.callback === Optimization.DEFAULT_CALLBACK && + cache.data === Optimization.DEFAULT_DATA ? nothing : _cb, cache.solver_args..., maxiters = maxiters, diff --git a/lib/OptimizationOptimisers/src/sophia.jl b/lib/OptimizationOptimisers/src/sophia.jl index 1f0ed87f7..fa9fa827b 100644 --- a/lib/OptimizationOptimisers/src/sophia.jl +++ b/lib/OptimizationOptimisers/src/sophia.jl @@ -71,9 +71,9 @@ function SciMLBase.__solve(cache::OptimizationCache{ maxiters = Optimization._check_and_convert_maxiters(maxiters) _loss = function (θ) - if cache.callback == Optimization.DEFAULT_CALLBACK && data == Optimization.DEFAULT_DATA + if cache.callback === Optimization.DEFAULT_CALLBACK && data === Optimization.DEFAULT_DATA return first(cache.f(θ, cache.p)) - elseif cache.callback == Optimization.DEFAULT_CALLBACK + elseif cache.callback === Optimization.DEFAULT_CALLBACK return first(cache.f(θ, cache.p, cur...)) elseif data === Optimization.DEFAULT_DATA x = cache.f(θ, cache.p)