Skip to content

Commit 8e727d1

Browse files
Merge pull request #398 from SciML/sparsearrays
Make sparsearrays into a weak dependency
2 parents e0f1b1d + a3a9d32 commit 8e727d1

File tree

4 files changed

+26
-5
lines changed

4 files changed

+26
-5
lines changed

Project.toml

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "RecursiveArrayTools"
22
uuid = "731186ca-8d62-57ce-b412-fbd966d074cd"
33
authors = ["Chris Rackauckas <[email protected]>"]
4-
version = "3.26.0"
4+
version = "3.27.0"
55

66
[deps]
77
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
@@ -11,7 +11,6 @@ GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527"
1111
IteratorInterfaceExtensions = "82899510-4779-5014-852e-03e436cf321d"
1212
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1313
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
14-
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
1514
StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c"
1615
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
1716
SymbolicIndexingInterface = "2efcf032-c050-4f8e-a9bb-153293bab1f5"
@@ -22,6 +21,7 @@ FastBroadcast = "7034ab61-46d4-4ed7-9d0f-46aef9175898"
2221
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
2322
Measurements = "eff96d63-e80a-5855-80a2-b1b0885c5ab7"
2423
MonteCarloMeasurements = "0987c9cc-fe09-11e8-30f0-b96dd679fdca"
24+
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
2525
ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267"
2626
Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c"
2727
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
@@ -32,6 +32,7 @@ RecursiveArrayToolsForwardDiffExt = "ForwardDiff"
3232
RecursiveArrayToolsMeasurementsExt = "Measurements"
3333
RecursiveArrayToolsMonteCarloMeasurementsExt = "MonteCarloMeasurements"
3434
RecursiveArrayToolsReverseDiffExt = ["ReverseDiff", "Zygote"]
35+
RecursiveArrayToolsSparseArraysExt = ["SparseArrays"]
3536
RecursiveArrayToolsTrackerExt = "Tracker"
3637
RecursiveArrayToolsZygoteExt = "Zygote"
3738

@@ -78,6 +79,7 @@ OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
7879
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
7980
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
8081
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
82+
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
8183
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
8284
StructArrays = "09ab397b-f2b6-538f-b94a-2f83cf4a842a"
8385
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
@@ -86,4 +88,4 @@ Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
8688
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
8789

8890
[targets]
89-
test = ["SafeTestsets", "Aqua", "FastBroadcast", "ForwardDiff", "NLsolve", "OrdinaryDiffEq", "Pkg", "Test", "Unitful", "Random", "StaticArrays", "StructArrays", "Zygote", "Measurements"]
91+
test = ["SafeTestsets", "Aqua", "FastBroadcast", "SparseArrays", "ForwardDiff", "NLsolve", "OrdinaryDiffEq", "Pkg", "Test", "Unitful", "Random", "StaticArrays", "StructArrays", "Zygote", "Measurements"]
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module RecursiveArrayToolsSparseArraysExt
2+
3+
import SparseArrays
4+
import RecursiveArrayTools
5+
6+
function Base.copyto!(dest::SparseArrays.AbstractCompressedVector, A::RecursiveArrayTools.ArrayPartition)
7+
@assert length(dest) == length(A)
8+
cur = 1
9+
@inbounds for i in 1:length(A.x)
10+
if A.x[i] isa Number
11+
dest[cur:(cur + length(A.x[i]) - 1)] .= A.x[i]
12+
else
13+
dest[cur:(cur + length(A.x[i]) - 1)] .= vec(A.x[i])
14+
end
15+
cur += length(A.x[i])
16+
end
17+
dest
18+
end
19+
20+
end

src/RecursiveArrayTools.jl

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ using DocStringExtensions
88
using RecipesBase, StaticArraysCore, Statistics,
99
ArrayInterface, LinearAlgebra
1010
using SymbolicIndexingInterface
11-
using SparseArrays
1211

1312
import Adapt
1413

src/array_partition.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ Base.all(f, A::ArrayPartition) = all(f, (all(f, x) for x in A.x))
176176
Base.all(f::Function, A::ArrayPartition) = all((all(f, x) for x in A.x))
177177
Base.all(A::ArrayPartition) = all(identity, A)
178178

179-
for type in [AbstractArray, SparseArrays.AbstractCompressedVector, PermutedDimsArray]
179+
for type in [AbstractArray, PermutedDimsArray]
180180
@eval function Base.copyto!(dest::$(type), A::ArrayPartition)
181181
@assert length(dest) == length(A)
182182
cur = 1

0 commit comments

Comments
 (0)