Skip to content

Commit 3df2e8d

Browse files
add CI and docs deployment (#1)
* add CI and docs deployment * All the linalg tests are moved to SuiteSparse.jl JuliaSparse/SuiteSparse.jl#53 * Disable the ambiguity tests for the moment. Co-authored-by: Viral B. Shah <viral@mayin.org>
1 parent c6b613c commit 3df2e8d

File tree

8 files changed

+142
-191
lines changed

8 files changed

+142
-191
lines changed

.ci/test_and_change_uuid.jl

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
@static if Base.VERSION >= v"1.6"
2+
using TOML
3+
using Test
4+
else
5+
using Pkg: TOML
6+
using Test
7+
end
8+
9+
# To generate the new UUID, we simply modify the first character of the original UUID
10+
const original_uuid = "3f01184e-e22b-5df5-ae63-d93ebab69eaf"
11+
const new_uuid = "4f01184e-e22b-5df5-ae63-d93ebab69eaf"
12+
13+
# `@__DIR__` is the `.ci/` folder.
14+
# Therefore, `dirname(@__DIR__)` is the repository root.
15+
const project_filename = joinpath(dirname(@__DIR__), "Project.toml")
16+
17+
@testset "Test that the UUID is unchanged" begin
18+
project_dict = TOML.parsefile(project_filename)
19+
@test project_dict["uuid"] == original_uuid
20+
end
21+
22+
write(
23+
project_filename,
24+
replace(
25+
read(project_filename, String),
26+
r"uuid = .*?\n" => "uuid = \"$(new_uuid)\"\n",
27+
),
28+
)

.github/workflows/ci.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: CI
2+
on:
3+
pull_request:
4+
branches:
5+
- 'main'
6+
- 'release-*'
7+
push:
8+
branches:
9+
- 'main'
10+
- 'release-*'
11+
tags: '*'
12+
jobs:
13+
test:
14+
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
version:
20+
# - '1.6'
21+
- 'nightly'
22+
os:
23+
- ubuntu-latest
24+
- macOS-latest
25+
- windows-latest
26+
arch:
27+
- x64
28+
- x86
29+
exclude:
30+
- os: macOS-latest
31+
arch: x86
32+
steps:
33+
- uses: actions/checkout@v2
34+
- uses: julia-actions/setup-julia@v1
35+
with:
36+
version: ${{ matrix.version }}
37+
arch: ${{ matrix.arch }}
38+
- uses: actions/cache@v1
39+
env:
40+
cache-name: cache-artifacts
41+
with:
42+
path: ~/.julia/artifacts
43+
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
44+
restore-keys: |
45+
${{ runner.os }}-test-${{ env.cache-name }}-
46+
${{ runner.os }}-test-${{ matrix.os }}
47+
${{ runner.os }}-
48+
- run: julia --color=yes .ci/test_and_change_uuid.jl
49+
- uses: julia-actions/julia-buildpkg@v1
50+
- uses: julia-actions/julia-runtest@v1
51+
- uses: julia-actions/julia-processcoverage@v1
52+
- uses: codecov/codecov-action@v1
53+
with:
54+
file: lcov.info
55+
docs:
56+
runs-on: ubuntu-latest
57+
steps:
58+
- uses: actions/checkout@v1.0.0
59+
- uses: julia-actions/setup-julia@latest
60+
with:
61+
# version: '1.6'
62+
version: 'nightly'
63+
- name: Generate docs
64+
run: |
65+
julia --color=yes -e 'write("Project.toml", replace(read("Project.toml", String), r"uuid = .*?\n" =>"uuid = \"3f01184e-e22b-5df5-ae63-d93ebab69eaf\"\n"));'
66+
julia --project --color=yes -e 'using Pkg; Pkg.activate("docs"); Pkg.instantiate(); Pkg.develop(PackageSpec(path = pwd()))'
67+
julia --project=docs --color=yes docs/make.jl pdf
68+
env:
69+
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name = "SparseArrays"
2-
uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
2+
uuid = "3f01184e-e22b-5df5-ae63-d93ebab69eaf"
33

44
[deps]
55
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# SparseArrays
2+
3+
| **Documentation** | **Build Status** |
4+
|:-----------------------------------------------------------------:|:-----------------------------------------------------------------------------------------------:|
5+
| [![][docs-img]][docs-url] | [![][ci-img]][ci-url] [![][codecov-img]][codecov-url] |
6+
7+
[docs-img]: https://img.shields.io/badge/docs-blue.svg
8+
[docs-url]: https://sparsearrays.juliasparse.org/dev/
9+
10+
[docs-v1-img]: https://img.shields.io/badge/docs-v1-blue.svg
11+
[docs-v1-url]: https://sparsearrays.juliasparse.org/v1/
12+
13+
[ci-img]: https://github.com/JuliaLang/sparsearrays.jl/workflows/Run%20tests/badge.svg?branch=master
14+
[ci-url]: https://github.com/JuliaLang/sparsearrays.jl/actions?query=workflow%3A%22Run+tests%22
15+
16+
[codecov-img]: https://codecov.io/gh/JuliaLang/sparsearrays.jl/branch/master/graph/badge.svg
17+
[codecov-url]: https://codecov.io/gh/JuliaLang/sparsearrays.jl
18+
19+
This package ships as part of the Julia stdlib.
20+
21+
SparseArrays.jl provides functionality for working with sparse arrays in Julia.
22+

docs/Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[deps]
2+
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"

docs/make.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using Documenter, SparseArrays
2+
3+
makedocs(
4+
modules = [SparseArrays],
5+
sitename = "SparseArrays",
6+
pages = Any[
7+
"SparseArrays" => "index.md"
8+
]
9+
)
10+
11+
deploydocs(repo = "github.com/JuliaLang/SparseArrays.jl.git")
File renamed without changes.

test/sparse.jl

Lines changed: 9 additions & 190 deletions
Original file line numberDiff line numberDiff line change
@@ -273,119 +273,6 @@ end
273273
@test B*A B*Array(A)
274274
end
275275

276-
@testset "complex matrix-vector multiplication and left-division" begin
277-
if Base.USE_GPL_LIBS
278-
for i = 1:5
279-
a = I + 0.1*sprandn(5, 5, 0.2)
280-
b = randn(5,3) + im*randn(5,3)
281-
c = randn(5) + im*randn(5)
282-
d = randn(5) + im*randn(5)
283-
α = rand(ComplexF64)
284-
β = rand(ComplexF64)
285-
@test (maximum(abs.(a*b - Array(a)*b)) < 100*eps())
286-
@test (maximum(abs.(mul!(similar(b), a, b) - Array(a)*b)) < 100*eps()) # for compatibility with present matmul API. Should go away eventually.
287-
@test (maximum(abs.(mul!(similar(c), a, c) - Array(a)*c)) < 100*eps()) # for compatibility with present matmul API. Should go away eventually.
288-
@test (maximum(abs.(mul!(similar(b), transpose(a), b) - transpose(Array(a))*b)) < 100*eps()) # for compatibility with present matmul API. Should go away eventually.
289-
@test (maximum(abs.(mul!(similar(c), transpose(a), c) - transpose(Array(a))*c)) < 100*eps()) # for compatibility with present matmul API. Should go away eventually.
290-
@test (maximum(abs.(a'b - Array(a)'b)) < 100*eps())
291-
@test (maximum(abs.(transpose(a)*b - transpose(Array(a))*b)) < 100*eps())
292-
@test (maximum(abs.(a\b - Array(a)\b)) < 1000*eps())
293-
@test (maximum(abs.(a'\b - Array(a')\b)) < 1000*eps())
294-
@test (maximum(abs.(transpose(a)\b - Array(transpose(a))\b)) < 1000*eps())
295-
@test (maximum(abs.((a'*c + d) - (Array(a)'*c + d))) < 1000*eps())
296-
@test (maximum(abs.((α*transpose(a)*c + β*d) -*transpose(Array(a))*c + β*d))) < 1000*eps())
297-
@test (maximum(abs.((transpose(a)*c + d) - (transpose(Array(a))*c + d))) < 1000*eps())
298-
c = randn(6) + im*randn(6)
299-
@test_throws DimensionMismatch α*transpose(a)*c + β*c
300-
@test_throws DimensionMismatch α*transpose(a)*fill(1.,5) + β*c
301-
302-
a = I + 0.1*sprandn(5, 5, 0.2) + 0.1*im*sprandn(5, 5, 0.2)
303-
b = randn(5,3)
304-
@test (maximum(abs.(a*b - Array(a)*b)) < 100*eps())
305-
@test (maximum(abs.(a'b - Array(a)'b)) < 100*eps())
306-
@test (maximum(abs.(transpose(a)*b - transpose(Array(a))*b)) < 100*eps())
307-
@test (maximum(abs.(a\b - Array(a)\b)) < 1000*eps())
308-
@test (maximum(abs.(a'\b - Array(a')\b)) < 1000*eps())
309-
@test (maximum(abs.(transpose(a)\b - Array(transpose(a))\b)) < 1000*eps())
310-
311-
a = I + tril(0.1*sprandn(5, 5, 0.2))
312-
b = randn(5,3) + im*randn(5,3)
313-
@test (maximum(abs.(a*b - Array(a)*b)) < 100*eps())
314-
@test (maximum(abs.(a'b - Array(a)'b)) < 100*eps())
315-
@test (maximum(abs.(transpose(a)*b - transpose(Array(a))*b)) < 100*eps())
316-
@test (maximum(abs.(a\b - Array(a)\b)) < 1000*eps())
317-
@test (maximum(abs.(a'\b - Array(a')\b)) < 1000*eps())
318-
@test (maximum(abs.(transpose(a)\b - Array(transpose(a))\b)) < 1000*eps())
319-
320-
a = I + tril(0.1*sprandn(5, 5, 0.2) + 0.1*im*sprandn(5, 5, 0.2))
321-
b = randn(5,3)
322-
@test (maximum(abs.(a*b - Array(a)*b)) < 100*eps())
323-
@test (maximum(abs.(a'b - Array(a)'b)) < 100*eps())
324-
@test (maximum(abs.(transpose(a)*b - transpose(Array(a))*b)) < 100*eps())
325-
@test (maximum(abs.(a\b - Array(a)\b)) < 1000*eps())
326-
@test (maximum(abs.(a'\b - Array(a')\b)) < 1000*eps())
327-
@test (maximum(abs.(transpose(a)\b - Array(transpose(a))\b)) < 1000*eps())
328-
329-
a = I + triu(0.1*sprandn(5, 5, 0.2))
330-
b = randn(5,3) + im*randn(5,3)
331-
@test (maximum(abs.(a*b - Array(a)*b)) < 100*eps())
332-
@test (maximum(abs.(a'b - Array(a)'b)) < 100*eps())
333-
@test (maximum(abs.(transpose(a)*b - transpose(Array(a))*b)) < 100*eps())
334-
@test (maximum(abs.(a\b - Array(a)\b)) < 1000*eps())
335-
@test (maximum(abs.(a'\b - Array(a')\b)) < 1000*eps())
336-
@test (maximum(abs.(transpose(a)\b - Array(transpose(a))\b)) < 1000*eps())
337-
338-
a = I + triu(0.1*sprandn(5, 5, 0.2) + 0.1*im*sprandn(5, 5, 0.2))
339-
b = randn(5,3)
340-
@test (maximum(abs.(a*b - Array(a)*b)) < 100*eps())
341-
@test (maximum(abs.(a'b - Array(a)'b)) < 100*eps())
342-
@test (maximum(abs.(transpose(a)*b - transpose(Array(a))*b)) < 100*eps())
343-
@test (maximum(abs.(a\b - Array(a)\b)) < 1000*eps())
344-
@test (maximum(abs.(a'\b - Array(a')\b)) < 1000*eps())
345-
@test (maximum(abs.(transpose(a)\b - Array(transpose(a))\b)) < 1000*eps())
346-
347-
a = I + triu(0.1*sprandn(5, 5, 0.2))
348-
b = randn(5,3) + im*randn(5,3)
349-
@test (maximum(abs.(a*b - Array(a)*b)) < 100*eps())
350-
@test (maximum(abs.(a'b - Array(a)'b)) < 100*eps())
351-
@test (maximum(abs.(transpose(a)*b - transpose(Array(a))*b)) < 100*eps())
352-
@test (maximum(abs.(a\b - Array(a)\b)) < 1000*eps())
353-
@test (maximum(abs.(a'\b - Array(a')\b)) < 1000*eps())
354-
@test (maximum(abs.(transpose(a)\b - Array(transpose(a))\b)) < 1000*eps())
355-
356-
# UpperTriangular/LowerTriangular solve
357-
a = UpperTriangular(I + triu(0.1*sprandn(5, 5, 0.2)))
358-
b = sprandn(5, 5, 0.2)
359-
@test (maximum(abs.(a\b - Array(a)\Array(b))) < 1000*eps())
360-
# test error throwing for bwdTrisolve
361-
@test_throws DimensionMismatch a\Matrix{Float64}(I, 6, 6)
362-
a = LowerTriangular(I + tril(0.1*sprandn(5, 5, 0.2)))
363-
b = sprandn(5, 5, 0.2)
364-
@test (maximum(abs.(a\b - Array(a)\Array(b))) < 1000*eps())
365-
# test error throwing for fwdTrisolve
366-
@test_throws DimensionMismatch a\Matrix{Float64}(I, 6, 6)
367-
368-
369-
370-
a = sparse(Diagonal(randn(5) + im*randn(5)))
371-
b = randn(5,3)
372-
@test (maximum(abs.(a*b - Array(a)*b)) < 100*eps())
373-
@test (maximum(abs.(a'b - Array(a)'b)) < 100*eps())
374-
@test (maximum(abs.(transpose(a)*b - transpose(Array(a))*b)) < 100*eps())
375-
@test (maximum(abs.(a\b - Array(a)\b)) < 1000*eps())
376-
@test (maximum(abs.(a'\b - Array(a')\b)) < 1000*eps())
377-
@test (maximum(abs.(transpose(a)\b - Array(transpose(a))\b)) < 1000*eps())
378-
379-
b = randn(5,3) + im*randn(5,3)
380-
@test (maximum(abs.(a*b - Array(a)*b)) < 100*eps())
381-
@test (maximum(abs.(a'b - Array(a)'b)) < 100*eps())
382-
@test (maximum(abs.(transpose(a)*b - transpose(Array(a))*b)) < 100*eps())
383-
@test (maximum(abs.(a\b - Array(a)\b)) < 1000*eps())
384-
@test (maximum(abs.(a'\b - Array(a')\b)) < 1000*eps())
385-
@test (maximum(abs.(transpose(a)\b - Array(transpose(a))\b)) < 1000*eps())
386-
end
387-
end
388-
end
389276

390277
@testset "matrix multiplication" begin
391278
for (m, p, n, q, k) in (
@@ -1641,14 +1528,6 @@ end
16411528
@test count(!iszero, sparsevec(Diagonal(Int[]))) == 0
16421529
end
16431530

1644-
@testset "explicit zeros" begin
1645-
if Base.USE_GPL_LIBS
1646-
a = SparseMatrixCSC(2, 2, [1, 3, 5], [1, 2, 1, 2], [1.0, 0.0, 0.0, 1.0])
1647-
@test lu(a)\[2.0, 3.0] [2.0, 3.0]
1648-
@test cholesky(a)\[2.0, 3.0] [2.0, 3.0]
1649-
end
1650-
end
1651-
16521531
@testset "issue #9917" begin
16531532
@test sparse([]') == reshape(sparse([]), 1, 0)
16541533
@test Array(sparse([])) == zeros(0)
@@ -2088,43 +1967,6 @@ end
20881967
@test_throws ArgumentError opnorm(rowM, 3)
20891968
end
20901969

2091-
@testset "sparse matrix cond" begin
2092-
local A = sparse(reshape([1.0], 1, 1))
2093-
Ac = sprandn(20, 20,.5) + im*sprandn(20, 20,.5)
2094-
Ar = sprandn(20, 20,.5) + eps()*I
2095-
@test cond(A, 1) == 1.0
2096-
# For a discussion of the tolerance, see #14778
2097-
if Base.USE_GPL_LIBS
2098-
@test 0.99 <= cond(Ar, 1) \ opnorm(Ar, 1) * opnorm(inv(Array(Ar)), 1) < 3
2099-
@test 0.99 <= cond(Ac, 1) \ opnorm(Ac, 1) * opnorm(inv(Array(Ac)), 1) < 3
2100-
@test 0.99 <= cond(Ar, Inf) \ opnorm(Ar, Inf) * opnorm(inv(Array(Ar)), Inf) < 3
2101-
@test 0.99 <= cond(Ac, Inf) \ opnorm(Ac, Inf) * opnorm(inv(Array(Ac)), Inf) < 3
2102-
end
2103-
@test_throws ArgumentError cond(A,2)
2104-
@test_throws ArgumentError cond(A,3)
2105-
Arect = spzeros(10, 6)
2106-
@test_throws DimensionMismatch cond(Arect, 1)
2107-
@test_throws ArgumentError cond(Arect,2)
2108-
@test_throws DimensionMismatch cond(Arect, Inf)
2109-
end
2110-
2111-
@testset "sparse matrix opnormestinv" begin
2112-
Random.seed!(1235)
2113-
Ac = sprandn(20,20,.5) + im* sprandn(20,20,.5)
2114-
Aci = ceil.(Int64, 100*sprand(20,20,.5)) + im*ceil.(Int64, sprand(20,20,.5))
2115-
Ar = sprandn(20,20,.5)
2116-
Ari = ceil.(Int64, 100*Ar)
2117-
if Base.USE_GPL_LIBS
2118-
# NOTE: opnormestinv is probabilistic, so requires a fixed seed (set above in Random.seed!(1234))
2119-
@test SparseArrays.opnormestinv(Ac,3) opnorm(inv(Array(Ac)),1) atol=1e-4
2120-
@test SparseArrays.opnormestinv(Aci,3) opnorm(inv(Array(Aci)),1) atol=1e-4
2121-
@test SparseArrays.opnormestinv(Ar) opnorm(inv(Array(Ar)),1) atol=1e-4
2122-
@test_throws ArgumentError SparseArrays.opnormestinv(Ac,0)
2123-
@test_throws ArgumentError SparseArrays.opnormestinv(Ac,21)
2124-
end
2125-
@test_throws DimensionMismatch SparseArrays.opnormestinv(sprand(3,5,.9))
2126-
end
2127-
21281970
@testset "issue #13008" begin
21291971
@test_throws ArgumentError sparse(Vector(1:100), Vector(1:100), fill(5,100), 5, 5)
21301972
@test_throws ArgumentError sparse(Int[], Vector(1:5), Vector(1:5))
@@ -2161,31 +2003,6 @@ end
21612003
@test LinearAlgebra.fillstored!(sparse(2.0I, 5, 5), 1) == Matrix(I, 5, 5)
21622004
end
21632005

2164-
@testset "factorization" begin
2165-
Random.seed!(123)
2166-
local A
2167-
A = sparse(Diagonal(rand(5))) + sprandn(5, 5, 0.2) + im*sprandn(5, 5, 0.2)
2168-
A = A + copy(A')
2169-
@test !Base.USE_GPL_LIBS || abs(det(factorize(Hermitian(A)))) abs(det(factorize(Array(A))))
2170-
A = sparse(Diagonal(rand(5))) + sprandn(5, 5, 0.2) + im*sprandn(5, 5, 0.2)
2171-
A = A*A'
2172-
@test !Base.USE_GPL_LIBS || abs(det(factorize(Hermitian(A)))) abs(det(factorize(Array(A))))
2173-
A = sparse(Diagonal(rand(5))) + sprandn(5, 5, 0.2)
2174-
A = A + copy(transpose(A))
2175-
@test !Base.USE_GPL_LIBS || abs(det(factorize(Symmetric(A)))) abs(det(factorize(Array(A))))
2176-
A = sparse(Diagonal(rand(5))) + sprandn(5, 5, 0.2)
2177-
A = A*transpose(A)
2178-
@test !Base.USE_GPL_LIBS || abs(det(factorize(Symmetric(A)))) abs(det(factorize(Array(A))))
2179-
@test factorize(triu(A)) == triu(A)
2180-
@test isa(factorize(triu(A)), UpperTriangular{Float64, SparseMatrixCSC{Float64, Int}})
2181-
@test factorize(tril(A)) == tril(A)
2182-
@test isa(factorize(tril(A)), LowerTriangular{Float64, SparseMatrixCSC{Float64, Int}})
2183-
C, b = A[:, 1:4], fill(1., size(A, 1))
2184-
@test !Base.USE_GPL_LIBS || factorize(C)\b Array(C)\b
2185-
@test_throws ErrorException eigen(A)
2186-
@test_throws ErrorException inv(A)
2187-
end
2188-
21892006
@testset "issue #13792, use sparse triangular solvers for sparse triangular solves" begin
21902007
local A, n, x
21912008
n = 100
@@ -2905,13 +2722,15 @@ end
29052722
@test_throws MethodError sprandn(T, 5, 5, 0.5)
29062723
end
29072724

2908-
@testset "method ambiguity" begin
2909-
# Ambiguity test is run inside a clean process.
2910-
# https://github.com/JuliaLang/julia/issues/28804
2911-
script = joinpath(@__DIR__, "ambiguous_exec.jl")
2912-
cmd = `$(Base.julia_cmd()) --startup-file=no $script`
2913-
@test success(pipeline(cmd; stdout=stdout, stderr=stderr))
2914-
end
2725+
# TODO: Re-enable after completing the SparseArrays.jl migration
2726+
#
2727+
# @testset "method ambiguity" begin
2728+
# # Ambiguity test is run inside a clean process.
2729+
# # https://github.com/JuliaLang/julia/issues/28804
2730+
# script = joinpath(@__DIR__, "ambiguous_exec.jl")
2731+
# cmd = `$(Base.julia_cmd()) --startup-file=no $script`
2732+
# @test success(pipeline(cmd; stdout=stdout, stderr=stderr))
2733+
# end
29152734

29162735
@testset "oneunit of sparse matrix" begin
29172736
A = sparse([Second(0) Second(0); Second(0) Second(0)])

0 commit comments

Comments
 (0)