Skip to content

Commit 8a007f8

Browse files
committed
add has_parallel_toolbox()
1 parent e96e1d4 commit 8a007f8

File tree

2 files changed

+39
-6
lines changed

2 files changed

+39
-6
lines changed

+stdlib/has_parallel_toolbox.m

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
%% HAS_PARALLEL_TOOLBOX does the user have Parallel Computing Toolbox and the license available for it?
2+
% This deliberately doesn't catch the case where the toolbox and license is valid, but there aren't
3+
% enough licenses, so that the user knows what's happening.
4+
% The user can use stdlib.checkout_license() to affirm that the license is available at the time of the call.
5+
6+
function y = has_parallel_toolbox()
7+
8+
try
9+
gcp('nocreate');
10+
y = true;
11+
catch e
12+
if e.identifier ~= "MATLAB:UndefinedFunction"
13+
rethrow(e)
14+
end
15+
y = false;
16+
end
17+
18+
end

test/TestPlatform.m

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,16 @@
77
end
88

99

10-
methods (Test)
10+
methods (Test, TestTags = {'toolbox', 'java'})
11+
function test_all_toolboxes(tc)
12+
tc.assumeTrue(stdlib.has_java())
13+
tbx = stdlib.allToolboxes();
14+
tc.verifyClass(tbx, "table")
15+
end
16+
end
17+
18+
19+
methods (Test, TestTags={'toolbox'})
1120

1221
function test_toolbox_used(tc)
1322
r = fullfile(fileparts(fileparts(mfilename('fullpath'))), '+stdlib');
@@ -23,12 +32,18 @@ function test_toolbox_used(tc)
2332
tc.verifyEqual(length(mathworksUsed), 1)
2433
end
2534

26-
function test_all_toolboxes(tc)
27-
tc.assumeTrue(stdlib.has_java())
28-
tbx = stdlib.allToolboxes();
29-
tc.verifyClass(tbx, "table")
35+
36+
function test_has_parallel_toolbox(tc)
37+
y = stdlib.has_parallel_toolbox();
38+
tc.verifyClass(y, 'logical')
39+
tc.verifyNotEmpty(y)
40+
end
41+
3042
end
3143

44+
45+
methods (Test)
46+
3247
function test_platform_tell(tc)
3348
r = stdlib.platform_tell();
3449
tc.verifyClass(r, 'char')
@@ -112,4 +127,4 @@ function test_cpu_count(tc)
112127

113128
end
114129

115-
end
130+
end

0 commit comments

Comments
 (0)