@@ -2281,22 +2281,70 @@ end
22812281 for c in unstored_indices
22822282 @test Base. isstored (A, c[1 ], c[2 ]) == false
22832283 end
2284+
2285+ # `isstored` for adjoint and tranposed matrices:
2286+ for trans in (adjoint, transpose)
2287+ B = trans (A)
2288+ stored_indices = [CartesianIndex (j, i) for (j, i) in zip (J, I)]
2289+ unstored_indices = [c for c in CartesianIndices ((n, m)) if ! (c in stored_indices)]
2290+ for c in stored_indices
2291+ @test Base. isstored (B, c[1 ], c[2 ]) == true
2292+ end
2293+ for c in unstored_indices
2294+ @test Base. isstored (B, c[1 ], c[2 ]) == false
2295+ end
2296+ end
22842297end
22852298
22862299@testset " show" begin
22872300 io = IOBuffer ()
2288- show (io, MIME " text/plain" (), spzeros (Float64, Int64, 0 , 0 ))
2289- @test String (take! (io)) == " 0×0 SparseArrays.SparseMatrixCSC{Float64,Int64} with 0 stored entries"
2290- show (io, MIME " text/plain" (), sparse (Int64[1 ], Int64[1 ], [1.0 ]))
2291- @test String (take! (io)) == " 1×1 SparseArrays.SparseMatrixCSC{Float64,Int64} with 1 stored entry:\n 1.0"
2292- show (io, MIME " text/plain" (), spzeros (Float32, Int64, 2 , 2 ))
2293- @test String (take! (io)) == " 2×2 SparseArrays.SparseMatrixCSC{Float32,Int64} with 0 stored entries:\n ⋅ ⋅ \n ⋅ ⋅ "
2301+
2302+ A = spzeros (Float64, Int64, 0 , 0 )
2303+ for (transform, showstring) in zip (
2304+ (identity, adjoint, transpose), (
2305+ " 0×0 SparseArrays.SparseMatrixCSC{Float64,Int64} with 0 stored entries" ,
2306+ " 0×0 LinearAlgebra.Adjoint{Float64,SparseArrays.SparseMatrixCSC{Float64,Int64}} with 0 stored entries" ,
2307+ " 0×0 LinearAlgebra.Transpose{Float64,SparseArrays.SparseMatrixCSC{Float64,Int64}} with 0 stored entries"
2308+ ))
2309+ show (io, MIME " text/plain" (), transform (A))
2310+ @test String (take! (io)) == showstring
2311+ end
2312+
2313+ A = sparse (Int64[1 ], Int64[1 ], [1.0 ])
2314+ for (transform, showstring) in zip (
2315+ (identity, adjoint, transpose), (
2316+ " 1×1 SparseArrays.SparseMatrixCSC{Float64,Int64} with 1 stored entry:\n 1.0" ,
2317+ " 1×1 LinearAlgebra.Adjoint{Float64,SparseArrays.SparseMatrixCSC{Float64,Int64}} with 1 stored entry:\n 1.0" ,
2318+ " 1×1 LinearAlgebra.Transpose{Float64,SparseArrays.SparseMatrixCSC{Float64,Int64}} with 1 stored entry:\n 1.0" ,
2319+ ))
2320+ show (io, MIME " text/plain" (), transform (A))
2321+ @test String (take! (io)) == showstring
2322+ end
2323+
2324+ A = spzeros (Float32, Int64, 2 , 2 )
2325+ for (transform, showstring) in zip (
2326+ (identity, adjoint, transpose), (
2327+ " 2×2 SparseArrays.SparseMatrixCSC{Float32,Int64} with 0 stored entries:\n ⋅ ⋅ \n ⋅ ⋅ " ,
2328+ " 2×2 LinearAlgebra.Adjoint{Float32,SparseArrays.SparseMatrixCSC{Float32,Int64}} with 0 stored entries:\n ⋅ ⋅ \n ⋅ ⋅ " ,
2329+ " 2×2 LinearAlgebra.Transpose{Float32,SparseArrays.SparseMatrixCSC{Float32,Int64}} with 0 stored entries:\n ⋅ ⋅ \n ⋅ ⋅ " ,
2330+ ))
2331+ show (io, MIME " text/plain" (), transform (A))
2332+ @test String (take! (io)) == showstring
2333+ end
22942334
22952335 A = sparse (Int64[1 , 1 ], Int64[1 , 2 ], [1.0 , 2.0 ])
2296- show (io, MIME " text/plain" (), A)
2297- @test String (take! (io)) == " 1×2 SparseArrays.SparseMatrixCSC{Float64,Int64} with 2 stored entries:\n 1.0 2.0"
2298- _show_with_braille_patterns (convert (IOContext, io), A)
2299- @test String (take! (io)) == " ⠉"
2336+ for (transform, showstring, braille) in zip (
2337+ (identity, adjoint, transpose), (
2338+ " 1×2 SparseArrays.SparseMatrixCSC{Float64,Int64} with 2 stored entries:\n 1.0 2.0" ,
2339+ " 2×1 LinearAlgebra.Adjoint{Float64,SparseArrays.SparseMatrixCSC{Float64,Int64}} with 2 stored entries:\n 1.0\n 2.0" ,
2340+ " 2×1 LinearAlgebra.Transpose{Float64,SparseArrays.SparseMatrixCSC{Float64,Int64}} with 2 stored entries:\n 1.0\n 2.0" ,
2341+ ),
2342+ (" ⠉" , " ⠃" , " ⠃" ))
2343+ show (io, MIME " text/plain" (), transform (A))
2344+ @test String (take! (io)) == showstring
2345+ _show_with_braille_patterns (convert (IOContext, io), transform (A))
2346+ @test String (take! (io)) == braille
2347+ end
23002348
23012349 # every 1-dot braille pattern
23022350 for (i, b) in enumerate (split (" ⠁⠂⠄⡀⠈⠐⠠⢀" , " " ))
@@ -2308,25 +2356,47 @@ end
23082356
23092357 # empty braille pattern Char(10240)
23102358 A = spzeros (Int64, Int64, 4 , 2 )
2311- _show_with_braille_patterns (convert (IOContext, io), A)
2312- @test String (take! (io)) == " " * Char (10240 )
2359+ for (transform, braille) in zip (
2360+ (identity, adjoint, transpose),
2361+ (" " * Char (10240 ), " " * Char (10240 )^ 2 , " " * Char (10240 )^ 2 ))
2362+ _show_with_braille_patterns (convert (IOContext, io), transform (A))
2363+ @test String (take! (io)) == braille
2364+ end
23132365
23142366 A = sparse (Int64[1 , 2 , 4 , 2 , 3 ], Int64[1 , 1 , 1 , 2 , 2 ], Int64[1 , 1 , 1 , 1 , 1 ], 4 , 2 )
2315- show (io, MIME " text/plain" (), A)
2316- @test String (take! (io)) == " 4×2 SparseArrays.SparseMatrixCSC{Int64,Int64} with 5 stored entries:\n 1 ⋅\n 1 1\n ⋅ 1\n 1 ⋅"
2317- _show_with_braille_patterns (convert (IOContext, io), A)
2318- @test String (take! (io)) == " ⡳"
2367+ for (transform, showstring, braille) in zip (
2368+ (identity, adjoint, transpose), (
2369+ " 4×2 SparseArrays.SparseMatrixCSC{Int64,Int64} with 5 stored entries:\n 1 ⋅\n 1 1\n ⋅ 1\n 1 ⋅" ,
2370+ " 2×4 LinearAlgebra.Adjoint{Int64,SparseArrays.SparseMatrixCSC{Int64,Int64}} with 5 stored entries:\n 1 1 ⋅ 1\n ⋅ 1 1 ⋅" ,
2371+ " 2×4 LinearAlgebra.Transpose{Int64,SparseArrays.SparseMatrixCSC{Int64,Int64}} with 5 stored entries:\n 1 1 ⋅ 1\n ⋅ 1 1 ⋅" ,
2372+ ),
2373+ (" ⡳" , " ⠙⠊" , " ⠙⠊" ))
2374+ show (io, MIME " text/plain" (), transform (A))
2375+ @test String (take! (io)) == showstring
2376+ _show_with_braille_patterns (convert (IOContext, io), transform (A))
2377+ @test String (take! (io)) == braille
2378+ end
23192379
23202380 A = sparse (Int64[1 , 3 , 2 , 4 ], Int64[1 , 1 , 2 , 2 ], Int64[1 , 1 , 1 , 1 ], 7 , 3 )
2321- show (io, MIME " text/plain" (), A)
2322- @test String (take! (io)) == " 7×3 SparseArrays.SparseMatrixCSC{Int64,Int64} with 4 stored entries:\n 1 ⋅ ⋅\n ⋅ 1 ⋅\n 1 ⋅ ⋅\n ⋅ 1 ⋅\n ⋅ ⋅ ⋅\n ⋅ ⋅ ⋅\n ⋅ ⋅ ⋅"
2323- _show_with_braille_patterns (convert (IOContext, io), A)
2324- @test String (take! (io)) == " ⢕" * Char (10240 ) * " \n " * Char (10240 )^ 2
2381+ for (transform, showstring, braille) in zip (
2382+ (identity, adjoint, transpose), (
2383+ " 7×3 SparseArrays.SparseMatrixCSC{Int64,Int64} with 4 stored entries:\n 1 ⋅ ⋅\n ⋅ 1 ⋅\n 1 ⋅ ⋅\n ⋅ 1 ⋅\n ⋅ ⋅ ⋅\n ⋅ ⋅ ⋅\n ⋅ ⋅ ⋅" ,
2384+ " 3×7 LinearAlgebra.Adjoint{Int64,SparseArrays.SparseMatrixCSC{Int64,Int64}} with 4 stored entries:\n 1 ⋅ 1 ⋅ ⋅ ⋅ ⋅\n ⋅ 1 ⋅ 1 ⋅ ⋅ ⋅\n ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅" ,
2385+ " 3×7 LinearAlgebra.Transpose{Int64,SparseArrays.SparseMatrixCSC{Int64,Int64}} with 4 stored entries:\n 1 ⋅ 1 ⋅ ⋅ ⋅ ⋅\n ⋅ 1 ⋅ 1 ⋅ ⋅ ⋅\n ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅" ,
2386+ ),
2387+ (" ⢕" * Char (10240 ) * " \n " * Char (10240 )^ 2 , " ⠑⠑" * Char (10240 )^ 2 , " ⠑⠑" * Char (10240 )^ 2 ))
2388+ show (io, MIME " text/plain" (), transform (A))
2389+ @test String (take! (io)) == showstring
2390+ _show_with_braille_patterns (convert (IOContext, io), transform (A))
2391+ @test String (take! (io)) == braille
2392+ end
23252393
23262394 A = sparse (Int64[1 : 10 ;], Int64[1 : 10 ;], fill (Float64 (1 ), 10 ))
2327- _show_with_braille_patterns (convert (IOContext, io), A)
23282395 brailleString = " ⠑⢄" * Char (10240 )^ 3 * " \n " * Char (10240 )^ 2 * " ⠑⢄" * Char (10240 ) * " \n " * Char (10240 )^ 4 * " ⠑"
2329- @test String (take! (io)) == brailleString
2396+ for transform in (identity, adjoint, transpose)
2397+ _show_with_braille_patterns (convert (IOContext, io), transform (A))
2398+ @test String (take! (io)) == brailleString
2399+ end
23302400
23312401 # Issue #30589
23322402 @test repr (" text/plain" , sparse ([true true ])) == " 1×2 SparseArrays.SparseMatrixCSC{Bool,$Int } with 2 stored entries:\n 1 1"
0 commit comments