annotate scripts/testfun/private/dump_demos.m @ 18925:87324260043d

Improve plot comparison scripts. * compare_plot_demos.m: pass toolkits{} to html_compare_plot_demos. Give instructions for toolkit matlab. Fix whitespace issue. * dump_demos.m: fix typo in default dir. Consistently use dump_plot_demos.m for main worker script. Create diary and error messages for inclusion in html page. Set random seed for better comparison. * html_plot_demos_template.html: Allow variable toolkits (removed hard-coded gnuplot, matlab, fltk sequence). Fix some whitespace issues. * html_compare_plot_demos.m: Rewrite docstring. The instructions are no longer needed because compare_plot_demos handles them. Add "toolkits" and column_width param. Dynamically add toolkits in html, add diary.log link.
author Andreas Weber <andy.weber.aw@gmail.com>
date Tue, 15 Jul 2014 22:18:35 +0200
parents f9cf5ae6b8a2
children 4c45986a278e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
1 ## Copyright (C) 2010 Søren Hauberg
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
2 ##
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
3 ## This file is part of Octave.
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
4 ##
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
8 ## your option) any later version.
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
9 ##
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
13 ## General Public License for more details.
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
14 ##
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
17 ## <http://www.gnu.org/licenses/>.
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
18
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
19 ## -*- texinfo -*-
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
20 ## @deftypefn {Function File} {} dump_demos ()
18875
0075f3fba930 dump_demos.m: Update to match new plot directory structure
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18874
diff changeset
21 ## @deftypefnx {Function File} {} dump_demos (@var{dirs})
0075f3fba930 dump_demos.m: Update to match new plot directory structure
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18874
diff changeset
22 ## @deftypefnx {Function File} {} dump_demos (@var{dirs}, @var{mfile})
0075f3fba930 dump_demos.m: Update to match new plot directory structure
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18874
diff changeset
23 ## @deftypefnx {Function File} {} dump_demos (@var{dirs}, @var{mfile}, @var{fmt})
18895
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
24 ## Produce a script, with the name specified by @var{mfile}, containing
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
25 ## the demos in the directories, @var{dirs}. The demos are assumed to produce
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
26 ## graphical output, whose renderings are saved with the specified format,
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
27 ## @var{fmt}.
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
28 ##
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
29 ## The defaults for each input are;
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
30 ##
18895
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
31 ## @table @var
18875
0075f3fba930 dump_demos.m: Update to match new plot directory structure
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18874
diff changeset
32 ## @item @var{dirs}
18925
87324260043d Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18897
diff changeset
33 ## @code{@{"plot/appearance", "plot/draw", "plot/util", "image"@}}
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
34 ## @item @var{mfile}
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
35 ## @code{"dump.m"}
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
36 ## @item @var{fmt}
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
37 ## @code{"png"}
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
38 ## @end table
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
39 ##
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
40 ## For example, to produce PNG output for all demos of the functions
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
41 ## in the plot directory;
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
42 ##
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
43 ## @example
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
44 ## dump_demos plot dump.m png
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
45 ## @end example
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
46 ## @seealso{fntests, test, demo}
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
47 ## @end deftypefn
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
48
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
49 ## Author: Søren Hauberg <soren@hauberg.org>
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
50
18925
87324260043d Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18897
diff changeset
51 function dump_demos (dirs={"plot/appearance", "plot/draw", "plot/util", "image"}, output="dump_plot_demos.m", fmt="png")
18875
0075f3fba930 dump_demos.m: Update to match new plot directory structure
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18874
diff changeset
52
0075f3fba930 dump_demos.m: Update to match new plot directory structure
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18874
diff changeset
53 if (nargin > 3)
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
54 print_usage ();
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
55 endif
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
56
18895
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
57 if (ischar (dirs))
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
58 dirs = {dirs};
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
59 elseif (! iscellstr (dirs))
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
60 error ("dump_demos: DIRS must be a cell array of strings with directory names");
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
61 endif
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
62
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
63 [~, funcname, ext] = fileparts (output);
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
64 if (isempty (ext))
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
65 output = [output ".m"];
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
66 endif
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
67
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
68 ## Create script beginning (close figures, etc.)
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
69 fid = fopen (output, "w");
18875
0075f3fba930 dump_demos.m: Update to match new plot directory structure
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18874
diff changeset
70 fprintf (fid, "%% DO NOT EDIT! Generated automatically by dump_demos.m\n");
18895
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
71 fprintf (fid, "function %s ()\n", funcname);
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
72 fprintf (fid, "close all\n");
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
73 fprintf (fid, "more off\n");
18925
87324260043d Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18897
diff changeset
74 fprintf (fid, "diary diary.log\n");
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
75
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
76 ## Run and print the demos in each directory
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
77 for i = 1:numel (dirs)
18895
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
78 d = dirs{i};
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
79 if (! is_absolute_filename (d))
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
80 d = dir_in_loadpath (d);
18875
0075f3fba930 dump_demos.m: Update to match new plot directory structure
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18874
diff changeset
81 endif
18895
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
82 if (! exist (d, "dir"))
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
83 error ("dump_demos: directory %s does not exist", d);
18875
0075f3fba930 dump_demos.m: Update to match new plot directory structure
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18874
diff changeset
84 endif
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
85 dump_all_demos (d, fid, fmt);
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
86 endfor
18875
0075f3fba930 dump_demos.m: Update to match new plot directory structure
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18874
diff changeset
87
18925
87324260043d Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18897
diff changeset
88 ## Stop and flush diary
87324260043d Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18897
diff changeset
89 fprintf (fid, "diary off\n");
87324260043d Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18897
diff changeset
90
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
91 ## Create script ending
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
92 fprintf (fid, "end\n\n")
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
93
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
94 ## Close script
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
95 fclose (fid);
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
96 endfunction
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
97
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
98 function dump_all_demos (directory, fid, fmt)
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
99 dirinfo = dir (fullfile (directory, "*.m"));
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
100 flist = {dirinfo.name};
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
101 ## Remove uigetdir, uigetfile, uiputfile, etc.
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
102 flist = flist(! strncmp (flist, "ui", 2));
18895
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
103 ## Remove linkaxes, linkprops
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
104 flist = flist(! strncmp (flist, "link", 4));
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
105 ## Remove colormap
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
106 flist = flist(! strncmp (flist, "colormap", 8));
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
107 for i = 1:numel (flist)
18895
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
108 fcn = flist{i};
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
109 fcn(end-1:end) = []; # remove .m
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
110 demos = get_demos (fcn);
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
111 for d = 1:numel (demos)
18895
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
112 idx = sprintf ("%02d", d);
18925
87324260043d Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18897
diff changeset
113 base_fn = sprintf ("%s_%s", fcn, idx);
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
114 fprintf (fid, "\ntry\n");
18925
87324260043d Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18897
diff changeset
115 ## Invoke the ancient, deprecated random seed
87324260043d Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18897
diff changeset
116 ## generators, but there is an initialization mismatch with the more modern
87324260043d Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18897
diff changeset
117 ## generators reported here (https://savannah.gnu.org/bugs/?42557).
87324260043d Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18897
diff changeset
118 fprintf (fid, " rand ('seed', 1);\n");
18895
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
119 fprintf (fid, " %s\n\n", demos{d});
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
120 fprintf (fid, " drawnow;\n");
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
121 fprintf (fid, " fig = (get (0, 'currentfigure'));\n");
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
122 fprintf (fid, " if (~ isempty (fig))\n");
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
123 fprintf (fid, " figure (fig);\n");
18925
87324260043d Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18897
diff changeset
124 fprintf (fid, " name = '%s.%s';\n", base_fn, fmt);
18895
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
125 fprintf (fid, " if (isempty (dir (name)))\n");
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
126 fprintf (fid, " fprintf ('Printing ""%%s"" ... ', name);\n")
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
127 fprintf (fid, " print ('-d%s', name);\n", fmt);
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
128 fprintf (fid, " fprintf ('done\\n');\n");
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
129 fprintf (fid, " else\n");
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
130 fprintf (fid, " fprintf ('File ""%%s"" exists.\\n', name);\n")
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
131 fprintf (fid, " end\n");
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
132 fprintf (fid, " end\n");
18895
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
133 # Temporary fix for cruft accumulating in figure window.
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
134 fprintf (fid, " close ('all');\n");
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
135 fprintf (fid, "catch\n");
18925
87324260043d Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18897
diff changeset
136 fprintf (fid, " fprintf ('ERROR in %s: %%s\\n', lasterr ());\n", base_fn);
87324260043d Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18897
diff changeset
137 fprintf (fid, " err_fid = fopen ('%s.err', 'w');\n", base_fn);
87324260043d Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18897
diff changeset
138 fprintf (fid, " fprintf (err_fid, '%%s', lasterr ());\n");
87324260043d Improve plot comparison scripts.
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18897
diff changeset
139 fprintf (fid, " fclose (err_fid);\n");
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
140 fprintf (fid, "end\n\n");
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
141 endfor
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
142 endfor
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
143 fprintf (fid, "close all\n");
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
144 endfunction
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
145
18895
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
146 function retval = get_demos (fcn)
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
147 [code, idx] = test (fcn, "grabdemo");
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
148 num_demos = length (idx) - 1;
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
149 retval = cell (1, num_demos);
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
150 ## Now split the demos into a cell array
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
151 for k = 1:num_demos
18895
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
152 retval{k} = oct2mat (code(idx(k):idx(k+1)-1));
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
153 endfor
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
154 endfunction
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
155
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
156 function code = oct2mat (code)
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
157 ## Simple hacks to make things Matlab compatible
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
158 code = strrep (code, "%!", "%%");
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
159 code = strrep (code, "!", "~");
18895
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
160 ## Simply replacing double quotes with single quotes
18875
0075f3fba930 dump_demos.m: Update to match new plot directory structure
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18874
diff changeset
161 ## causes problems with strings like 'hello "world"'
18895
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
162 ## More complicated regexprep targets only full double quoted strings
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
163 code = regexprep (code, "^([^']*)\"(.*)\"", "$1'$2'",
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
164 "lineanchors", "dotexceptnewline");
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
165 code = strrep (code, "#", "%");
18895
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
166 ## Fix the format specs for the errorbar demos changed by the line above
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
167 code = strrep (code, "%r", "#r");
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
168 code = strrep (code, "%~", "#~");
18895
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
169 endkeywords = {"endfor", "endfunction", "endif", "endwhile", "end_try_catch"};
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
170 for k = 1:numel (endkeywords)
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
171 code = strrep (code, endkeywords{k}, "end");
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
172 endfor
18895
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
173 commentkeywords = {"unwind_protect", "end_unwind_protect"};
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
174 for k = 1:numel (commentkeywords)
18895
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
175 code = strrep (code, commentkeywords{k}, ["%" commentkeywords{k}]);
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
176 endfor
18895
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
177
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
178 ## Fix up sombrero which now has default argument in Octave
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
179 code = strrep (code, "sombrero ()", "sombrero (41)");
18874
c74673161752 Add scripts to help validate plot results.
Ben Abbott <bpabbott@mac.com>
parents:
diff changeset
180 endfunction
18895
b8934a57e13e Improve plot comparison scripts.
Rik <rik@octave.org>
parents: 18877
diff changeset
181