Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 3 additions & 16 deletions .github/workflows/TagBot.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,11 @@
name: TagBot

on:
issue_comment:
types:
- created
workflow_dispatch:
inputs:
lookback:
default: "3"
permissions:
actions: read
checks: read
contents: write
deployments: read
issues: read
discussions: read
packages: read
pages: read
pull-requests: read
repository-projects: read
security-events: read
statuses: read

jobs:
TagBot:
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot'
Expand All @@ -28,4 +14,5 @@ jobs:
- uses: JuliaRegistries/TagBot@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
registry: ITensor/ITensorRegistry
ssh: ${{ secrets.DOCUMENTER_KEY }}
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ci:
skip: [runic]
skip: [itensor-formatter]

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand All @@ -11,7 +11,7 @@ repos:
- id: end-of-file-fixer
exclude_types: [markdown] # incompatible with Literate.jl

- repo: https://github.com/fredrikekre/runic-pre-commit
rev: v2.0.1
- repo: https://github.com/ITensor/ITensorFormatter.jl
rev: v0.2.9
hooks:
- id: runic
- id: itensor-formatter
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "SparseArraysBase"
uuid = "0d5efcca-f356-4864-8770-e1ed8d78f208"
version = "0.9.3"
version = "0.9.4"
authors = ["ITensor developers <support@itensor.org> and contributors"]

[workspace]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://itensor.github.io/SparseArraysBase.jl/dev/)
[![Build Status](https://github.com/ITensor/SparseArraysBase.jl/actions/workflows/Tests.yml/badge.svg?branch=main)](https://github.com/ITensor/SparseArraysBase.jl/actions/workflows/Tests.yml?query=branch%3Amain)
[![Coverage](https://codecov.io/gh/ITensor/SparseArraysBase.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/ITensor/SparseArraysBase.jl)
[![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle)
[![Code Style](https://img.shields.io/badge/code_style-ITensor-purple)](https://github.com/ITensor/ITensorFormatter.jl)
[![Aqua](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl)

## Support
Expand Down
8 changes: 4 additions & 4 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ using Documenter: Documenter, DocMeta, deploydocs, makedocs
using SparseArraysBase: SparseArraysBase

DocMeta.setdocmeta!(
SparseArraysBase, :DocTestSetup, :(using SparseArraysBase); recursive = true,
SparseArraysBase, :DocTestSetup, :(using SparseArraysBase); recursive = true
)

include("make_index.jl")
Expand All @@ -14,11 +14,11 @@ makedocs(;
format = Documenter.HTML(;
canonical = "https://itensor.github.io/SparseArraysBase.jl",
edit_link = "main",
assets = ["assets/favicon.ico", "assets/extras.css"],
assets = ["assets/favicon.ico", "assets/extras.css"]
),
pages = ["Home" => "index.md", "Reference" => "reference.md"],
pages = ["Home" => "index.md", "Reference" => "reference.md"]
)

deploydocs(;
repo = "github.com/ITensor/SparseArraysBase.jl", devbranch = "main", push_preview = true,
repo = "github.com/ITensor/SparseArraysBase.jl", devbranch = "main", push_preview = true
)
2 changes: 1 addition & 1 deletion docs/make_index.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ Literate.markdown(
joinpath(pkgdir(SparseArraysBase), "docs", "src");
flavor = Literate.DocumenterFlavor(),
name = "index",
postprocess = ccq_logo,
postprocess = ccq_logo
)
2 changes: 1 addition & 1 deletion docs/make_readme.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ Literate.markdown(
joinpath(pkgdir(SparseArraysBase));
flavor = Literate.CommonMarkFlavor(),
name = "README",
postprocess = ccq_logo,
postprocess = ccq_logo
)
2 changes: 1 addition & 1 deletion examples/README.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# [![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://itensor.github.io/SparseArraysBase.jl/dev/)
# [![Build Status](https://github.com/ITensor/SparseArraysBase.jl/actions/workflows/Tests.yml/badge.svg?branch=main)](https://github.com/ITensor/SparseArraysBase.jl/actions/workflows/Tests.yml?query=branch%3Amain)
# [![Coverage](https://codecov.io/gh/ITensor/SparseArraysBase.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/ITensor/SparseArraysBase.jl)
# [![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle)
# [![Code Style](https://img.shields.io/badge/code_style-ITensor-purple)](https://github.com/ITensor/ITensorFormatter.jl)
# [![Aqua](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl)

# ## Support
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function SparseArraysBase.dense(a::AbstractNamedDimsArray)
end

function SparseArraysBase.oneelement(
value, index::NTuple{N, Int}, ax::NTuple{N, AbstractNamedUnitRange},
value, index::NTuple{N, Int}, ax::NTuple{N, AbstractNamedUnitRange}
) where {N}
return nameddims(oneelement(value, index, denamed.(ax)), name.(ax))
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ struct SparseArrayFusion <: FusionStyle end
TensorAlgebra.FusionStyle(::Type{<:AnyAbstractSparseArray}) = SparseArrayFusion()

function TensorAlgebra.matricize(
style::SparseArrayFusion, a::AbstractArray, length_codomain::Val,
style::SparseArrayFusion, a::AbstractArray, length_codomain::Val
)
m = matricize(ReshapeFusion(), a, length_codomain)
return convert(SparseMatrixCSC, m)
Expand All @@ -18,7 +18,7 @@ function TensorAlgebra.unmatricize(
style::SparseArrayFusion,
m::AbstractMatrix,
axes_codomain::Tuple{Vararg{AbstractUnitRange}},
axes_domain::Tuple{Vararg{AbstractUnitRange}},
axes_domain::Tuple{Vararg{AbstractUnitRange}}
)
a = unmatricize(ReshapeFusion(), m, axes_codomain, axes_domain)
# TODO: Use `similar_type(m)` instead of hardcoding to `SparseArrayDOK`?
Expand Down
40 changes: 18 additions & 22 deletions src/abstractsparsearray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,13 @@ function Base.similar(a::AnyAbstractSparseArray, T::Type, ax::Tuple{Vararg{Int}}
return similar_sparsearray(a, T, ax)
end
function Base.similar(
a::AnyAbstractSparseArray, T::Type, ax::Tuple{Integer, Vararg{Integer}},
a::AnyAbstractSparseArray, T::Type, ax::Tuple{Integer, Vararg{Integer}}
)
return similar_sparsearray(a, T, ax)
end
function Base.similar(
a::AnyAbstractSparseArray,
T::Type,
ax::Tuple{Union{Integer, Base.OneTo}, Vararg{Union{Integer, Base.OneTo}}},
a::AnyAbstractSparseArray, T::Type,
ax::Tuple{Union{Integer, Base.OneTo}, Vararg{Union{Integer, Base.OneTo}}}
)
return similar_sparsearray(a, T, ax)
end
Expand Down Expand Up @@ -98,7 +97,7 @@ function Base.permutedims!(dst, a::AnyAbstractSparseArray, perm)
end
function LinearAlgebra.mul!(
dst::AbstractMatrix, a1::AnyAbstractSparseArray, a2::AnyAbstractSparseArray,
α::Number, β::Number,
α::Number, β::Number
)
return style(a1, a2)(mul!)(dst, a1, a2, α, β)
end
Expand Down Expand Up @@ -146,7 +145,7 @@ function Base.print_array(io::IO, a::AnyAbstractSparseArray)
return @invoke Base.print_array(io::typeof(io), a′::AbstractArray{<:Any, ndims(a)})
end
function Base.replace_in_print_matrix(
a::AnyAbstractSparseVecOrMat, i::Integer, j::Integer, s::AbstractString,
a::AnyAbstractSparseVecOrMat, i::Integer, j::Integer, s::AbstractString
)
return isstored(a, i, j) ? s : Base.replace_with_centered_mark(s)
end
Expand Down Expand Up @@ -252,17 +251,19 @@ end
@doc """
sparserand!([rng], A::AbstractArray; density::Real=0.5, randfun::Function=rand) -> A

Overwrite part of an array with random entries, where the probability of overwriting is independently given by `density`.
Overwrite part of an array with random entries, where the probability of overwriting is
independently given by `density`.
The optional `rng` argument specifies a random number generator, see also `Random`.
The optional `randfun` argument can be used to control the type of random elements, and should support
the signature `randfun(rng, T, N)` to generate `N` entries of type `T`.
The optional `randfun` argument can be used to control the type of random elements, and
should support the signature `randfun(rng, T, N)` to generate `N` entries of type `T`.

See also [`sparserand`](@ref).
""" sparserand!

sparserand!(A::AbstractArray; kwargs...) = sparserand!(default_rng(), A; kwargs...)
function sparserand!(
rng::AbstractRNG, A::AbstractArray; density::Real = 0.5, randfun::Function = Random.rand,
rng::AbstractRNG, A::AbstractArray; density::Real = 0.5,
randfun::Function = Random.rand
)
ArrayLayouts.zero!(A)
rand_inds = Random.randsubseq(rng, eachindex(A), density)
Expand All @@ -275,39 +276,34 @@ end
using ArrayLayouts: ArrayLayouts, MemoryLayout
using LinearAlgebra: LinearAlgebra, Adjoint
function ArrayLayouts.MemoryLayout(
::Type{Transpose{T, P}},
::Type{Transpose{T, P}}
) where {T, P <: AbstractSparseMatrix}
return MemoryLayout(P)
end
function ArrayLayouts.MemoryLayout(
::Type{Adjoint{T, P}},
::Type{Adjoint{T, P}}
) where {T, P <: AbstractSparseMatrix}
return MemoryLayout(P)
end
function LinearAlgebra.mul!(
dest::AbstractMatrix,
A::Adjoint{<:Any, <:AbstractSparseMatrix},
B::AbstractSparseMatrix,
α::Number,
β::Number,
A::Adjoint{<:Any, <:AbstractSparseMatrix}, B::AbstractSparseMatrix,
α::Number, β::Number
)
return ArrayLayouts.mul!(dest, A, B, α, β)
end
function LinearAlgebra.mul!(
dest::AbstractMatrix,
A::AbstractSparseMatrix,
B::Adjoint{<:Any, <:AbstractSparseMatrix},
α::Number,
β::Number,
A::AbstractSparseMatrix, B::Adjoint{<:Any, <:AbstractSparseMatrix},
α::Number, β::Number
)
return ArrayLayouts.mul!(dest, A, B, α, β)
end
function LinearAlgebra.mul!(
dest::AbstractMatrix,
A::Adjoint{<:Any, <:AbstractSparseMatrix},
B::Adjoint{<:Any, <:AbstractSparseMatrix},
α::Number,
β::Number,
α::Number, β::Number
)
return ArrayLayouts.mul!(dest, A, B, α, β)
end
27 changes: 11 additions & 16 deletions src/abstractsparsearraystyle.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ abstract type AbstractSparseArrayImplementationStyle <: AbstractArrayImplementat

function FunctionImplementations.ImplementationStyle(
style1::AbstractSparseArrayImplementationStyle,
style2::AbstractSparseArrayImplementationStyle,
style2::AbstractSparseArrayImplementationStyle
)
return SparseArrayImplementationStyle()
end
function FunctionImplementations.ImplementationStyle(
style1::AbstractSparseArrayImplementationStyle,
style2::AbstractArrayImplementationStyle,
style2::AbstractArrayImplementationStyle
)
return style1
end
Expand All @@ -74,7 +74,7 @@ end
using FunctionImplementations: DefaultArrayImplementationStyle
function FunctionImplementations.ImplementationStyle(
style1::AbstractSparseArrayImplementationStyle,
style2::DefaultArrayImplementationStyle,
style2::DefaultArrayImplementationStyle
)
return style1
end
Expand Down Expand Up @@ -122,30 +122,23 @@ end

using LinearAlgebra: mul!
function mul!!(
a_dest::AbstractMatrix,
a1::AbstractMatrix,
a2::AbstractMatrix,
α::Number = true,
β::Number = false,
a_dest::AbstractMatrix, a1::AbstractMatrix, a2::AbstractMatrix,
α::Number = true, β::Number = false
)
mul!(a_dest, a1, a2, α, β)
return a_dest
end

function mul!!(
a_dest::Number, a1::Number, a2::Number, α::Number = true, β::Number = false,
a_dest::Number, a1::Number, a2::Number, α::Number = true, β::Number = false
)
return a1 * a2 * α + a_dest * β
end

# a1 * a2 * α + a_dest * β
function _mul!_sparse(
a_dest::AbstractArray,
a1::AbstractArray,
a2::AbstractArray,
α::Number = true,
β::Number = false;
(mul!!) = (mul!!),
a_dest::AbstractArray, a1::AbstractArray, a2::AbstractArray,
α::Number = true, β::Number = false; (mul!!) = (mul!!)
)
a_dest .*= β
β′ = one(Bool)
Expand All @@ -165,7 +158,9 @@ function _mul!_sparse(
end

function ArrayLayouts.materialize!(
m::MatMulMatAdd{<:AbstractSparseLayout, <:AbstractSparseLayout, <:AbstractSparseLayout},
m::MatMulMatAdd{
<:AbstractSparseLayout, <:AbstractSparseLayout, <:AbstractSparseLayout,
}
)
_mul!_sparse(m.C, m.A, m.B, m.α, m.β)
return m.C
Expand Down
Loading
Loading