Skip to content

Commit 076aea7

Browse files
zickgrafjames-d-mitchell
authored andcommitted
Print empty lists with two spaces for consistency
1 parent f42f693 commit 076aea7

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

gap/digraph.gi

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -699,8 +699,8 @@ InstallMethod(PrintString, "for a digraph", [IsDigraph], String);
699699
InstallMethod(String, "for a digraph",
700700
[IsDigraph],
701701
function(D)
702-
local n, N, i, mut, streps, outnbs_rep, lengths, strings, creators_streps,
703-
creators_props, props;
702+
local n, N, i, mut, streps, outnbs_rep, lengths, strings,
703+
out_neighbours_string, creators_streps, creators_props, props;
704704
if IsMutableDigraph(D) then
705705
mut := "IsMutableDigraph, ";
706706
else
@@ -722,7 +722,11 @@ function(D)
722722
ReplacedString(streps[n], "\\", "\\\\"), "\"", ")"));
723723
od;
724724

725-
outnbs_rep := Concatenation("Digraph(", mut, String(OutNeighbours(D)), ")");
725+
out_neighbours_string := String(OutNeighbours(D));
726+
# print empty lists with two spaces for consistency
727+
# see https://github.com/gap-system/gap/pull/5418
728+
out_neighbours_string := ReplacedString(out_neighbours_string, "[ ]", "[ ]");
729+
outnbs_rep := Concatenation("Digraph(", mut, out_neighbours_string, ")");
726730
Add(strings, String(outnbs_rep));
727731

728732
N := DigraphNrVertices(D);

tst/standard/digraph.tst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,9 +1179,9 @@ gap> gr1 := EmptyDigraph(0);;
11791179
gap> gr2 := DigraphCopy(gr1);
11801180
<immutable empty digraph with 0 vertices>
11811181
gap> String(gr2);
1182-
"Digraph([ ])"
1182+
"Digraph([ ])"
11831183
gap> PrintString(gr2);
1184-
"Digraph([ ])"
1184+
"Digraph([ ])"
11851185
gap> D := CycleDigraph(10 * 10 ^ 5);
11861186
<immutable cycle digraph with 1000000 vertices>
11871187
gap> D1 := DigraphCopy(D);
@@ -1348,7 +1348,7 @@ gap> list := [[1, 2], []];
13481348
gap> D := DigraphNC(IsMutableDigraph, list);
13491349
<mutable digraph with 2 vertices, 2 edges>
13501350
gap> PrintString(D);
1351-
"Digraph(IsMutableDigraph, [ [ 1, 2 ], [ ] ])"
1351+
"Digraph(IsMutableDigraph, [ [ 1, 2 ], [ ] ])"
13521352
gap> EvalString(String(D)) = D;
13531353
true
13541354
gap> DigraphByAdjacencyMatrix(IsMutableDigraph, []);
@@ -1802,7 +1802,7 @@ gap> String(G);
18021802
gap> D := Digraph([]);
18031803
<immutable empty digraph with 0 vertices>
18041804
gap> String(D);
1805-
"Digraph([ ])"
1805+
"Digraph([ ])"
18061806
gap> D := CompleteDigraph(7);
18071807
<immutable complete digraph with 7 vertices>
18081808
gap> String(D);

0 commit comments

Comments
 (0)