@@ -12,6 +12,20 @@ using StableRNGs: StableRNG
1212using Test: @test , @test_broken , @test_throws , @testset
1313using TestExtras: @constinferred
1414
15+ module TestBasicsUtils
16+ using KroneckerArrays: KroneckerArrays
17+
18+ struct WrappedKroneckerArray{T, N, A <: AbstractArray{T, N} , B <: AbstractArray{T, N} } < :
19+ KroneckerArrays. AbstractKroneckerArray{T, N}
20+ a:: A
21+ b:: B
22+ end
23+ function WrappedKroneckerArray (a:: AbstractArray{T, N} , b:: AbstractArray{T, N} ) where {T, N}
24+ return WrappedKroneckerArray {T, N, typeof(a), typeof(b)} (a, b)
25+ end
26+ KroneckerArrays. kroneckerfactors (ab:: WrappedKroneckerArray ) = (ab. a, ab. b)
27+ end
28+
1529elts = (Float32, Float64, ComplexF32, ComplexF64)
1630@testset " KroneckerArrays (eltype=$elt )" for elt in elts
1731 p = [1 , 2 ] × [3 , 4 , 5 ]
@@ -141,6 +155,11 @@ elts = (Float32, Float64, ComplexF32, ComplexF64)
141155 @test bc. style === style
142156 @test collect (copy (bc)) ≈ 2 * collect (a)
143157
158+ # Display
159+ aw = TestBasicsUtils. WrappedKroneckerArray (randn (elt, 2 , 2 ), randn (elt, 3 , 3 ))
160+ @test occursin (" ⊗ " , sprint (show, aw))
161+ @test occursin (" \n ⊗\n " , sprint (show, MIME (" text/plain" ), aw))
162+
144163 # Mapping
145164 a = randn (elt, 2 , 2 ) ⊗ randn (elt, 3 , 3 )
146165 @test_throws " not supported" map (sin, a)
0 commit comments