Skip to content

Commit

Permalink
modifed 'makeRunDemos' so it calls each demo inside a try..catch bloc…
Browse files Browse the repository at this point in the history
…k, so if a demo says 'requireXXXtoolbox', it will automatically be skipped by runDemos; the old system which said 'if ~XXXinstalled then print 'skipping'" has been removed. Alos, makeRunDEmos now skips exclued files rather than commenting them out

git-svn-id: https://pmtk3.googlecode.com/svn/trunk@2764 b6abd7f4-f95b-11de-aa3c-59de0406b4f5
  • Loading branch information
[email protected] committed Apr 6, 2011
1 parent b236367 commit 690f446
Show file tree
Hide file tree
Showing 27 changed files with 3,776 additions and 581 deletions.
2 changes: 1 addition & 1 deletion demos/biclusterDemo.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
%% Bicluster Demo
% PMTKreallySlow
%PMTKreallySlow
%%

% This file is from pmtk3.googlecode.com
Expand Down
5 changes: 1 addition & 4 deletions demos/clusterYeast.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@

% This file is from pmtk3.googlecode.com

if ~bioinfoToolboxInstalled
disp('skipping demo, needs bioinfoToolbox');
return;
end

requireStatsToolbox
requireBioinfoToolbox
loadData('yeastData310') % 'X', 'genes', 'times');
Expand Down
7 changes: 2 additions & 5 deletions demos/demoPeaksTraj.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@

% This file is from pmtk3.googlecode.com

if ~optimToolboxInstalled
fprintf('%s requires optimization toolbox; skipping\n', mfilename())
return
end
%requireOptimToolbox;

requireOptimToolbox;
[X,Y] = meshgrid(linspace(-2.5,2.5,40),linspace(-3,3,50));
Z = peaks(X,Y);

Expand Down
6 changes: 1 addition & 5 deletions demos/demoRosen2d.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@

% This file is from pmtk3.googlecode.com

if ~optimToolboxInstalled
fprintf('%s requires optimization toolbox; skipping\n', mfilename())
return
end
%requireOptimToolbox;
requireOptimToolbox;
xstart = [-1 2];

% basic usage with anonymous function and numerical derivatives
Expand Down
5 changes: 1 addition & 4 deletions demos/demoRosenConstrained.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ function demoRosenConstrained()
% minimize 2d rosenbrock st x1^2 + x^2 <= 1
% Example from p1-8 of Mathworks Optimization Toolbox manual

if ~optimToolboxInstalled
fprintf('%s requires optimization toolbox; skipping\n', mfilename())
return
end
requiresOptimToolbox

xstart = [-1 2];
% Hessian is ignored by quasi-Newton so we use interior point
Expand Down
30 changes: 8 additions & 22 deletions demos/discreteDensityModelsShootout.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
pcTrain = 0.5; pcTest = 0.5;
pcMissing = 0.3;

%dataName = 'SUN09';
dataName = 'SUN09';
%dataName = 'newsgroups';
%dataName = 'newsgroups1';
dataName = 'ases4';
%dataName = 'ases4';

switch dataName
case 'newsgroups'
Expand Down Expand Up @@ -182,13 +182,12 @@
%}


%{

m = m + 1;
methods(m).modelname = 'dgm-init-tree';
methods(m).fitFn = @(labels) dgmFitStruct(labels, 'nodeNames', nodeNames, 'maxFamEvals', 1000, ...
'figFolder', figFolder, 'nrestarts', 0, 'initMethod', 'tree', 'edgeRestrict', 'MI');
methods(m).logprobFn = @(model, labels) dgmLogprob(model, 'obs', labels);
%}

%{
m = m + 1;
Expand Down Expand Up @@ -228,20 +227,6 @@



Ks = [1,5];
for kk=1:numel(Ks)
K = Ks(kk);
m = m + 1;
alpha = 1.1;
%methods(m).modelname = sprintf('mixK%d,a%2.1f', K, alpha);
methods(m).modelname = sprintf('mix%d', K);
methods(m).fitFn = @(labels) mixDiscreteFit(labels, K, 'maxIter', 30, ...
'verbose', false, 'alpha', 1.1);
methods(m).logprobFn = @(model, labels) mixDiscreteLogprob(model, labels);
methods(m).predictMissingFn = @(model, labels) mixDiscretePredictMissing(model, labels);
end


%{
Ks = [1,5,10,20,40];
for kk=1:numel(Ks)
Expand Down Expand Up @@ -436,7 +421,7 @@
[styles, colors, symbols, plotstr] = plotColors();


%{

% NLL - for catFA, which cannot compute valid loglik,
% we use NaNs
figure;
Expand All @@ -454,7 +439,7 @@
dataName, Nnodes, Ntrain, Ntest))
fname = fullfile(figFolder, sprintf('negloglik-%s.png', dataName));
print(gcf, '-dpng', fname);
%}


% imputation error
figure;
Expand Down Expand Up @@ -486,6 +471,8 @@
fname = fullfile(figFolder, sprintf('tree-%s', dataName))
graphviz(tree.edge_weights, 'labels', nodeNames, 'directed', 1, 'filename', fname);
end
%}


m = strfindCell('dgm', methodNames);
if ~isempty(m)
Expand All @@ -495,6 +482,7 @@
graphviz(dgm.G, 'labels', dgm.nodeNames, 'directed', 1, 'filename', fname);
end

%{
m = strfindCell('mrf-L1', methodNames);
if ~isempty(m)
mrf = models{m};
Expand All @@ -519,8 +507,6 @@
%title(sprintf('%5.3f', mix.mixWeight(k)))
end
end
%}

%{
Expand Down
5 changes: 1 addition & 4 deletions demos/dtreeDemoIris.m
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
% Demonstrate classification/decision tree on 2d 3class iris data
% From http://www.mathworks.com/products/statistics/demos.html?file=/products/demos/shipping/stats/classdemo.html

if ~statsToolboxInstalled
fprintf('cannot run %s without stats toolbox; skipping\n', mfilename())
return
end
requireStatsToolbox


% "Resubstitution error" is the training set error
Expand Down
2 changes: 2 additions & 0 deletions demos/glmnetDemo.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@


if ~glmnetInstalled
fprintf('cannot run %s without glmnet; skipping\n', mfilename());
return;
Expand Down
8 changes: 2 additions & 6 deletions demos/hclustYeastDemo.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@

% This file is from pmtk3.googlecode.com

%requireStatsToolbox
%requireBioinfoToolbox
if ~bioinfoToolboxInstalled
fprintf('cannot run %s without bioinformatics toolbox; skipping\n', mfilename());
return;
end
requireStatsToolbox
requireBioinfoToolbox
loadData('yeastData310') % 'X', 'genes', 'times');

corrDist = pdist(X, 'corr');
Expand Down
15 changes: 5 additions & 10 deletions demos/kmeansYeastDemo.m
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
%% Cluster yeast data using Kmeans
%PMTKneedBioToolbox redgreencmap
%%

% This file is from pmtk3.googlecode.com

%requireBioinfoToolbox
if ~bioinfoToolboxInstalled
fprintf('cannot run %s without bioinformatics toolbox; skipping\n', mfilename());
return;
end
loadData('yeastData310') % 'X', 'genes', 'times');
% This file is from pmtk3.googlecode.com


loadData('yeastData310') % 'X', 'genes', 'times');

figure;imagesc(X);colormap(redgreencmap)
figure;imagesc(X);
%colormap(redgreencmap) % bioinfoToolbox
colormap(redgreenColormap)
xlabel('time')
set(gca,'xticklabel',times)
ylabel('genes')
Expand Down
6 changes: 1 addition & 5 deletions demos/linregRobustDemo.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@
% This file is from pmtk3.googlecode.com

function linregRobustDemo()
%requireOptimToolbox
if ~optimToolboxInstalled
fprintf('cannot run %s without optimization toolbox; skipping\n', mfilename());
return;
end
requireOptimToolbox
seed = 0; setSeed(seed);
x = sort(rand(10,1));
y = 1+2*x + rand(size(x))-.5;
Expand Down
7 changes: 3 additions & 4 deletions demos/linregStudentTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
%PMTKauthor Yi Huang
%%


% This file is from pmtk3.googlecode.com

if ~optimToolboxInstalled
fprintf('cannot run %s without optimization toolbox; skipping\n', mfilename());
return;
end
requireOptimToolbox


seed = 0; setSeed(seed);
x = sort(rand(10,1));
Expand Down
5 changes: 1 addition & 4 deletions demos/mrfImageDenoisingApprox.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@
fprintf('cannot run %s without libdai; skipping\n', mfilename());
return;
end
if ~imagesToolboxInstalled
fprintf('cannot run %s without image processing toolbox; skipping\n', mfilename());
return;
end
requireImageToolbox
setSeed(0);
infEngine = 'libdaibp';
sz = 32;
Expand Down
5 changes: 1 addition & 4 deletions demos/qpDemo.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@

% This file is from pmtk3.googlecode.com

if ~optimToolboxInstalled
fprintf('cannot run %s without optim toolbox; skipping\n', mfilename());
return;
end
requireOptimToolbox
H = 2*eye(2);
g = -[3,0.25];
A = [1 1; 1 -1; -1 1; -1 -1];
Expand Down
15 changes: 13 additions & 2 deletions matlabTools/graphics/graphviz.m
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,12 @@ function graphviz(adj, varargin)


if ~isempty(filename)
cmd = sprintf('ps2pdf %s.ps %s.pdf', filename, filename);
if ismac
str = '/usr/local/bin/ps2pdf';
else
str = 'ps2pdf';
end
cmd = sprintf('%s %s.ps %s.pdf', str, filename, filename);
status = system(cmd);
if status ~= 0
error(sprintf('error executing %s', cmd));
Expand Down Expand Up @@ -183,8 +188,14 @@ function graphviz(adj, varargin)
opts = strcat(opts,' -Glandscape ');
end

if ismac
dotstr = '/usr/local/bin/dot';
else
dotstr = 'dot';
end
%cmd = strcat('C:\temp\graphviz-2.8\bin\dot ',opts,' -T ps -o graphVizIt.ps graphVizIt.txt ')
cmd = sprintf('dot %s -Tps %s -o %s', opts, dotname, outname);
cmd = sprintf('%s %s -Tps %s -o %s', dotstr, opts, dotname, outname);
%cmd = sprintf('dot -Tps %s -o %s', dotname, outname);
%cmd = sprintf('dot %s -Tpng %s -o %s', opts, dotname, outname);
status = system(cmd);
if status ~= 0
Expand Down
11 changes: 6 additions & 5 deletions matlabTools/metaTools/whoCallsMe.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@

% This file is from pmtk3.googlecode.com

[recache, recursive, verbose] = process_options(varargin, ...
[recache, recursive, verbose, skipBuiltin] = process_options(varargin, ...
'recache' , false, ...
'recursive', false, ...
'verbose', true);
'verbose', true, ...
'skipBuiltin', true);
%%
w = which(fname);

Expand All @@ -37,8 +38,8 @@
end
return
end
if startswith(w, matlabroot) || startswith(w, 'built-in (')
list = []; g = []; map = struct();
if skipBuiltin && (startswith(w, matlabroot) || startswith(w, 'built-in ('))
list = []; m =[]; g = []; map = struct();
if verbose
fprintf('%s is a built-in matlab function.\n', fname);
end
Expand Down Expand Up @@ -89,7 +90,7 @@
else
fprintf('The dependency graph is out of date\n\n');
[list, m, g, map] = whoCallsMe(fname, 'recache', true, ...
'recursive', recursive, 'verbose', verbose);
'recursive', recursive, 'verbose', verbose, 'skipBuiltin', skipBuiltin);
end
end

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ function requireOptimToolbox()
% Throw an error as the calling function if the optim toolbox is not installed

% This file is from pmtk3.googlecode.com


if ~optimToolboxInstalled
if isOctave
Expand Down
File renamed without changes.
9 changes: 8 additions & 1 deletion pmtkTools/getConfigValue.m
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,14 @@
end
end
end
remove = cellfun(@(c)~isvarname(c) || length(c) < 5, tags);
%remove = cellfun(@(c)~isvarname(c) || length(c) < 5, tags);
remove = [];
for i=1:numel(tags)
c = tags{i};
if ~isvarname(c) || length(c) < 5
remove = [remove i];
end
end
tags(remove) = [];
lines(remove) = [];
end
Loading

0 comments on commit 690f446

Please sign in to comment.