From 42625fb176b0e296603e1533e28a9551b6d58771 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlio=20Hoffimann?= Date: Sat, 20 May 2023 08:26:22 -0300 Subject: [PATCH 1/4] Fix formatting issues --- ext/DensityRatioEstimationChainRulesCoreExt.jl | 1 + ext/DensityRatioEstimationConvexExt.jl | 1 + ext/DensityRatioEstimationGPUArraysExt.jl | 1 + ext/DensityRatioEstimationJuMPExt.jl | 1 + ext/DensityRatioEstimationOptimExt.jl | 3 ++- src/DensityRatioEstimation.jl | 16 ++++++---------- src/kliep/convex.jl | 2 +- src/kliep/optim.jl | 2 +- src/kmm/jump.jl | 2 +- src/lsif/jump.jl | 2 +- src/lsif/optim.jl | 2 +- 11 files changed, 17 insertions(+), 16 deletions(-) diff --git a/ext/DensityRatioEstimationChainRulesCoreExt.jl b/ext/DensityRatioEstimationChainRulesCoreExt.jl index 0ec4884..82e49ed 100644 --- a/ext/DensityRatioEstimationChainRulesCoreExt.jl +++ b/ext/DensityRatioEstimationChainRulesCoreExt.jl @@ -1,6 +1,7 @@ # ------------------------------------------------------------------ # Licensed under the MIT License. See LICENSE in the project root. # ------------------------------------------------------------------ + module DensityRatioEstimationChainRulesCoreExt if isdefined(Base, :get_extension) diff --git a/ext/DensityRatioEstimationConvexExt.jl b/ext/DensityRatioEstimationConvexExt.jl index d70f848..b416af8 100644 --- a/ext/DensityRatioEstimationConvexExt.jl +++ b/ext/DensityRatioEstimationConvexExt.jl @@ -1,6 +1,7 @@ # ------------------------------------------------------------------ # Licensed under the MIT License. See LICENSE in the project root. # ------------------------------------------------------------------ + module DensityRatioEstimationConvexExt if isdefined(Base, :get_extension) diff --git a/ext/DensityRatioEstimationGPUArraysExt.jl b/ext/DensityRatioEstimationGPUArraysExt.jl index c16705a..9f58743 100644 --- a/ext/DensityRatioEstimationGPUArraysExt.jl +++ b/ext/DensityRatioEstimationGPUArraysExt.jl @@ -1,6 +1,7 @@ # ------------------------------------------------------------------ # Licensed under the MIT License. See LICENSE in the project root. # ------------------------------------------------------------------ + module DensityRatioEstimationGPUArraysExt if isdefined(Base, :get_extension) diff --git a/ext/DensityRatioEstimationJuMPExt.jl b/ext/DensityRatioEstimationJuMPExt.jl index ee49421..44837d5 100644 --- a/ext/DensityRatioEstimationJuMPExt.jl +++ b/ext/DensityRatioEstimationJuMPExt.jl @@ -1,6 +1,7 @@ # ------------------------------------------------------------------ # Licensed under the MIT License. See LICENSE in the project root. # ------------------------------------------------------------------ + module DensityRatioEstimationJuMPExt if isdefined(Base, :get_extension) diff --git a/ext/DensityRatioEstimationOptimExt.jl b/ext/DensityRatioEstimationOptimExt.jl index 4b1b4f8..e337adc 100644 --- a/ext/DensityRatioEstimationOptimExt.jl +++ b/ext/DensityRatioEstimationOptimExt.jl @@ -1,6 +1,7 @@ # ------------------------------------------------------------------ # Licensed under the MIT License. See LICENSE in the project root. # ------------------------------------------------------------------ + module DensityRatioEstimationOptimExt if isdefined(Base, :get_extension) @@ -12,7 +13,7 @@ else using ..DensityRatioEstimation: KLIEP, LSIF, OptimLib using ..Optim end -using LinearAlgebra + include("../src/kliep/optim.jl") include("../src/lsif/optim.jl") diff --git a/src/DensityRatioEstimation.jl b/src/DensityRatioEstimation.jl index f933757..ee1f284 100644 --- a/src/DensityRatioEstimation.jl +++ b/src/DensityRatioEstimation.jl @@ -32,27 +32,24 @@ include("lcv.jl") # pure Julia implementations include("kmm/julia.jl") -if !isdefined(Base, :get_extension) - using Requires -end # implementations that require extra dependencies @static if !isdefined(Base, :get_extension) + using Requires + function __init__() - - #Solvers - - #JuMP: KMM, LSIF + # JuMP: KMM, LSIF @require JuMP = "4076af6c-e467-56ae-b986-b466b2749572" begin @require Ipopt = "b6b21f68-93f8-5de0-b562-5493be1d77c9" begin include("../ext/DensityRatioEstimationJuMPExt.jl") end end - #Optim: KLIEP, LSIF + + # Optim: KLIEP, LSIF @require Optim = "429524aa-4258-5aef-a3af-852621145aeb" begin include("../ext/DensityRatioEstimationOptimExt.jl") end - #Convex: KLIEP + # Convex: KLIEP @require Convex = "f65535da-76fb-5f13-bab9-19810c17039a" begin @require ECOS = "e2685f51-7e38-5353-a97d-a921fd2c8199" begin include("../ext/DensityRatioEstimationConvexExt.jl") @@ -63,7 +60,6 @@ end @require ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" begin include("../ext/DensityRatioEstimationChainRulesCoreExt.jl") end - @require GPUArrays = "0c68f7d7-f131-5f86-a1c3-88cf8149b2d7" begin include("../ext/DensityRatioEstimationGPUArraysExt.jl") end diff --git a/src/kliep/convex.jl b/src/kliep/convex.jl index d6f3bbf..9f6641f 100644 --- a/src/kliep/convex.jl +++ b/src/kliep/convex.jl @@ -2,7 +2,7 @@ # Licensed under the MIT License. See LICENSE in the project root. # ------------------------------------------------------------------ -#This file is part of the module DensityRatioEstimationConvexExt. +# This file is part of the module DensityRatioEstimationConvexExt. function DensityRatioEstimation._kliep_coeffs(K_nu, K_de, dre::KLIEP, optlib::Type{ConvexLib}) # retrieve parameters diff --git a/src/kliep/optim.jl b/src/kliep/optim.jl index 025fe63..8074ea8 100644 --- a/src/kliep/optim.jl +++ b/src/kliep/optim.jl @@ -2,7 +2,7 @@ # Licensed under the MIT License. See LICENSE in the project root. # ------------------------------------------------------------------ -#This file is part of the module DensityRatioEstimationOptimExt. +# This file is part of the module DensityRatioEstimationOptimExt. function DensityRatioEstimation._kliep_coeffs(K_nu, K_de, dre::KLIEP, optlib::Type{OptimLib}) # retrieve parameters diff --git a/src/kmm/jump.jl b/src/kmm/jump.jl index 13eb481..2a3dfa6 100644 --- a/src/kmm/jump.jl +++ b/src/kmm/jump.jl @@ -2,7 +2,7 @@ # Licensed under the MIT License. See LICENSE in the project root. # ------------------------------------------------------------------ -#This file is part of the module DensityRatioEstimationJuMPExt. +# This file is part of the module DensityRatioEstimationJuMPExt. function _kmm_jump_model(K, κ, dre::AbstractKMM, optlib::Type{JuMPLib}) # number of denominator samples diff --git a/src/lsif/jump.jl b/src/lsif/jump.jl index 3c4169e..bdb4045 100644 --- a/src/lsif/jump.jl +++ b/src/lsif/jump.jl @@ -2,7 +2,7 @@ # Licensed under the MIT License. See LICENSE in the project root. # ------------------------------------------------------------------ -#This file is part of the module DensityRatioEstimationJuMPExt. +# This file is part of the module DensityRatioEstimationJuMPExt. function DensityRatioEstimation._lsif_coeffs(H, h, dre::LSIF, optlib::Type{JuMPLib}) # retrieve parameters diff --git a/src/lsif/optim.jl b/src/lsif/optim.jl index 9c7f27d..dc90fc6 100644 --- a/src/lsif/optim.jl +++ b/src/lsif/optim.jl @@ -2,7 +2,7 @@ # Licensed under the MIT License. See LICENSE in the project root. # ------------------------------------------------------------------ -#This file is part of the module DensityRatioEstimationOptimExt. +# This file is part of the module DensityRatioEstimationOptimExt. function DensityRatioEstimation._lsif_coeffs(H, h, dre::LSIF, optlib::Type{OptimLib}) # retrieve parameters From 7d39d46aaf4386a7427d2629c9bb41ccbfed0aac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlio=20Hoffimann?= Date: Sat, 20 May 2023 08:33:54 -0300 Subject: [PATCH 2/4] Fix Requires import --- src/DensityRatioEstimation.jl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/DensityRatioEstimation.jl b/src/DensityRatioEstimation.jl index ee1f284..cc64e0c 100644 --- a/src/DensityRatioEstimation.jl +++ b/src/DensityRatioEstimation.jl @@ -33,9 +33,10 @@ include("lcv.jl") include("kmm/julia.jl") # implementations that require extra dependencies -@static if !isdefined(Base, :get_extension) +if !isdefined(Base, :get_extension) using Requires - +end +if !isdefined(Base, :get_extension) function __init__() # JuMP: KMM, LSIF @require JuMP = "4076af6c-e467-56ae-b986-b466b2749572" begin From 1e271df82b30c5521a2d0ccc6e51a306e497f8b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlio=20Hoffimann?= Date: Sat, 20 May 2023 08:56:47 -0300 Subject: [PATCH 3/4] Add missing LinearAlgebra in extension --- ext/DensityRatioEstimationOptimExt.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ext/DensityRatioEstimationOptimExt.jl b/ext/DensityRatioEstimationOptimExt.jl index e337adc..7dc088f 100644 --- a/ext/DensityRatioEstimationOptimExt.jl +++ b/ext/DensityRatioEstimationOptimExt.jl @@ -14,6 +14,8 @@ else using ..Optim end +using LinearAlgebra + include("../src/kliep/optim.jl") include("../src/lsif/optim.jl") From db0974cdbf596dd4a4485cc264cf66c3842cd06c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlio=20Hoffimann?= Date: Sat, 20 May 2023 09:07:11 -0300 Subject: [PATCH 4/4] Fix conditional import --- src/DensityRatioEstimation.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DensityRatioEstimation.jl b/src/DensityRatioEstimation.jl index cc64e0c..c85e275 100644 --- a/src/DensityRatioEstimation.jl +++ b/src/DensityRatioEstimation.jl @@ -36,7 +36,7 @@ include("kmm/julia.jl") if !isdefined(Base, :get_extension) using Requires end -if !isdefined(Base, :get_extension) +@static if !isdefined(Base, :get_extension) function __init__() # JuMP: KMM, LSIF @require JuMP = "4076af6c-e467-56ae-b986-b466b2749572" begin