diff --git a/src/PowerNetworkMatrix.jl b/src/PowerNetworkMatrix.jl index c3e9b7d0..61c63b10 100644 --- a/src/PowerNetworkMatrix.jl +++ b/src/PowerNetworkMatrix.jl @@ -303,7 +303,7 @@ function Base.show_nd( end end -function Base.show(io::IO, ::MIME{Symbol("text/plain")}, array::PowerNetworkMatrix) +function Base.show(io::IO, array::PowerNetworkMatrix) summary(io, array) isempty(array) && return println(io, ":") diff --git a/src/virtual_lodf_calculations.jl b/src/virtual_lodf_calculations.jl index 2e29a67c..e4f6e5fd 100644 --- a/src/virtual_lodf_calculations.jl +++ b/src/virtual_lodf_calculations.jl @@ -54,6 +54,14 @@ struct VirtualLODF{Ax, L <: NTuple{2, Dict}} <: PowerNetworkMatrix{Float64} tol::Base.RefValue{Float64} end +function Base.show(io::IO, ::MIME{Symbol("text/plain")}, array::VirtualLODF) + summary(io, array) + isempty(array) && return + println(io, ":") + Base.print_array(io, array) + return +end + function _get_PTDF_A_diag( K::KLU.KLUFactorization{Float64, Int}, BA::SparseArrays.SparseMatrixCSC{Float64, Int}, diff --git a/src/virtual_ptdf_calculations.jl b/src/virtual_ptdf_calculations.jl index 2ac60559..bf5e30f1 100644 --- a/src/virtual_ptdf_calculations.jl +++ b/src/virtual_ptdf_calculations.jl @@ -57,6 +57,14 @@ struct VirtualPTDF{Ax, L <: NTuple{2, Dict}} <: PowerNetworkMatrix{Float64} tol::Base.RefValue{Float64} end +function Base.show(io::IO, ::MIME{Symbol("text/plain")}, array::VirtualPTDF) + summary(io, array) + isempty(array) && return + println(io, ":") + Base.print_array(io, array) + return +end + """ Builds the PTDF matrix from a group of branches and buses. The return is a PTDF array indexed with the branch numbers. diff --git a/test/test_BA_ABA_matrix.jl b/test/test_BA_ABA_matrix.jl index a4d9a608..0ebdd801 100644 --- a/test/test_BA_ABA_matrix.jl +++ b/test/test_BA_ABA_matrix.jl @@ -79,3 +79,24 @@ end end @test test_val end + +@testset "Test show for A, BA and ABA matrix" begin + sys = PSB.build_system(PSB.PSITestSystems, "c_sys5") + + a = IncidenceMatrix(sys) + ba = BA_Matrix(sys) + aba = ABA_Matrix(sys) + + for mat in [a, ba, aba] + test_value = false + try + show(@eval a) + test_value = true + catch err + if err isa Exception + test_value = false + end + end + @test test_value + end +end diff --git a/test/test_virtual_lodf.jl b/test/test_virtual_lodf.jl index c53e5cd8..c5811f7e 100644 --- a/test/test_virtual_lodf.jl +++ b/test/test_virtual_lodf.jl @@ -103,9 +103,11 @@ end @testset "Test Virtual LODF auxiliary functions" begin sys = PSB.build_system(PSB.PSITestSystems, "c_sys5") + # test isempty when VirtualLODF is created (cache must be empty) vlodf = VirtualLODF(sys) @test isempty(vlodf) == true + # test eachindex and axes @test length(eachindex(vlodf)) == length(axes(vlodf)[1]) * length(axes(vlodf)[2]) @@ -119,4 +121,16 @@ end end end @test test_value + + # test show + test_value = false + try + show(vlodf) + test_value = true + catch err + if err isa Exception + test_value = false + end + end + @test test_value end diff --git a/test/test_virtual_ptdf.jl b/test/test_virtual_ptdf.jl index eb764f47..3ec4b509 100644 --- a/test/test_virtual_ptdf.jl +++ b/test/test_virtual_ptdf.jl @@ -177,4 +177,16 @@ end @test setdiff(PNM.get_branch_ax(vptdf), PSY.get_name.(PNM.get_ac_branches(sys))) == String[] @test setdiff(PNM.get_bus_ax(vptdf), PSY.get_number.(PNM.get_buses(sys))) == String[] + + # test show + test_value = false + try + show(vptdf) + test_value = true + catch err + if err isa Exception + test_value = false + end + end + @test test_value end