Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move sparse matrix tests to the new SparseArrays.jl repo #43832

Merged
merged 2 commits into from
Jan 17, 2022
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
21 changes: 1 addition & 20 deletions test/abstractarray.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

using Random, LinearAlgebra, SparseArrays
using Random, LinearAlgebra

A = rand(5,4,3)
@testset "Bounds checking" begin
Expand Down Expand Up @@ -832,24 +832,6 @@ A = TSlowNIndexes(rand(2,2))
@test @inferred(axes(rand(3,2), 3)) == 1:1
end

@testset "#17088" begin
n = 10
M = rand(n, n)
@testset "vector of vectors" begin
v = [[M]; [M]] # using vcat
@test size(v) == (2,)
@test !issparse(v)
end
@testset "matrix of vectors" begin
m1 = [[M] [M]] # using hcat
m2 = [[M] [M];] # using hvcat
@test m1 == m2
@test size(m1) == (1,2)
@test !issparse(m1)
@test !issparse(m2)
end
end

@testset "isinteger and isreal" begin
@test all(isinteger, Diagonal(rand(1:5,5)))
@test isreal(Diagonal(rand(5)))
Expand Down Expand Up @@ -1022,7 +1004,6 @@ end
s = Vector([1, 2])
for a = ([1], UInt[1], [3, 4, 5], UInt[3, 4, 5])
@test s === copy!(s, Vector(a)) == Vector(a)
@test s === copy!(s, SparseVector(a)) == Vector(a)
end
# issue #35649
s = [1, 2, 3, 4]
Expand Down
37 changes: 0 additions & 37 deletions test/arrayops.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ using .Main.OffsetArrays

isdefined(@__MODULE__, :T24Linear) || include("testhelpers/arrayindexingtypes.jl")

using SparseArrays

using Random, LinearAlgebra
using Dates

Expand Down Expand Up @@ -1201,9 +1199,6 @@ end
m = mapslices(x->tuple(x), [1 2; 3 4], dims=1)
@test m[1,1] == ([1,3],)
@test m[1,2] == ([2,4],)

# issue #21123
@test mapslices(nnz, sparse(1.0I, 3, 3), dims=1) == [1 1 1]
end

@testset "single multidimensional index" begin
Expand Down Expand Up @@ -1954,13 +1949,6 @@ end
@test isless(CartesianIndex((2,1)), CartesianIndex((1,2)))
@test !isless(CartesianIndex((1,2)), CartesianIndex((2,1)))

a = spzeros(2,3)
@test CartesianIndices(size(a)) == eachindex(a)
a[CartesianIndex{2}(2,3)] = 5
@test a[2,3] == 5
b = view(a, 1:2, 2:3)
b[CartesianIndex{2}(1,1)] = 7
@test a[1,2] == 7
@test 2*CartesianIndex{3}(1,2,3) == CartesianIndex{3}(2,4,6)
@test CartesianIndex{3}(1,2,3)*2 == CartesianIndex{3}(2,4,6)
@test_throws ErrorException iterate(CartesianIndex{3}(1,2,3))
Expand Down Expand Up @@ -2013,16 +2001,6 @@ end
y = iterate(itr, y[2])
@test y === nothing
@test r[val] == 3
r = sparse(2:3:8)
itr = eachindex(r)
y = iterate(itr)
@test y !== nothing
y = iterate(itr, y[2])
y = iterate(itr, y[2])
@test y !== nothing
val, state = y
@test r[val] == 8
@test iterate(itr, state) == nothing
end

R = CartesianIndices((1,3))
Expand Down Expand Up @@ -2964,18 +2942,3 @@ end
@test c + zero(c) == c
end
end

@testset "Allow assignment of singleton array to sparse array #43644" begin
K = spzeros(3,3)
b = zeros(3,3)
b[3,:] = [1,2,3]
K[3,1:3] += [1.0 2.0 3.0]'
@test K == b
K[3:3,1:3] += zeros(1, 3)
@test K == b
K[3,1:3] += zeros(3)
@test K == b
K[3,:] += zeros(3,1)
@test K == b
@test_throws DimensionMismatch K[3,1:2] += [1.0 2.0 3.0]'
end
4 changes: 2 additions & 2 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# test core language features

using Random, SparseArrays, InteractiveUtils
using Random, InteractiveUtils

const Bottom = Union{}

Expand Down Expand Up @@ -3659,7 +3659,7 @@ f12092(x::Int, y::Int...) = 2
# NOTE: should have > MAX_TUPLETYPE_LEN arguments
f12063(tt, g, p, c, b, v, cu::T, d::AbstractArray{T, 2}, ve) where {T} = 1
f12063(args...) = 2
g12063() = f12063(0, 0, 0, 0, 0, 0, 0.0, spzeros(0,0), Int[])
g12063() = f12063(0, 0, 0, 0, 0, 0, 0.0, zeros(0,0), Int[])
@test g12063() == 1

# issue #11587
Expand Down
2 changes: 1 addition & 1 deletion test/hashing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -283,4 +283,4 @@ end
@test isequal(a, b) == (Base.hash_32_32(a) == Base.hash_32_32(b))
end
end
end
end
24 changes: 1 addition & 23 deletions test/show.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

using LinearAlgebra, SparseArrays
using LinearAlgebra

# For curmod_*
include("testenv.jl")
Expand Down Expand Up @@ -730,28 +730,6 @@ let filename = tempname()
rm(filename)
end

# issue #12960
mutable struct T12960 end
import Base.zero
Base.zero(::Type{T12960}) = T12960()
Base.zero(x::T12960) = T12960()
let
A = sparse(1.0I, 3, 3)
B = similar(A, T12960)
@test repr(B) == "sparse([1, 2, 3], [1, 2, 3], $T12960[#undef, #undef, #undef], 3, 3)"
@test occursin(
"\n #undef ⋅ ⋅ \n ⋅ #undef ⋅ \n ⋅ ⋅ #undef",
repr(MIME("text/plain"), B),
)

B[1,2] = T12960()
@test repr(B) == "sparse([1, 1, 2, 3], [1, 2, 2, 3], $T12960[#undef, $T12960(), #undef, #undef], 3, 3)"
@test occursin(
"\n #undef T12960() ⋅ \n ⋅ #undef ⋅ \n ⋅ ⋅ #undef",
repr(MIME("text/plain"), B),
)
end

# issue #13127
function f13127()
buf = IOBuffer()
Expand Down