Skip to content

Commit

Permalink
Merge pull request #263 from JuliaArrays/multi-package
Browse files Browse the repository at this point in the history
Multi package (#211)
  • Loading branch information
ChrisRackauckas authored May 18, 2022
2 parents e74a7aa + 4b55e95 commit 4a42500
Show file tree
Hide file tree
Showing 57 changed files with 3,140 additions and 2,897 deletions.
23 changes: 23 additions & 0 deletions .ci/test.jl
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)
23 changes: 23 additions & 0 deletions .github/workflows/Documentation.yml
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
12 changes: 11 additions & 1 deletion .github/workflows/Downstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,16 @@ jobs:
with:
version: ${{ matrix.julia-version }}
arch: x64
- uses: julia-actions/julia-buildpkg@latest
- name: Setup ArrayInterface
shell: julia --color=yes
run: |
using Pkg
function dev_subpkg(subpkg)
subpkg_path = joinpath(".","ArrayInterface", "lib", subpkg)
Pkg.develop(Pkg.PackageSpec(path=subpkg_path))
end
dev_subpkg("ArrayInterfaceCore")
Pkg.build()
- name: Clone Downstream
uses: actions/checkout@v2
with:
Expand All @@ -47,6 +56,7 @@ jobs:
try
# force it to use this PR's version of the package
Pkg.develop(PackageSpec(path=".")) # resolver may fail with main deps
Pkg.update()
Pkg.test() # resolver may fail with test time deps
catch err
Expand Down
45 changes: 0 additions & 45 deletions .github/workflows/ci-julia-nightly.yml

This file was deleted.

47 changes: 14 additions & 33 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,28 @@ on:
push:
branches:
- master
tags: '*'
jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
group:
- ArrayInterfaceCore
- ArrayInterfaceBandedMatrices
- ArrayInterfaceBlockBandedMatrices
- ArrayInterfaceCUDA
- ArrayInterfaceOffsetArrays
- ArrayInterfaceStaticArrays
- ArrayInterfaceTracker
version:
- '1'
- '1.6'
- '1' # automatically expands to the latest stable 1.x release of Julia.
os:
- ubuntu-latest
- windows-latest
arch:
- x64
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v1
env:
cache-name: cache-artifacts
Expand All @@ -38,29 +38,10 @@ jobs:
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
- run: julia .ci/test.jl
env:
GROUP: ${{ matrix.group }}
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v1
with:
file: lcov.info
docs:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: julia-actions/setup-julia@latest
with:
version: '1.6'
- run: julia --color=yes -e 'using Pkg; VERSION >= v"1.5-" && !isdir(joinpath(DEPOT_PATH[1], "registries", "General")) && Pkg.Registry.add("General")'
shell: bash
env:
JULIA_PKG_SERVER: ""
- run: julia --project=docs -e '
using Pkg;
Pkg.develop(PackageSpec(; path=pwd()));
Pkg.instantiate();'
- run: julia --project=docs docs/make.jl
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
file: lcov.info
13 changes: 4 additions & 9 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,11 @@ uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
version = "5.0.8"

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

[compat]
Compat = "3.37"
IfElse = "0.1"
Requires = "0.5, 1.0"
ArrayInterfaceCore = "0.1"
Static = "0.6"
julia = "1.2"
julia = "1.6"

20 changes: 20 additions & 0 deletions lib/ArrayInterfaceBandedMatrices/Project.toml
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"]
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
20 changes: 20 additions & 0 deletions lib/ArrayInterfaceBandedMatrices/test/runtests.jl
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))

26 changes: 26 additions & 0 deletions lib/ArrayInterfaceBlockBandedMatrices/Project.toml
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"]
Loading

0 comments on commit 4a42500

Please sign in to comment.