diff --git a/src/compgraph_struct.jl b/src/compgraph_struct.jl index 1d3849e..467f9b4 100644 --- a/src/compgraph_struct.jl +++ b/src/compgraph_struct.jl @@ -319,7 +319,7 @@ function set_coeffs!(graph, x, cref = get_all_cref(graph)) end if !(length(x) == length(cref)) error( - "Vector of coefficients and defined set of coefficients" * + "Vector of coefficients and defined set of coefficients " * "do not have the same length.", ) end diff --git a/test/graph_ops.jl b/test/graph_ops.jl index 1548ea0..dc0933f 100644 --- a/test/graph_ops.jl +++ b/test/graph_ops.jl @@ -67,6 +67,12 @@ using LinearAlgebra, Polynomials add_lincomb!(graph, :AI, 2.0, :A, 2.0, :I) add_mult!(graph, :Pout, :AI, :A) add_output!(graph, :Pout) + try + rename_node!(graph, :Z, :Z_new) + catch e + @test e isa Exception + @test sprint(showerror, e) == "Node Z not present in the graph." + end graph1 = deepcopy(graph) rename_node!(graph1, :AI, :B) @@ -92,4 +98,19 @@ using LinearAlgebra, Polynomials del_output!(graph, :Pout) @test isempty(graph.outputs) + # Setting and getting coefficients + graph = Compgraph() + add_lincomb!(graph, :B, [1.0], [:A]) + add_output!(graph, :B) + set_coeffs!(graph, 2.0) + @test graph.coeffs[:B][1] == 2.0 + try + set_coeffs!(graph, [1.0, 2.0]) + catch e + @test e isa Exception + @test sprint(showerror, e) == "Vector of coefficients and defined " * + "set of coefficients do not have the same length." + end + @test get_coeffs(graph) == [2.0] + end diff --git a/test/topo_order.jl b/test/topo_order.jl index 8ea5b0d..f447c55 100644 --- a/test/topo_order.jl +++ b/test/topo_order.jl @@ -29,4 +29,13 @@ using LinearAlgebra helper[:Z2] = -1 order = get_topo_order(g, priohelp = helper, will_not_dealloc = [:I])[1] @test order[1:4] == [:X1; :X2; :X3; :Z1] + + add_mult!(g, :Z, :B, :B) + try + get_topo_order(g) + catch e + @test e isa Exception + @test sprint(showerror, e) == + "Graph is disconnected. Nodes [:Z] cannot be computed." + end end