Skip to content

Commit 5eee1bb

Browse files
Jutholkdvos
andauthored
make compatible with TensorOperations v5 (#14)
* make compatible with TensorOperations v5 * Reabsorb TensorOperations as dependency instead of extension (#15) * use new lts syntax * Reabsorb TensorOperations as full dependency * Fix Aqua compat * Add missing Compat entries * some more (final?) changes * add constructors from UniformScaling --------- Co-authored-by: Lukas <[email protected]>
1 parent f348d12 commit 5eee1bb

14 files changed

+202
-153
lines changed

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ updates:
44
- package-ecosystem: "github-actions"
55
directory: "/" # Location of package manifests
66
schedule:
7-
interval: "weekly"
7+
interval: "weekly"

.github/workflows/CompatHelper.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
name: CompatHelper
2-
32
on:
43
schedule:
54
- cron: 0 0 * * *
65
workflow_dispatch:
7-
86
jobs:
97
CompatHelper:
108
runs-on: ubuntu-latest

.github/workflows/TagBot.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
11
name: TagBot
2-
32
on:
43
issue_comment:
54
types:
65
- created
76
workflow_dispatch:
8-
7+
inputs:
8+
lookback:
9+
default: "3"
10+
permissions:
11+
actions: read
12+
checks: read
13+
contents: write
14+
deployments: read
15+
issues: read
16+
discussions: read
17+
packages: read
18+
pages: read
19+
pull-requests: read
20+
repository-projects: read
21+
security-events: read
22+
statuses: read
923
jobs:
1024
TagBot:
1125
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot'

.github/workflows/ci.yml

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,16 @@ jobs:
1717
test:
1818
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }}
1919
runs-on: ${{ matrix.os }}
20+
timeout-minutes: 60
21+
permissions: # needed to allow julia-actions/cache to proactively delete old caches that it has created
22+
actions: write
23+
contents: read
2024
strategy:
2125
fail-fast: false
2226
matrix:
2327
version:
24-
- '1.6' # LTS version
28+
- '1.8' # lowest TensorOperations version
29+
- 'lts' # LTS version
2530
- '1' # automatically expands to the latest stable 1.x release of Julia
2631
os:
2732
- ubuntu-latest
@@ -31,42 +36,43 @@ jobs:
3136
- x64
3237
steps:
3338
- uses: actions/checkout@v4
34-
- uses: julia-actions/setup-julia@v1
39+
- uses: julia-actions/setup-julia@v2
3540
with:
3641
version: ${{ matrix.version }}
3742
arch: ${{ matrix.arch }}
38-
- uses: julia-actions/cache@v1
43+
- uses: julia-actions/cache@v2
3944
- uses: julia-actions/julia-buildpkg@latest
4045
- uses: julia-actions/julia-runtest@latest
41-
# env:
42-
# JULIA_NUM_THREADS: 4
4346
- uses: julia-actions/julia-processcoverage@v1
44-
- uses: codecov/codecov-action@v3
47+
- uses: codecov/codecov-action@v4
4548
with:
4649
file: lcov.info
50+
token: ${{ secrets.CODECOV_TOKEN }}
51+
fail_ci_if_error: false
4752
test-nightly:
4853
needs: test
4954
name: Julia nightly - ${{ matrix.os }} - ${{ matrix.arch }}
5055
runs-on: ${{ matrix.os }}
56+
timeout-minutes: 60
57+
permissions: # needed to allow julia-actions/cache to proactively delete old caches that it has created
58+
actions: write
59+
contents: read
5160
strategy:
52-
fail-fast: false
61+
fail-fast: true
5362
matrix:
5463
version:
64+
- 'pre' # automatically expands to the latest pre-release of Julia
5565
- 'nightly'
5666
os:
5767
- ubuntu-latest
58-
- macOS-latest
59-
- windows-latest
6068
arch:
6169
- x64
6270
steps:
6371
- uses: actions/checkout@v4
64-
- uses: julia-actions/setup-julia@v1
72+
- uses: julia-actions/setup-julia@v2
6573
with:
6674
version: ${{ matrix.version }}
6775
arch: ${{ matrix.arch }}
68-
- uses: julia-actions/cache@v1
76+
- uses: julia-actions/cache@v2
6977
- uses: julia-actions/julia-buildpkg@latest
7078
- uses: julia-actions/julia-runtest@latest
71-
# env:
72-
# JULIA_NUM_THREADS: 4

Project.toml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "SparseArrayKit"
22
uuid = "a9a3c162-d163-4c15-8926-b8794fbefed2"
33
authors = ["Lukas Devos <[email protected]>", "Maarten Van Damme <[email protected]>", "Jutho Haegeman <[email protected]>"]
4-
version = "0.3.1"
4+
version = "0.4"
55

66
[deps]
77
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
@@ -12,28 +12,32 @@ VectorInterface = "409d34a3-91d5-4945-b6ec-7529ddf182d8"
1212

1313
[weakdeps]
1414
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
15-
TensorOperations = "6aa20fa7-93e2-5fca-9bc0-fbd0db3c71a2"
1615

1716
[extensions]
1817
SparseArrayKitSparseArrays = "SparseArrays"
19-
SparseArrayKitTensorOperations = "TensorOperations"
2018

2119
[compat]
20+
Aqua = "0.8"
21+
LinearAlgebra = "1"
2222
PackageExtensionCompat = "1"
23-
TensorOperations = "4"
23+
Random = "1"
24+
SparseArrays = "1"
25+
Strided = "2"
26+
Test = "1"
27+
TestExtras = "0.3"
28+
TensorOperations = "5"
2429
TupleTools = "1.1"
2530
VectorInterface = "0.4.1"
26-
julia = "1.6"
31+
julia = "1.8"
2732

2833
[extras]
2934
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
3035
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
3136
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
3237
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
3338
Strided = "5e0ebb24-38b0-5f93-81fe-25c709ecae67"
34-
TensorOperations = "6aa20fa7-93e2-5fca-9bc0-fbd0db3c71a2"
3539
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
3640
TestExtras = "5ed8adda-3752-4e41-b88a-e8b09835ee3a"
3741

3842
[targets]
39-
test = ["Test", "TestExtras", "TensorOperations", "Strided", "Random", "LinearAlgebra", "SparseArrays", "Aqua"]
43+
test = ["Test", "TestExtras", "Strided", "Random", "LinearAlgebra", "SparseArrays", "Aqua"]

ext/SparseArrayKitTensorOperations.jl

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

src/SparseArrayKit.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
module SparseArrayKit
22

33
using VectorInterface
4+
using TensorOperations
45
using LinearAlgebra
56
using TupleTools
67

7-
const IndexTuple{N} = NTuple{N,Int}
8-
98
export SparseArray
109
export nonzero_pairs, nonzero_keys, nonzero_values, nonzero_length
1110

src/base.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ end
5454

5555
# array manipulation
5656
function Base.permutedims!(dst::SparseArray, src::SparseArray, p)
57-
return tensoradd!(dst, tuple(p...), src, :N, true, false)
57+
return tensoradd!(dst, src, (tuple(p...), ()), false)
5858
end
5959

6060
function Base.reshape(parent::SparseArray{T}, dims::Dims) where {T}

src/linearalgebra.jl

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ const ASM{T} = Union{SparseArray{T,2},
7777

7878
LinearAlgebra.mul!(C::SM, A::ASM, B::ASM) = mul!(C, A, B, one(eltype(C)), zero(eltype(C)))
7979
function LinearAlgebra.mul!(C::SM, A::ASM, B::ASM, α::Number, β::Number)
80-
CA = A isa Adjoint ? :C : :N
81-
CB = B isa Adjoint ? :C : :N
80+
conjA = A isa Adjoint
81+
conjB = B isa Adjoint
8282
oindA = A isa Union{Adjoint,Transpose} ? (2,) : (1,)
8383
cindA = A isa Union{Adjoint,Transpose} ? (1,) : (2,)
8484
oindB = B isa Union{Adjoint,Transpose} ? (1,) : (2,)
@@ -87,8 +87,12 @@ function LinearAlgebra.mul!(C::SM, A::ASM, B::ASM, α::Number, β::Number)
8787
AA = A isa Union{Adjoint,Transpose} ? parent(A) : A
8888
BB = B isa Union{Adjoint,Transpose} ? parent(B) : B
8989

90-
return tensorcontract!(C, (1, 2), AA, CA, oindA, cindA, BB, CB, oindB, cindB, α, β)
90+
return tensorcontract!(C, AA, (oindA, cindA), conjA, BB, (cindB, oindB), conjB,
91+
((1, 2), ()), α,
92+
β)
9193
end
9294

93-
LinearAlgebra.adjoint!(C::SM, A::SM) = tensoradd!(C, (2, 1), A, :C, One(), Zero())
94-
LinearAlgebra.transpose!(C::SM, A::SM) = tensoradd!(C, (2, 1), A, :N, One(), Zero())
95+
LinearAlgebra.adjoint!(C::SM, A::SM) = tensoradd!(C, A, ((2, 1), ()), true, One(), Zero())
96+
function LinearAlgebra.transpose!(C::SM, A::SM)
97+
return tensoradd!(C, A, ((2, 1), ()), false, One(), Zero())
98+
end

src/sparsearray.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@ function SparseArray{T}(::UndefInitializer, dims::Dims{N}) where {T,N}
1717
return SparseArray{T,N}(undef, dims)
1818
end
1919
SparseArray{T}(::UndefInitializer, dims...) where {T} = SparseArray{T}(undef, dims)
20+
function SparseArray{T}(a::UniformScaling, dims::Dims{2}) where {T}
21+
A = SparseArray{T}(undef, dims)
22+
for i in 1:min(dims...)
23+
A[i, i] = a[1, 1]
24+
end
25+
return A
26+
end
27+
SparseArray(a::UniformScaling, dims::Dims{2}) = SparseArray{eltype(a)}(a, dims)
28+
SparseArray(a::UniformScaling, d1::Int, d2::Int) = SparseArray{eltype(a)}(a, (d1, d2))
2029

2130
nonzero_pairs(a::SparseArray) = pairs(a.data)
2231
nonzero_keys(a::SparseArray) = keys(a.data)

0 commit comments

Comments
 (0)