From efddd1f6b38292830f451495c93e7b892ddb1a7a Mon Sep 17 00:00:00 2001 From: Alex Arslan Date: Sat, 9 Jul 2022 12:05:15 -0700 Subject: [PATCH 1/4] Don't rely on `Base.promote_op` Its docstring explicitly says not to. Instead we can query the type of the result of the operation on values of the given type. --- src/cox.jl | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/cox.jl b/src/cox.jl index 5c08e16..f098d83 100644 --- a/src/cox.jl +++ b/src/cox.jl @@ -1,6 +1,6 @@ # Some utility functions to compute Cox regression -promote_nonmissing(::Type{T}) where {T} = Base.promote_op(/, T, T) +promote_nonmissing(::Type{T}) where {T} = typeof(one(T) / one(T)) promote_nonmissing(::Type{Union{T,Missing}}) where {T} = promote_nonmissing(T) struct CoxSum{T,N} @@ -132,8 +132,7 @@ function _cox_fgh!(β, grad, hes, c::CoxAux{T}) where T update_cox!(c, β, (hes !== nothing) | (grad !== nothing)) X, ξ, Xβ, θ, Xθ, ξθ, λ, fs, ls = c.X, c.ξ, c.Xβ, c.θ, c.Xθ, c.ξθ, c.λ, c.fs, c.ls - R = Base.promote_op(/, T, T) - y = zero(R) + y = zero(T) / one(T) if hes !== nothing fill!(hes, 0) @@ -143,7 +142,7 @@ function _cox_fgh!(β, grad, hes, c::CoxAux{T}) where T end if grad !== nothing || hes !== nothing # preallocate - Z = zeros(R, length(β)) + Z = zeros(typeof(y), length(β)) end @inbounds for i in 1:length(fs) From fa54e407bdb7343278167eb94e926b1740da1736 Mon Sep 17 00:00:00 2001 From: Alex Arslan Date: Sat, 9 Jul 2022 13:50:55 -0700 Subject: [PATCH 2/4] Remove unused dependency on PositiveFactorizations The switch to Optim from hand-rolled Newton-Raphson removed the only use of this package. --- Project.toml | 2 -- src/Survival.jl | 1 - 2 files changed, 3 deletions(-) diff --git a/Project.toml b/Project.toml index e4f6f9b..6ba2afb 100644 --- a/Project.toml +++ b/Project.toml @@ -6,7 +6,6 @@ version = "0.2.2" Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" Optim = "429524aa-4258-5aef-a3af-852621145aeb" -PositiveFactorizations = "85a6dd25-e78a-55b7-8502-1745935b8125" StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" StatsModels = "3eaba693-59b7-5ba5-a881-562e759f1c8d" @@ -15,7 +14,6 @@ CategoricalArrays = "0.9" DataFrames = "1" Distributions = "0.20, 0.21, 0.22, 0.23, 0.24, 0.25" Optim = "1" -PositiveFactorizations = "0.2" StatsBase = "0.30, 0.31, 0.32, 0.33" StatsModels = "0.6" julia = "1.2" diff --git a/src/Survival.jl b/src/Survival.jl index f3d1813..db7353f 100644 --- a/src/Survival.jl +++ b/src/Survival.jl @@ -2,7 +2,6 @@ module Survival using Distributions using LinearAlgebra -using PositiveFactorizations using StatsBase using StatsModels using Optim From fce52ed07029ac00059b680b1b52e0d04b1ec98c Mon Sep 17 00:00:00 2001 From: Alex Arslan Date: Sat, 9 Jul 2022 14:03:56 -0700 Subject: [PATCH 3/4] Use property destructuring with Compat We have a transitive dependency on Compat anyway and this simplifies exactly one line of code so might as well. --- Project.toml | 2 ++ src/Survival.jl | 3 ++- src/cox.jl | 3 +-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Project.toml b/Project.toml index 6ba2afb..d4725bf 100644 --- a/Project.toml +++ b/Project.toml @@ -3,6 +3,7 @@ uuid = "8a913413-2070-5976-9d4c-2b364fdc2f7f" version = "0.2.2" [deps] +Compat = "34da2185-b29b-5c13-b0c7-acf172513d20" Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" Optim = "429524aa-4258-5aef-a3af-852621145aeb" @@ -11,6 +12,7 @@ StatsModels = "3eaba693-59b7-5ba5-a881-562e759f1c8d" [compat] CategoricalArrays = "0.9" +Compat = "3.43, 4" DataFrames = "1" Distributions = "0.20, 0.21, 0.22, 0.23, 0.24, 0.25" Optim = "1" diff --git a/src/Survival.jl b/src/Survival.jl index db7353f..0f1f948 100644 --- a/src/Survival.jl +++ b/src/Survival.jl @@ -1,10 +1,11 @@ module Survival +using Compat using Distributions using LinearAlgebra +using Optim using StatsBase using StatsModels -using Optim export EventTime, diff --git a/src/cox.jl b/src/cox.jl index f098d83..a43eb34 100644 --- a/src/cox.jl +++ b/src/cox.jl @@ -130,8 +130,7 @@ end function _cox_fgh!(β, grad, hes, c::CoxAux{T}) where T update_cox!(c, β, (hes !== nothing) | (grad !== nothing)) - X, ξ, Xβ, θ, Xθ, ξθ, λ, fs, ls = - c.X, c.ξ, c.Xβ, c.θ, c.Xθ, c.ξθ, c.λ, c.fs, c.ls + @compat (; X, ξ, Xβ, θ, Xθ, ξθ, λ, fs, ls) = c y = zero(T) / one(T) if hes !== nothing From 84e296416caea45dd5c71a45d83bc81e825dbf31 Mon Sep 17 00:00:00 2001 From: Alex Arslan Date: Sat, 9 Jul 2022 14:23:01 -0700 Subject: [PATCH 4/4] Require Julia 1.6, modernize CI, allow CategoricalArrays 0.10 Currently we require Julia 1.2 but 1.6 is current LTS so we might as well bump to that. --- .github/workflows/CI.yml | 27 ++++++--------------------- Project.toml | 4 ++-- 2 files changed, 8 insertions(+), 23 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index a056b43..22af39f 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -1,12 +1,9 @@ name: CI on: - pull_request: - branches: - - master push: - branches: - - master - tags: '*' + branches: [master] + tags: ["*"] + pull_request: jobs: test: name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} @@ -15,7 +12,7 @@ jobs: fail-fast: false matrix: version: - - '1.2' + - '1.6' - '1' - 'nightly' os: @@ -49,20 +46,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: julia-actions/setup-julia@v1 - with: - version: '1' - - run: | - julia --project=docs -e ' - using Pkg - Pkg.develop(PackageSpec(path=pwd())) - Pkg.instantiate()' - - run: | - julia --project=docs -e ' - using Documenter: doctest - using Survival - doctest(Survival)' - - run: julia --project=docs docs/make.jl + - uses: julia-actions/julia-buildpkg@latest + - uses: julia-actions/julia-docdeploy@latest env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} diff --git a/Project.toml b/Project.toml index d4725bf..062ac55 100644 --- a/Project.toml +++ b/Project.toml @@ -11,14 +11,14 @@ StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" StatsModels = "3eaba693-59b7-5ba5-a881-562e759f1c8d" [compat] -CategoricalArrays = "0.9" +CategoricalArrays = "0.9, 0.10" Compat = "3.43, 4" DataFrames = "1" Distributions = "0.20, 0.21, 0.22, 0.23, 0.24, 0.25" Optim = "1" StatsBase = "0.30, 0.31, 0.32, 0.33" StatsModels = "0.6" -julia = "1.2" +julia = "1.6" [extras] CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"