-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #263 from JuliaArrays/multi-package
Multi package (#211)
- Loading branch information
Showing
57 changed files
with
3,140 additions
and
2,897 deletions.
There are no files selected for viewing
This file contains 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,23 @@ | ||
import Pkg | ||
|
||
const GROUP = get(ENV, "GROUP", "All") | ||
|
||
function dev_subpkg(subpkg) | ||
subpkg_path = joinpath(dirname(@__DIR__), "lib", subpkg) | ||
Pkg.develop(Pkg.PackageSpec(path=subpkg_path)) | ||
end | ||
|
||
function activate_subpkg_env(subpkg) | ||
subpkg_path = joinpath(dirname(@__DIR__), "lib", subpkg) | ||
Pkg.activate(subpkg_path) | ||
Pkg.develop(Pkg.PackageSpec(path=subpkg_path)) | ||
Pkg.instantiate() | ||
end | ||
|
||
Pkg.update() | ||
|
||
# All packages need the core | ||
dev_subpkg("ArrayInterfaceCore") | ||
Pkg.develop("ArrayInterface") | ||
|
||
Pkg.test("ArrayInterface"; coverage=true) |
This file contains 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,23 @@ | ||
name: Documentation | ||
on: | ||
push: | ||
branches: | ||
- master | ||
tags: '*' | ||
pull_request: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: julia-actions/setup-julia@latest | ||
with: | ||
version: '1' | ||
- name: Install dependencies | ||
run: julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()' | ||
- name: Build and deploy | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # For authentication with GitHub Actions token | ||
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} # For authentication with SSH deploy key | ||
run: julia --project=docs/ docs/make.jl |
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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,20 @@ | ||
name = "ArrayInterfaceBandedMatrices" | ||
uuid = "2e50d22c-5be1-4042-81b1-c572ed69783d" | ||
version = "0.1.0" | ||
|
||
[deps] | ||
ArrayInterfaceCore = "30b0a656-2188-435a-8636-2ec0e6a096e2" | ||
BandedMatrices = "aae01518-5342-5314-be14-df237901396f" | ||
|
||
[compat] | ||
ArrayInterfaceCore = "0.1" | ||
BandedMatrices = "0.17" | ||
julia = "1.6" | ||
|
||
[extras] | ||
ArrayInterfaceCore = "30b0a656-2188-435a-8636-2ec0e6a096e2" | ||
BandedMatrices = "aae01518-5342-5314-be14-df237901396f" | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
|
||
[targets] | ||
test = ["ArrayInterfaceCore","BandedMatrices","Test"] |
71 changes: 71 additions & 0 deletions
71
lib/ArrayInterfaceBandedMatrices/src/ArrayInterfaceBandedMatrices.jl
This file contains 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,71 @@ | ||
module ArrayInterfaceBandedMatrices | ||
|
||
using ArrayInterfaceCore | ||
using BandedMatrices | ||
|
||
struct BandedMatrixIndex <: ArrayInterfaceCore.MatrixIndex | ||
count::Int | ||
rowsize::Int | ||
colsize::Int | ||
bandinds::Array{Int,1} | ||
bandsizes::Array{Int,1} | ||
isrow::Bool | ||
end | ||
|
||
Base.firstindex(i::BandedMatrixIndex) = 1 | ||
Base.lastindex(i::BandedMatrixIndex) = i.count | ||
Base.length(i::BandedMatrixIndex) = lastindex(i) | ||
Base.@propagate_inbounds function Base.getindex(ind::BandedMatrixIndex, i::Int) | ||
@boundscheck 1 <= i <= ind.count || throw(BoundsError(ind, i)) | ||
_i = i | ||
p = 1 | ||
while _i - ind.bandsizes[p] > 0 | ||
_i -= ind.bandsizes[p] | ||
p += 1 | ||
end | ||
bandind = ind.bandinds[p] | ||
startfromone = !xor(ind.isrow, (bandind > 0)) | ||
if startfromone | ||
return _i | ||
else | ||
return _i + abs(bandind) | ||
end | ||
end | ||
|
||
function _bandsize(bandind, rowsize, colsize) | ||
-(rowsize - 1) <= bandind <= colsize - 1 || throw(ErrorException("Invalid Bandind")) | ||
if (bandind * (colsize - rowsize) > 0) & (abs(bandind) <= abs(colsize - rowsize)) | ||
return min(rowsize, colsize) | ||
elseif bandind * (colsize - rowsize) <= 0 | ||
return min(rowsize, colsize) - abs(bandind) | ||
else | ||
return min(rowsize, colsize) - abs(bandind) + abs(colsize - rowsize) | ||
end | ||
end | ||
|
||
function BandedMatrixIndex(rowsize, colsize, lowerbandwidth, upperbandwidth, isrow) | ||
upperbandwidth > -lowerbandwidth || throw(ErrorException("Invalid Bandwidths")) | ||
bandinds = upperbandwidth:-1:-lowerbandwidth | ||
bandsizes = [_bandsize(band, rowsize, colsize) for band in bandinds] | ||
BandedMatrixIndex(sum(bandsizes), rowsize, colsize, bandinds, bandsizes, isrow) | ||
end | ||
|
||
function ArrayInterfaceCore.findstructralnz(x::BandedMatrices.BandedMatrix) | ||
l, u = BandedMatrices.bandwidths(x) | ||
rowsize, colsize = Base.size(x) | ||
rowind = BandedMatrixIndex(rowsize, colsize, l, u, true) | ||
colind = BandedMatrixIndex(rowsize, colsize, l, u, false) | ||
return (rowind, colind) | ||
end | ||
|
||
ArrayInterfaceCore.has_sparsestruct(::Type{<:BandedMatrices.BandedMatrix}) = true | ||
ArrayInterfaceCore.isstructured(::Type{<:BandedMatrices.BandedMatrix}) = true | ||
ArrayInterfaceCore.fast_matrix_colors(::Type{<:BandedMatrices.BandedMatrix}) = true | ||
|
||
function ArrayInterfaceCore.matrix_colors(A::BandedMatrices.BandedMatrix) | ||
l, u = BandedMatrices.bandwidths(A) | ||
width = u + l + 1 | ||
return _cycle(1:width, Base.size(A, 2)) | ||
end | ||
|
||
end # module |
This file contains 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,20 @@ | ||
|
||
using ArrayInterfaceCore | ||
using ArrayInterfaceBandedMatrices | ||
using BandedMatrices | ||
using Test | ||
|
||
B=BandedMatrix(Ones(5,5), (-1,2)) | ||
B[band(1)].=[1,2,3,4] | ||
B[band(2)].=[5,6,7] | ||
@test ArrayInterfaceCore.has_sparsestruct(B) | ||
rowind,colind=ArrayInterfaceCore.findstructralnz(B) | ||
@test [B[rowind[i],colind[i]] for i in 1:length(rowind)]==[5,6,7,1,2,3,4] | ||
B=BandedMatrix(Ones(4,6), (-1,2)) | ||
B[band(1)].=[1,2,3,4] | ||
B[band(2)].=[5,6,7,8] | ||
rowind,colind=ArrayInterfaceCore.findstructralnz(B) | ||
@test [B[rowind[i],colind[i]] for i in 1:length(rowind)]==[5,6,7,8,1,2,3,4] | ||
@test ArrayInterfaceCore.isstructured(typeof(B)) | ||
@test ArrayInterfaceCore.fast_matrix_colors(typeof(B)) | ||
|
This file contains 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,26 @@ | ||
name = "ArrayInterfaceBlockBandedMatrices" | ||
uuid = "5331f1e9-51c7-46b0-a9b0-df4434785e0a" | ||
authors = ["Zachary P. Christensen <[email protected]>"] | ||
version = "0.1.0" | ||
|
||
[deps] | ||
ArrayInterfaceCore = "30b0a656-2188-435a-8636-2ec0e6a096e2" | ||
ArrayInterfaceBandedMatrices = "2e50d22c-5be1-4042-81b1-c572ed69783d" | ||
BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e" | ||
BlockBandedMatrices = "ffab5731-97b5-5995-9138-79e8c1846df0" | ||
|
||
[compat] | ||
ArrayInterfaceCore = "0.1" | ||
ArrayInterfaceBandedMatrices = "0.1" | ||
BlockBandedMatrices = "0.11" | ||
BlockArrays = "0.16" | ||
julia = "1.6" | ||
|
||
[extras] | ||
ArrayInterfaceCore = "30b0a656-2188-435a-8636-2ec0e6a096e2" | ||
BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e" | ||
BlockBandedMatrices = "ffab5731-97b5-5995-9138-79e8c1846df0" | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
|
||
[targets] | ||
test = ["ArrayInterfaceCore","BlockArrays","BlockBandedMatrices","Test"] |
Oops, something went wrong.