Skip to content

Commit

Permalink
support julia 1.9 onwards (#57)
Browse files Browse the repository at this point in the history
* support julia 1.9 onwards

* remove requires from Project.toml
  • Loading branch information
longemen3000 committed Jul 7, 2023
1 parent 5305648 commit 29c4e8c
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 89 deletions.
4 changes: 1 addition & 3 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ version = "1.1.1"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Parameters = "d96e819e-fc66-5662-9728-84c9c7592b0a"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"

Expand Down Expand Up @@ -36,9 +35,8 @@ Ipopt = "1"
JuMP = "1"
Optim = "1"
Parameters = "0.12"
Requires = "1"
StatsBase = "0.33, 0.34"
julia = "1.6"
julia = "1.9"

[extras]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
Expand Down
9 changes: 2 additions & 7 deletions ext/DensityRatioEstimationChainRulesCoreExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,8 @@

module DensityRatioEstimationChainRulesCoreExt

if isdefined(Base, :get_extension)
using DensityRatioEstimation
using ChainRulesCore
else
using ..DensityRatioEstimation
using ..ChainRulesCore
end
using DensityRatioEstimation
using ChainRulesCore

ChainRulesCore.@non_differentiable DensityRatioEstimation.safe_diagm(::Any, ::Any)

Expand Down
15 changes: 4 additions & 11 deletions ext/DensityRatioEstimationConvexExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,10 @@

module DensityRatioEstimationConvexExt

if isdefined(Base, :get_extension)
using DensityRatioEstimation
using DensityRatioEstimation: KLIEP, ConvexLib
using Convex
using ECOS
else
using ..DensityRatioEstimation
using ..DensityRatioEstimation: KLIEP, ConvexLib
using ..Convex
using ..ECOS
end
using DensityRatioEstimation
using DensityRatioEstimation: KLIEP, ConvexLib
using Convex
using ECOS

include("../src/kliep/convex.jl")

Expand Down
9 changes: 2 additions & 7 deletions ext/DensityRatioEstimationGPUArraysExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,8 @@

module DensityRatioEstimationGPUArraysExt

if isdefined(Base, :get_extension)
using DensityRatioEstimation
using GPUArrays
else
using ..DensityRatioEstimation
using ..GPUArrays
end
using DensityRatioEstimation
using GPUArrays
using LinearAlgebra

# Avoid `mat + a * I` with CUDA which involves scalar operations and is slow
Expand Down
24 changes: 7 additions & 17 deletions ext/DensityRatioEstimationJuMPExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,13 @@

module DensityRatioEstimationJuMPExt

if isdefined(Base, :get_extension)
using DensityRatioEstimation
using DensityRatioEstimation: LSIF, JuMPLib, AbstractKMM, uKMM, KMM
using DensityRatioEstimation.Parameters
using JuMP
using Ipopt
using LinearAlgebra
using Statistics
else
using ..DensityRatioEstimation
using ..DensityRatioEstimation: LSIF, JuMPLib, AbstractKMM, uKMM, KMM
using ..DensityRatioEstimation.Parameters
using ..JuMP
using ..Ipopt
using ..LinearAlgebra
using ..Statistics
end
using DensityRatioEstimation
using DensityRatioEstimation: LSIF, JuMPLib, AbstractKMM, uKMM, KMM
using DensityRatioEstimation.Parameters
using JuMP
using Ipopt
using LinearAlgebra
using Statistics

include("../src/kmm/jump.jl")
include("../src/lsif/jump.jl")
Expand Down
12 changes: 3 additions & 9 deletions ext/DensityRatioEstimationOptimExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,9 @@

module DensityRatioEstimationOptimExt

if isdefined(Base, :get_extension)
using DensityRatioEstimation
using DensityRatioEstimation: KLIEP, LSIF, OptimLib
using Optim
else
using ..DensityRatioEstimation
using ..DensityRatioEstimation: KLIEP, LSIF, OptimLib
using ..Optim
end
using DensityRatioEstimation
using DensityRatioEstimation: KLIEP, LSIF, OptimLib
using Optim

using LinearAlgebra

Expand Down
35 changes: 0 additions & 35 deletions src/DensityRatioEstimation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,41 +32,6 @@ include("lcv.jl")
# pure Julia implementations
include("kmm/julia.jl")

# implementations that require extra dependencies
if !isdefined(Base, :get_extension)
using Requires
end
@static if !isdefined(Base, :get_extension)
function __init__()
# 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
@require Optim = "429524aa-4258-5aef-a3af-852621145aeb" begin
include("../ext/DensityRatioEstimationOptimExt.jl")
end

# Convex: KLIEP
@require Convex = "f65535da-76fb-5f13-bab9-19810c17039a" begin
@require ECOS = "e2685f51-7e38-5353-a97d-a921fd2c8199" begin
include("../ext/DensityRatioEstimationConvexExt.jl")
end
end

# AD and GPU libs
@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
end
end

export
# optim libs
OptimizationLibrary,
Expand Down

0 comments on commit 29c4e8c

Please sign in to comment.