Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FillArrays extension & bump Julia compat to >=1.6 #184

Closed
wants to merge 8 commits into from

Conversation

devmotion
Copy link
Member

@devmotion devmotion commented Sep 26, 2023

This PR adds FillArrays as a weak dependency on Julia >= 1.9 and as a proper dependency on Julia < 1.9 (the latter might not be completely desirable, see #182 (comment), and alternatives would be to use Requires or reduce features on older Julia versions).

Currently, the only method in the extension is a definition of AbstractPDMat for Diagonal matrices with an FillArray as diagonal. This is motivated by the constructors of MvNormal in Distributions in https://github.com/JuliaStats/Distributions.jl/blob/87aebc29b2b9608801b70aae09fbc1d2dad56e3f/src/multivariate/mvnormal.jl#L201-L210: With the definition in this PR they could be simplified to

MvNormal::AbstractVector{<:Real}, Σ::AbstractMatrix{<:Real}) = MvNormal(μ, AbstractPDMat(Σ))
MvNormal::AbstractVector{<:Real}, Σ::UniformScaling{<:Real}) =
    MvNormal(μ, ScalMat(length(μ), Σ.λ))

This pattern is more generally useful, I imagine: Downstream packages that deal with pd matrices could be encouraged to use AbstractPDMat(...) for converting user-provided matrices to an optimized representation. The PR here adds such optimizations also for Diagonal with FillArrays as diagonal.

Edit: I dropped support for Julia < 1.6 in the PR. Tests were failing on Julia 1.0, even after adding compat with FillArrays 0.x - IIRC Pkg does not resolve again the package dependencies in the tests which caused issues due to incompatibilities between FillArrays and BandedMatrices.

@codecov-commenter
Copy link

codecov-commenter commented Sep 26, 2023

Codecov Report

All modified lines are covered by tests ✅

Files Coverage Δ
ext/PDMatsFillArraysExt.jl 100.00% <100.00%> (ø)
src/PDMats.jl 100.00% <ø> (ø)
src/scalmat.jl 97.33% <100.00%> (ø)
src/utils.jl 94.73% <ø> (+3.07%) ⬆️

📢 Thoughts on this report? Let us know!.

@devmotion devmotion changed the title Add FillArrays extension Add FillArrays extension & bump Julia compat to >=1.6 Sep 26, 2023
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
SuiteSparse = "4607b0f0-06f3-5cda-b6b1-a6196a1729e9"

[compat]
julia = "1"
FillArrays = "1"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, we could not support this feature on Julia < 1.9. But generally I don't like these inconsistencies.

@devmotion
Copy link
Member Author

Closed in favour of #192.

@devmotion devmotion closed this Oct 17, 2023
@devmotion devmotion deleted the dw/fillarrays_ext branch October 17, 2023 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants