Skip to content

Commit 4a42500

Browse files
Merge pull request #263 from JuliaArrays/multi-package
Multi package (#211)
2 parents e74a7aa + 4b55e95 commit 4a42500

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+3140
-2897
lines changed

.ci/test.jl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import Pkg
2+
3+
const GROUP = get(ENV, "GROUP", "All")
4+
5+
function dev_subpkg(subpkg)
6+
subpkg_path = joinpath(dirname(@__DIR__), "lib", subpkg)
7+
Pkg.develop(Pkg.PackageSpec(path=subpkg_path))
8+
end
9+
10+
function activate_subpkg_env(subpkg)
11+
subpkg_path = joinpath(dirname(@__DIR__), "lib", subpkg)
12+
Pkg.activate(subpkg_path)
13+
Pkg.develop(Pkg.PackageSpec(path=subpkg_path))
14+
Pkg.instantiate()
15+
end
16+
17+
Pkg.update()
18+
19+
# All packages need the core
20+
dev_subpkg("ArrayInterfaceCore")
21+
Pkg.develop("ArrayInterface")
22+
23+
Pkg.test("ArrayInterface"; coverage=true)

.github/workflows/Documentation.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Documentation
2+
on:
3+
push:
4+
branches:
5+
- master
6+
tags: '*'
7+
pull_request:
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
- uses: julia-actions/setup-julia@latest
15+
with:
16+
version: '1'
17+
- name: Install dependencies
18+
run: julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
19+
- name: Build and deploy
20+
env:
21+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # For authentication with GitHub Actions token
22+
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} # For authentication with SSH deploy key
23+
run: julia --project=docs/ docs/make.jl

.github/workflows/Downstream.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,16 @@ jobs:
3434
with:
3535
version: ${{ matrix.julia-version }}
3636
arch: x64
37-
- uses: julia-actions/julia-buildpkg@latest
37+
- name: Setup ArrayInterface
38+
shell: julia --color=yes
39+
run: |
40+
using Pkg
41+
function dev_subpkg(subpkg)
42+
subpkg_path = joinpath(".","ArrayInterface", "lib", subpkg)
43+
Pkg.develop(Pkg.PackageSpec(path=subpkg_path))
44+
end
45+
dev_subpkg("ArrayInterfaceCore")
46+
Pkg.build()
3847
- name: Clone Downstream
3948
uses: actions/checkout@v2
4049
with:
@@ -47,6 +56,7 @@ jobs:
4756
try
4857
# force it to use this PR's version of the package
4958
Pkg.develop(PackageSpec(path=".")) # resolver may fail with main deps
59+
5060
Pkg.update()
5161
Pkg.test() # resolver may fail with test time deps
5262
catch err

.github/workflows/ci-julia-nightly.yml

Lines changed: 0 additions & 45 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 14 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,28 @@ on:
66
push:
77
branches:
88
- master
9-
tags: '*'
109
jobs:
1110
test:
12-
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
13-
runs-on: ${{ matrix.os }}
11+
runs-on: ubuntu-latest
1412
strategy:
1513
fail-fast: false
1614
matrix:
15+
group:
16+
- ArrayInterfaceCore
17+
- ArrayInterfaceBandedMatrices
18+
- ArrayInterfaceBlockBandedMatrices
19+
- ArrayInterfaceCUDA
20+
- ArrayInterfaceOffsetArrays
21+
- ArrayInterfaceStaticArrays
22+
- ArrayInterfaceTracker
1723
version:
24+
- '1'
1825
- '1.6'
19-
- '1' # automatically expands to the latest stable 1.x release of Julia.
20-
os:
21-
- ubuntu-latest
22-
- windows-latest
23-
arch:
24-
- x64
2526
steps:
2627
- uses: actions/checkout@v2
2728
- uses: julia-actions/setup-julia@v1
2829
with:
2930
version: ${{ matrix.version }}
30-
arch: ${{ matrix.arch }}
3131
- uses: actions/cache@v1
3232
env:
3333
cache-name: cache-artifacts
@@ -38,29 +38,10 @@ jobs:
3838
${{ runner.os }}-test-${{ env.cache-name }}-
3939
${{ runner.os }}-test-
4040
${{ runner.os }}-
41-
- uses: julia-actions/julia-buildpkg@v1
42-
- uses: julia-actions/julia-runtest@v1
41+
- run: julia .ci/test.jl
42+
env:
43+
GROUP: ${{ matrix.group }}
4344
- uses: julia-actions/julia-processcoverage@v1
4445
- uses: codecov/codecov-action@v1
4546
with:
46-
file: lcov.info
47-
docs:
48-
name: Documentation
49-
runs-on: ubuntu-latest
50-
steps:
51-
- uses: actions/checkout@v1
52-
- uses: julia-actions/setup-julia@latest
53-
with:
54-
version: '1.6'
55-
- run: julia --color=yes -e 'using Pkg; VERSION >= v"1.5-" && !isdir(joinpath(DEPOT_PATH[1], "registries", "General")) && Pkg.Registry.add("General")'
56-
shell: bash
57-
env:
58-
JULIA_PKG_SERVER: ""
59-
- run: julia --project=docs -e '
60-
using Pkg;
61-
Pkg.develop(PackageSpec(; path=pwd()));
62-
Pkg.instantiate();'
63-
- run: julia --project=docs docs/make.jl
64-
env:
65-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66-
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
47+
file: lcov.info

Project.toml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,11 @@ uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
33
version = "5.0.8"
44

55
[deps]
6-
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"
7-
IfElse = "615f187c-cbe4-4ef1-ba3b-2fcf58d6d173"
8-
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
9-
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
10-
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
6+
ArrayInterfaceCore = "30b0a656-2188-435a-8636-2ec0e6a096e2"
117
Static = "aedffcd0-7271-4cad-89d0-dc628f76c6d3"
128

139
[compat]
14-
Compat = "3.37"
15-
IfElse = "0.1"
16-
Requires = "0.5, 1.0"
10+
ArrayInterfaceCore = "0.1"
1711
Static = "0.6"
18-
julia = "1.2"
12+
julia = "1.6"
13+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name = "ArrayInterfaceBandedMatrices"
2+
uuid = "2e50d22c-5be1-4042-81b1-c572ed69783d"
3+
version = "0.1.0"
4+
5+
[deps]
6+
ArrayInterfaceCore = "30b0a656-2188-435a-8636-2ec0e6a096e2"
7+
BandedMatrices = "aae01518-5342-5314-be14-df237901396f"
8+
9+
[compat]
10+
ArrayInterfaceCore = "0.1"
11+
BandedMatrices = "0.17"
12+
julia = "1.6"
13+
14+
[extras]
15+
ArrayInterfaceCore = "30b0a656-2188-435a-8636-2ec0e6a096e2"
16+
BandedMatrices = "aae01518-5342-5314-be14-df237901396f"
17+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
18+
19+
[targets]
20+
test = ["ArrayInterfaceCore","BandedMatrices","Test"]
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
module ArrayInterfaceBandedMatrices
2+
3+
using ArrayInterfaceCore
4+
using BandedMatrices
5+
6+
struct BandedMatrixIndex <: ArrayInterfaceCore.MatrixIndex
7+
count::Int
8+
rowsize::Int
9+
colsize::Int
10+
bandinds::Array{Int,1}
11+
bandsizes::Array{Int,1}
12+
isrow::Bool
13+
end
14+
15+
Base.firstindex(i::BandedMatrixIndex) = 1
16+
Base.lastindex(i::BandedMatrixIndex) = i.count
17+
Base.length(i::BandedMatrixIndex) = lastindex(i)
18+
Base.@propagate_inbounds function Base.getindex(ind::BandedMatrixIndex, i::Int)
19+
@boundscheck 1 <= i <= ind.count || throw(BoundsError(ind, i))
20+
_i = i
21+
p = 1
22+
while _i - ind.bandsizes[p] > 0
23+
_i -= ind.bandsizes[p]
24+
p += 1
25+
end
26+
bandind = ind.bandinds[p]
27+
startfromone = !xor(ind.isrow, (bandind > 0))
28+
if startfromone
29+
return _i
30+
else
31+
return _i + abs(bandind)
32+
end
33+
end
34+
35+
function _bandsize(bandind, rowsize, colsize)
36+
-(rowsize - 1) <= bandind <= colsize - 1 || throw(ErrorException("Invalid Bandind"))
37+
if (bandind * (colsize - rowsize) > 0) & (abs(bandind) <= abs(colsize - rowsize))
38+
return min(rowsize, colsize)
39+
elseif bandind * (colsize - rowsize) <= 0
40+
return min(rowsize, colsize) - abs(bandind)
41+
else
42+
return min(rowsize, colsize) - abs(bandind) + abs(colsize - rowsize)
43+
end
44+
end
45+
46+
function BandedMatrixIndex(rowsize, colsize, lowerbandwidth, upperbandwidth, isrow)
47+
upperbandwidth > -lowerbandwidth || throw(ErrorException("Invalid Bandwidths"))
48+
bandinds = upperbandwidth:-1:-lowerbandwidth
49+
bandsizes = [_bandsize(band, rowsize, colsize) for band in bandinds]
50+
BandedMatrixIndex(sum(bandsizes), rowsize, colsize, bandinds, bandsizes, isrow)
51+
end
52+
53+
function ArrayInterfaceCore.findstructralnz(x::BandedMatrices.BandedMatrix)
54+
l, u = BandedMatrices.bandwidths(x)
55+
rowsize, colsize = Base.size(x)
56+
rowind = BandedMatrixIndex(rowsize, colsize, l, u, true)
57+
colind = BandedMatrixIndex(rowsize, colsize, l, u, false)
58+
return (rowind, colind)
59+
end
60+
61+
ArrayInterfaceCore.has_sparsestruct(::Type{<:BandedMatrices.BandedMatrix}) = true
62+
ArrayInterfaceCore.isstructured(::Type{<:BandedMatrices.BandedMatrix}) = true
63+
ArrayInterfaceCore.fast_matrix_colors(::Type{<:BandedMatrices.BandedMatrix}) = true
64+
65+
function ArrayInterfaceCore.matrix_colors(A::BandedMatrices.BandedMatrix)
66+
l, u = BandedMatrices.bandwidths(A)
67+
width = u + l + 1
68+
return _cycle(1:width, Base.size(A, 2))
69+
end
70+
71+
end # module
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
using ArrayInterfaceCore
3+
using ArrayInterfaceBandedMatrices
4+
using BandedMatrices
5+
using Test
6+
7+
B=BandedMatrix(Ones(5,5), (-1,2))
8+
B[band(1)].=[1,2,3,4]
9+
B[band(2)].=[5,6,7]
10+
@test ArrayInterfaceCore.has_sparsestruct(B)
11+
rowind,colind=ArrayInterfaceCore.findstructralnz(B)
12+
@test [B[rowind[i],colind[i]] for i in 1:length(rowind)]==[5,6,7,1,2,3,4]
13+
B=BandedMatrix(Ones(4,6), (-1,2))
14+
B[band(1)].=[1,2,3,4]
15+
B[band(2)].=[5,6,7,8]
16+
rowind,colind=ArrayInterfaceCore.findstructralnz(B)
17+
@test [B[rowind[i],colind[i]] for i in 1:length(rowind)]==[5,6,7,8,1,2,3,4]
18+
@test ArrayInterfaceCore.isstructured(typeof(B))
19+
@test ArrayInterfaceCore.fast_matrix_colors(typeof(B))
20+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name = "ArrayInterfaceBlockBandedMatrices"
2+
uuid = "5331f1e9-51c7-46b0-a9b0-df4434785e0a"
3+
authors = ["Zachary P. Christensen <[email protected]>"]
4+
version = "0.1.0"
5+
6+
[deps]
7+
ArrayInterfaceCore = "30b0a656-2188-435a-8636-2ec0e6a096e2"
8+
ArrayInterfaceBandedMatrices = "2e50d22c-5be1-4042-81b1-c572ed69783d"
9+
BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
10+
BlockBandedMatrices = "ffab5731-97b5-5995-9138-79e8c1846df0"
11+
12+
[compat]
13+
ArrayInterfaceCore = "0.1"
14+
ArrayInterfaceBandedMatrices = "0.1"
15+
BlockBandedMatrices = "0.11"
16+
BlockArrays = "0.16"
17+
julia = "1.6"
18+
19+
[extras]
20+
ArrayInterfaceCore = "30b0a656-2188-435a-8636-2ec0e6a096e2"
21+
BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
22+
BlockBandedMatrices = "ffab5731-97b5-5995-9138-79e8c1846df0"
23+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
24+
25+
[targets]
26+
test = ["ArrayInterfaceCore","BlockArrays","BlockBandedMatrices","Test"]

0 commit comments

Comments
 (0)