@@ -38,6 +38,7 @@ using SparseArraysBase: SparseArrayDOK, SparseMatrixDOK, SparseVectorDOK, stored
3838using TensorAlgebra: contract
3939using Test: @test , @test_broken , @test_throws , @testset , @inferred
4040using TestExtras: @constinferred
41+ using TypeParameterAccessors: TypeParameterAccessors, Position
4142include (" TestBlockSparseArraysUtils.jl" )
4243
4344arrayts = (Array, JLArray)
@@ -1084,13 +1085,35 @@ arrayts = (Array, JLArray)
10841085 @test storedlength (b) == 17
10851086 end
10861087 @testset " show" begin
1088+ vectort_elt = arrayt{elt,1 }
1089+ matrixt_elt = arrayt{elt,2 }
1090+ arrayt_elt = arrayt{elt,3 }
1091+
1092+ a = BlockSparseVector {elt,arrayt{elt,1}} ([2 , 2 ])
1093+ @test sprint (summary, a) ==
1094+ " 2-blocked 4-element BlockSparseVector{$(elt) , $(vectort_elt) , …}"
1095+
1096+ a = BlockSparseMatrix {elt,arrayt{elt,2}} ([2 , 2 ], [2 , 2 ])
1097+ @test sprint (summary, a) ==
1098+ " 2×2-blocked 4×4 BlockSparseMatrix{$(elt) , $(matrixt_elt) , …}"
1099+
1100+ a = BlockSparseArray {elt,3,arrayt{elt,3}} ([2 , 2 ], [2 , 2 ], [2 , 2 ])
1101+ @test sprint (summary, a) ==
1102+ " 2×2×2-blocked 4×4×4 BlockSparseArray{$(elt) , 3, $(arrayt_elt) , …}"
1103+
10871104 if elt === Float64
10881105 # Not testing other element types since they change the
10891106 # spacing so it isn't easy to make the test general.
1090- a = BlockSparseArray {elt} ([2 , 2 ], [2 , 2 ])
1107+ a = BlockSparseMatrix {elt,arrayt{elt,2} } ([2 , 2 ], [2 , 2 ])
10911108 a[1 , 2 ] = 12
10921109 @test sprint (show, " text/plain" , a) ==
10931110 " $(summary (a)) :\n $(zero (eltype (a))) $(eltype (a)(12 )) │ . .\n $(zero (eltype (a))) $(zero (eltype (a))) │ . .\n ───────────┼──────\n . . │ . .\n . . │ . ."
10941111 end
10951112 end
1113+ @testset " TypeParameterAccessors.position" begin
1114+ @test TypeParameterAccessors. position (BlockSparseArray, eltype) == Position (1 )
1115+ @test TypeParameterAccessors. position (BlockSparseArray, ndims) == Position (2 )
1116+ @test TypeParameterAccessors. position (BlockSparseArray, blocktype) == Position (3 )
1117+ @test TypeParameterAccessors. position (BlockSparseArray, blockstype) == Position (4 )
1118+ end
10961119end
0 commit comments