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
52 changes: 45 additions & 7 deletions Utilities/ComputationalGraph/ComputationalGraphInteractiveTool.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,23 @@

plotOptions

interactiveOptions

end

methods

function cgit = ComputationalGraphInteractiveTool(cg, varargin)

opt = struct('markStatic', true);
opt = struct('markStatic', true, ...
'interactiveOptions', []);
opt = merge_options(opt, varargin{:});

interactiveOptions = setDefaultJsonStructField(opt.interactiveOptions, {'printStackSelectionAfterUpdate', 'position'}, 'before');
interactiveOptions = setDefaultJsonStructField(interactiveOptions, 'plotAfterUpdate', true);

cgit.interactiveOptions = interactiveOptions;

cgit.computationalGraph = cg;

nodenames = cg.nodenames;
Expand Down Expand Up @@ -935,8 +943,7 @@ function diff(cgit)

varnames = varnameset{2};

familyVarnames = {};

familyvarnames = {};
for ivar = 1 : numel(varnames)

varname = varnames{ivar};
Expand All @@ -948,12 +955,12 @@ function diff(cgit)

varnameinds = varnameinds(levels <= level);

familyVarnames = union(familyVarnames, cg.nodenames(varnameinds));
familyvarnames = union(familyvarnames, cg.nodenames(varnameinds));


end

selection = {'set', familyVarnames};
selection = {'set', familyvarnames};
return

case 'diff'
Expand All @@ -979,6 +986,24 @@ function diff(cgit)
function printStack(cgit)

stack = cgit.stack;

doplot = getJsonStructField(cgit.interactiveOptions, {'plotAfterUpdate'}, false);

if doplot
cgit.plot();
end

position = getJsonStructField(cgit.interactiveOptions, {'printStackSelectionAfterUpdate', 'position'});

if isAssigned(position) && strcmp(position, 'before')

cgit.printHeader('Selection')
cgit.printStackSelection();
fprintf('\n');

end

cgit.printHeader('Selector stack');
for iselector = numel(stack) : -1 : 1
lines = cgit.setupSelectorPrint(stack{iselector});
nlines = numel(lines);
Expand All @@ -991,6 +1016,14 @@ function printStack(cgit)
fprintf('%s%s\n', start, lines{iline});
end
end

if isAssigned(position) && strcmp(position, 'after')

fprintf('\n');
cgit.printHeader('Stack selection result after parsing')
cgit.printStackSelection();

end

end

Expand Down Expand Up @@ -1275,8 +1308,13 @@ function printFunctionDocs(functionDocs, parfill, oneline)
end

function printHeader(headertxt, n)
% Minor utility function used in this class to print a header with a number
str = sprintf('\n%d %s', n, headertxt);
% Minor utility function used in this class to print a header. The optional argument n can be used to include a
% number at the beginning of the header (often needed).
if nargin < 2
str = sprintf('\n%s', headertxt);
else
str = sprintf('\n%d %s', n, headertxt);
end
fprintf('%s:\n', str);
fprintf('%s\n', repmat('-', length(str), 1));
end
Expand Down
2 changes: 2 additions & 0 deletions Utilities/ComputationalGraph/regexpSelect.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
end
inds = unique(inds);
else
name = replace(name, '{', '\{');
name = replace(name, '}', '\}');
name = regexprep(name, ' +', '.*');
inds = regexp(names, name, 'once');
inds = cellfun(@(x) ~isempty(x), inds);
Expand Down