From 9af118eebfb36d4688125539f0917100851151f2 Mon Sep 17 00:00:00 2001 From: dcerkoney Date: Mon, 9 Oct 2023 20:15:44 -0400 Subject: [PATCH] Improve I/O for orders --- src/computational_graph/io.jl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/computational_graph/io.jl b/src/computational_graph/io.jl index a84c141b..32e20e88 100644 --- a/src/computational_graph/io.jl +++ b/src/computational_graph/io.jl @@ -17,6 +17,15 @@ function short(factor, ignore=nothing) end end +function short_orders(orders) + orders_no_trailing_zeros = "" + idx_last_set = findlast(x -> x != 0, orders) + if isnothing(idx_last_set) == false + orders_no_trailing_zeros *= string(orders[1:idx_last_set]) + end + return orders_no_trailing_zeros +end + function _stringrep(graph::AbstractGraph, color=true) namestr = isempty(graph.name) ? "" : "-$(graph.name)" idstr = "$(graph.id)$namestr" @@ -25,7 +34,7 @@ function _stringrep(graph::AbstractGraph, color=true) end fstr = short(graph.factor, one(graph.factor)) wstr = short(graph.weight) - ostr = string(orders(graph)) + ostr = short_orders(orders(graph)) # =$(node.weight*(2π)^(3*node.id.para.innerLoopNum)) if length(graph.subgraphs) == 0