Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion PackageInfo.g
Original file line number Diff line number Diff line change
Expand Up @@ -539,9 +539,10 @@ PackageDoc := rec(
),

Dependencies := rec(
GAP := ">=4.10.0",
GAP := ">=4.11.0",
NeededOtherPackages := [["IO", ">=4.5.1"],
["orb", ">=4.8.2"],
["GraphViz", ">=0.0.0"],
["datastructures", ">=0.2.5"]],
SuggestedOtherPackages := [["GAPDoc", ">=1.6.3"],
["GRAPE", ">=4.8.1"],
Expand Down
846 changes: 332 additions & 514 deletions doc/display.xml

Large diffs are not rendered by default.

15 changes: 13 additions & 2 deletions doc/z-chap9.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
<Chapter Label="Visualising and IO"><Heading>Visualising and IO</Heading>

<Section><Heading>Visualising a digraph</Heading>
<#Include Label="Splash">
<#Include Label="GraphvizDigraph">
<#Include Label="DotDigraph">
<#Include Label="DotSymmetricDigraph">

<#Include Label="GraphvizColoredDigraph">
<#Include Label="DotColoredDigraph">

<#Include Label="GraphvizVertexLabelledDigraph">
<#Include Label="DotVertexLabelledDigraph">

<#Include Label="GraphvizPartialOrderDigraph">
<#Include Label="DotPartialOrderDigraph">

<#Include Label="GraphvizPreorderDigraph">
<#Include Label="DotPreorderDigraph">

<#Include Label="GraphvizHighlightedDigraph">
<#Include Label="DotHighlightedDigraph">
</Section>

Expand Down
151 changes: 151 additions & 0 deletions etc/code-coverage-test-c.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
#!/usr/bin/env python
"""
"""

# pylint: disable=invalid-name, broad-except

import argparse
import tempfile
import subprocess
import sys
import os
import webbrowser

from os.path import exists, isfile

_ERR_PREFIX = '\033[31merror: '

def exec_string(string):
'execute the string in a subprocess.'
try:
subprocess.check_call(string, shell=True)
except KeyboardInterrupt:
sys.exit('\033[31m\nKilled!\033[0m')
except (subprocess.CalledProcessError, OSError):
sys.exit(_ERR_PREFIX + 'executing:\n' + string + '\n failed!\033[0m')

_PARSER = argparse.ArgumentParser(prog='code-coverage-test-c.py',
usage='%(prog)s [options]')
_PARSER.add_argument('files', nargs='+', type=str,
help='the test files you want to check code coverage for'
+ '(must be at least one)')
_PARSER.add_argument('--gap-root', nargs='?', type=str,
help='the gap root directory (default: ~/gap)',
default='~/gap/')
_PARSER.add_argument('--pkg', nargs='?', type=str,
help='the package to profile (default: None)',
default=None)
_PARSER.add_argument('--build', dest='build', action='store_true',
help='rebuild GAP (default: False)')
_PARSER.set_defaults(build=False)
_PARSER.add_argument('--open', nargs='?', type=str,
help=('open the lcov html page for this file ' +
'(default: None)'),
default=None)
_PARSER.add_argument('--line', nargs='?', type=str,
help=('open the html page for the file specified by --open' +
' at this line (default: None)'),
default=None)
_ARGS = _PARSER.parse_args()

if not _ARGS.gap_root[-1] == '/':
_ARGS.gap_root += '/'

_ARGS.gap_root = os.path.expanduser(_ARGS.gap_root)
if _ARGS.pkg != None:
_ARGS.pkg = _ARGS.gap_root + '/pkg/' + _ARGS.pkg

if not (os.path.exists(_ARGS.gap_root) and os.path.isdir(_ARGS.gap_root)):
sys.exit('\033[31mcode-coverage-test-c.py: error: can\'t find gap root' +
' directory!\033[0m')
if (_ARGS.pkg != None and not (os.path.exists(_ARGS.pkg) and
os.path.isdir(_ARGS.pkg))):
sys.exit('\033[31mcode-coverage-test-c.py: error: can\'t find the pkg' +
' directory %s\033[0m' % _ARGS.pkg)
for f in _ARGS.files:
if not (os.path.exists(f) and os.path.isfile(f)):
sys.exit('\033[31mcode-coverage-test-c.py: error: ' + f +
' does not exist!\033[0m')

_DIR = tempfile.mkdtemp()
print('\033[35musing temporary directory: ' + _DIR + '\033[0m')

_COMMANDS = 'echo "'
for f in _ARGS.files:
_COMMANDS += 'Test(\\"' + f + '\\");;'
_COMMANDS += '"'

# TODO build if files changed since last build or built with the wrong flags,
# by looking in config.log

# for source in :
# if time.ctime(os.path.getmtime(file))

if _ARGS.build:
cwd = os.getcwd()
os.chdir(_ARGS.gap_root)
exec_string('''rm -rf bin/ && \
make clean && \
./configure CFLAGS="-O0 -g --coverage" \
CXXFLAGS="-O0 -g --coverage" \
LDFLAGS="-O0 -g --coverage" && \
make -j8''')
if _ARGS.pkg != None:
os.chdir(_ARGS.pkg)
exec_string('rm -rf bin/ && \
make clean && \
./configure CFLAGS="-O0 -g --coverage" \
CXXFLAGS="-O0 -g --coverage" \
LDFLAGS="-O0 -g --coverage" && \
make -j8''')
os.chdir(cwd)

pro1 = subprocess.Popen(_COMMANDS, stdout=subprocess.PIPE, shell=True)
_RUN_GAP = _ARGS.gap_root + 'bin/gap.sh -A -m 1g -T'

try:
pro2 = subprocess.Popen(_RUN_GAP,
stdin=pro1.stdout,
shell=True)
pro2.wait()
print('')
except KeyboardInterrupt:
pro1.terminate()
pro1.wait()
pro2.terminate()
pro2.wait()
print('\033[31mKilled!\033[0m')
sys.exit(1)
except Exception:
sys.exit('\033[31mcode-coverage-test-c.py: error: something went wrong '
+ 'calling GAP!\033[0m''')
if _ARGS.pkg != None:
exec_string('lcov --capture --directory ' + _ARGS.pkg +
'/src --output-file ' + _DIR + '/lcov.info')
else:
exec_string('lcov --capture --directory ' + _ARGS.gap_root +
'/src --output-file ' + _DIR + '/lcov.info')

exec_string('genhtml ' + _DIR + '/lcov.info --output-directory ' + _DIR +
'/lcov-out')

filename = _DIR + '/lcov-out/'
if _ARGS.open:
filename += _ARGS.open + '.gcov.html'
else:
filename += '/index.html'

if exists(filename) and isfile(filename):
if _ARGS.open and _ARGS.line:
filename += '#' + _ARGS.line
print('file://' + filename)
try:
webbrowser.get('chrome').open('file://' + filename, new=2)
except Exception:
webbrowser.open('file://' + filename, new=2)
else:
sys.exit('\n' + _ERR_PREFIX + 'Failed to open file://' + filename +
'\033[0m')

print('\n\033[32mSUCCESS!\033[0m')
sys.exit(0)
2 changes: 1 addition & 1 deletion etc/code-coverage-test-gap.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
_GAP_COMMANDS.extend(
[
"UncoverageLineByLine();;",
rf"LoadPackage(\"profiling\", false);;",
r"LoadPackage(\"profiling\", false);;",
rf"filesdir := \"{getcwd()}{_PROFILE_DIR}\";;",
rf"outdir := \"{_DIR}\";;",
rf"x := ReadLineByLineProfile(\"{_DIR}/profile.gz\");;",
Expand Down
35 changes: 35 additions & 0 deletions gap/deprecated.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#############################################################################
##
## deprecated.gd
## Copyright (C) 2024 James D. Mitchell
##
## Licensing information can be found in the README file of this package.
##
#############################################################################
##

DeclareAttribute("DotDigraph", IsDigraph);
DeclareAttribute("DotSymmetricDigraph", IsDigraph);

DeclareOperation("DotSymmetricVertexColoredDigraph", [IsDigraph, IsList]);
DeclareOperation("DotVertexColoredDigraph", [IsDigraph, IsList]);

DeclareOperation("DotEdgeColoredDigraph", [IsDigraph, IsList]);
DeclareOperation("DotSymmetricEdgeColoredDigraph", [IsDigraph, IsList]);

DeclareOperation("DotColoredDigraph", [IsDigraph, IsList, IsList]);
DeclareOperation("DotSymmetricColoredDigraph", [IsDigraph, IsList, IsList]);

DeclareOperation("DotVertexLabelledDigraph", [IsDigraph]);

DeclareAttribute("DotPartialOrderDigraph", IsDigraph);
DeclareAttribute("DotPreorderDigraph", IsDigraph);

DeclareSynonym("DotQuasiorderDigraph", DotPreorderDigraph);

DeclareOperation("DotHighlightedDigraph", [IsDigraph, IsList]);
DeclareOperation("DotHighlightedDigraph",
[IsDigraph, IsList, IsString, IsString]);
DeclareOperation("DotHighlightedGraph", [IsDigraph, IsList]);
DeclareOperation("DotHighlightedGraph",
[IsDigraph, IsList, IsString, IsString]);
116 changes: 116 additions & 0 deletions gap/deprecated.gi
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
#############################################################################
##
## deprecated.gi
## Copyright (C) 2024 James D. Mitchell
##
## Licensing information can be found in the README file of this package.
##
#############################################################################
##

BindGlobal("_PrintDeprecated", function(old, arg...)
Info(InfoWarning, 1, "`", old, "` is deprecated and will be removed in v3",
" use `", Concatenation(List(arg, AsString)), "` instead!");
end);

InstallMethod(DotDigraph, "for a digraph", [IsDigraph],
function(D)
_PrintDeprecated("DotDigraph", "GraphvizDigraph");
return AsString(GraphvizDigraph(D));
end);

InstallMethod(DotSymmetricDigraph, "for a digraph", [IsDigraph],
function(D)
_PrintDeprecated("DotSymmetricDigraph", "GraphvizGraph");
return AsString(GraphvizGraph(D));
end);

InstallMethod(DotSymmetricVertexColoredDigraph,
"for a digraph and list of colors",
[IsDigraph, IsHomogeneousList],
function(D, colors)
_PrintDeprecated("DotSymmetricVertexColoredDigraph",
"GraphvizVertexColoredGraph");
return AsString(GraphvizVertexColoredGraph(D, colors));
end);

InstallMethod(DotVertexColoredDigraph, "for a digraph and a list",
[IsDigraph, IsList],
function(D, colors)
_PrintDeprecated("DotVertexColoredDigraph",
"GraphvizVertexColoredDigraph");
return AsString(GraphvizVertexColoredDigraph(D, colors));
end);

InstallMethod(DotSymmetricEdgeColoredDigraph,
"for a digraph and list of colors",
[IsDigraph, IsHomogeneousList],
function(D, colors)
_PrintDeprecated("DotSymmetricEdgeColoredDigraph",
"GraphvizEdgeColoredGraph");
return AsString(GraphvizEdgeColoredGraph(D, colors));
end);

InstallMethod(DotEdgeColoredDigraph, "for a digraph and a list",
[IsDigraph, IsList],
function(D, colors)
_PrintDeprecated("DotEdgeColoredDigraph",
"GraphvizEdgeColoredDigraph");
return AsString(GraphvizEdgeColoredDigraph(D, colors));
end);

InstallMethod(DotSymmetricColoredDigraph,
"for a digraph, vertex colors, and edge colors",
[IsDigraph, IsHomogeneousList, IsHomogeneousList],
function(D, n_colors, e_colors)
_PrintDeprecated("DotSymmetricColoredDigraph",
"GraphvizColoredGraph");
return AsString(GraphvizColoredGraph(D, n_colors, e_colors));
end);

InstallMethod(DotColoredDigraph,
"for a digraph, vertex colors, and edge colors",
[IsDigraph, IsHomogeneousList, IsHomogeneousList],
function(D, n_colors, e_colors)
_PrintDeprecated("DotColoredDigraph",
"GraphvizColoredDigraph");
return AsString(GraphvizColoredDigraph(D, n_colors, e_colors));
end);

InstallMethod(DotVertexLabelledDigraph, "for a digraph", [IsDigraph],
function(D)
_PrintDeprecated("DotVertexLabelledDigraph",
"GraphvizVertexLabelledDigraph");
return AsString(GraphvizVertexLabelledDigraph(D));
end);

InstallMethod(DotPartialOrderDigraph, "for a digraph", [IsDigraph],
function(D)
_PrintDeprecated("DotPartialOrderDigraph",
"GraphvizPartialOrderDigraph");
return AsString(GraphvizPartialOrderDigraph(D));
end);

InstallMethod(DotPreorderDigraph, "for a digraph", [IsDigraph],
function(D)
_PrintDeprecated("DotPreorderDigraph",
"GraphvizPreorderDigraph");
return AsString(GraphvizPreorderDigraph(D));
end);

InstallMethod(DotHighlightedDigraph,
"for a digraph, list, and two strings",
[IsDigraph, IsList, IsString, IsString],
function(D, hi_verts, hi, lo)
_PrintDeprecated("DotHighlightedDigraph",
"GraphvizHighlightedDigraph");
return AsString(GraphvizHighlightedDigraph(D, hi_verts, hi, lo));
end);

InstallMethod(DotHighlightedDigraph, "for a digraph and list",
[IsDigraph, IsList],
function(D, list)
_PrintDeprecated("DotHighlightedDigraph",
"GraphvizHighlightedDigraph");
return AsString(GraphvizHighlightedDigraph(D, list, "black", "grey"));
end);
Loading
Loading