-
Notifications
You must be signed in to change notification settings - Fork 39
Add extension for PDMats #303
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
259fa24
Add extension for PDMats
devmotion 8d6f033
Fix typo
devmotion d5dada1
Merge branch 'master' into dw/pdmats
devmotion e661a20
Make PDMats a dependency on Julia < 1.9
devmotion 853e5ae
Revert changes to Aqua tests
devmotion 4380a97
Fix imports
devmotion File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,33 +1,39 @@ | ||
| name = "FillArrays" | ||
| uuid = "1a297f60-69ca-5386-bcde-b61e274b549b" | ||
| version = "1.7.0" | ||
| version = "1.8.0" | ||
|
|
||
| [deps] | ||
| LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" | ||
| Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" | ||
| Requires = "ae029012-a4dd-5104-9daa-d747884805df" | ||
| SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" | ||
| Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" | ||
|
|
||
| [weakdeps] | ||
| PDMats = "90014a1f-27ba-587c-ab20-58faa44d9150" | ||
| SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" | ||
| Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" | ||
|
|
||
| [extensions] | ||
| FillArraysPDMatsExt = "PDMats" | ||
| FillArraysSparseArraysExt = "SparseArrays" | ||
| FillArraysStatisticsExt = "Statistics" | ||
|
|
||
| [compat] | ||
| Aqua = "0.5, 0.6, 0.7" | ||
| PDMats = "0.11.17" | ||
| Requires = "1" | ||
| julia = "1.6" | ||
|
|
||
| [extras] | ||
| Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" | ||
| Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" | ||
| PDMats = "90014a1f-27ba-587c-ab20-58faa44d9150" | ||
| ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267" | ||
| SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" | ||
| StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" | ||
| Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" | ||
| Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
|
|
||
| [targets] | ||
| test = ["Aqua", "Test", "Base64", "ReverseDiff", "SparseArrays", "StaticArrays", "Statistics"] | ||
| test = ["Aqua", "Test", "Base64", "PDMats", "ReverseDiff", "SparseArrays", "StaticArrays", "Statistics"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| module FillArraysPDMatsExt | ||
|
|
||
| if isdefined(Base, :get_extension) | ||
| import FillArrays | ||
| import FillArrays.LinearAlgebra | ||
| import PDMats | ||
| else | ||
| import ..FillArrays | ||
| import ..FillArrays.LinearAlgebra | ||
| import ..PDMats | ||
| end | ||
|
|
||
| function PDMats.AbstractPDMat(a::LinearAlgebra.Diagonal{T,<:FillArrays.AbstractFill{T,1}}) where {T<:Real} | ||
| dim = size(a, 1) | ||
| return PDMats.ScalMat(dim, FillArrays.getindex_value(a.diag)) | ||
| end | ||
|
|
||
| end # module | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -669,10 +669,18 @@ include("fillalgebra.jl") | |
| include("fillbroadcast.jl") | ||
| include("trues.jl") | ||
|
|
||
| @static if !isdefined(Base, :get_extension) | ||
| if !isdefined(Base, :get_extension) | ||
| import Requires | ||
| include("../ext/FillArraysSparseArraysExt.jl") | ||
| include("../ext/FillArraysStatisticsExt.jl") | ||
| end | ||
| @static if !isdefined(Base, :get_extension) | ||
| function __init__() | ||
| Requires.@require PDMats = "90014a1f-27ba-587c-ab20-58faa44d9150" begin | ||
| include("../ext/FillArraysPDMatsExt.jl") | ||
|
||
| end | ||
| end | ||
| end | ||
|
|
||
| ## | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This style seems a bit unusual to me. Would it not be possible to import the packages directly, or is the namespace specification necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The branch is necessary, Requires needs relative imports (as shown also in the docs: https://github.com/JuliaPackaging/Requires.jl and https://pkgdocs.julialang.org/v1/creating-packages/#Requires.jl).
Moreover, in an extension one should import only the package itself and its weak dependency, and even stdlibs should be loaded indirectly: JuliaStats/LogExpFunctions.jl#63
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, interesting, I had no idea about this transitive loading issue. Looks fine to me then