Skip to content

Commit 857077d

Browse files
committed
Matlab < R2019b compatibility
1 parent 01de948 commit 857077d

File tree

10 files changed

+31
-39
lines changed

10 files changed

+31
-39
lines changed

+stdlib/+legacy/set_permissions.m

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
function ok = set_permissions(file, readable, writable, executable)
2-
arguments
3-
file
4-
readable (1,1) {mustBeInteger}
5-
writable (1,1) {mustBeInteger}
6-
executable (1,1) {mustBeInteger}
7-
end
8-
92

103
mode = '';
114
% mode is space-delimited
@@ -34,7 +27,7 @@
3427
return
3528
end
3629

37-
[s, msg, id] = fileattrib(file, mode);
30+
[s, msg, id] = fileattrib(char(file), mode);
3831
ok = s == 1;
3932
if ~ok
4033
warning(id, "Failed to set permissions %s for %s: %s", mode, file, msg)

+stdlib/allToolboxes.m

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
%% ALLTOOLBOXES tell all the Matlab toolboxes known for this Matlab release
2-
% requires: java
2+
% requires: java, Matlab >= R2018a
33

44
function names = allToolboxes()
55

66
tbx = com.mathworks.product.util.ProductIdentifier.values; %#ok<JAPIMATHWORKS>
77

8-
% R2021a has a bug that requires the comma-separated syntax
98
names = table('Size', [numel(tbx), 2], ...
10-
'VariableTypes',["string", "string"], ...
11-
'VariableNames',["product", "license"]);
9+
'VariableTypes', {'string', 'string'}, ...
10+
'VariableNames', {'product', 'license'});
1211
names.product = string(tbx);
1312

1413
for i = 1:numel(tbx)
@@ -17,4 +16,4 @@
1716

1817
names = sortrows(names);
1918

20-
end
19+
end

+stdlib/get_pid.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
function pid = get_pid()
44

55
if stdlib.matlabOlderThan('R2025a')
6-
pid = feature("getpid");
6+
pid = feature('getpid');
77
else
88
pid = matlabProcessID;
99
end

+stdlib/is_matlab_online.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
function y = is_matlab_online()
77

8-
name = "MW_DDUX_APP_NAME";
8+
name = 'MW_DDUX_APP_NAME';
99
value = "MATLAB_ONLINE";
1010

1111
y = isunix() && ~ismac() && contains(getenv(name), value);

+stdlib/isinteractive.m

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
%% ISINTERACTIVE tell if being run interactively
1+
%% ISINTERACTIVE tell if graphical desktop is being used
2+
%
3+
% "matlab -nodesktop" mode outputs false.
24
%
3-
% we try to consider the "-nodesktop" mode as interactive.
45
% * get(0,'ScreenSize') often isn't relable anymore, it will show a display
56
% size on HPC for example, maybe due to Xvfb or such.
67
% Nowadays (R2025a+) one can make plots without Java enabled -nojvm too.
78

89

910
function g = isinteractive()
1011

11-
if batchStartupOptionUsed()
12+
if ~stdlib.matlabOlderThan('R2019b') && batchStartupOptionUsed()
1213
g = false;
1314
else
1415
g = matlab.desktop.editor.isEditorAvailable() || ...

+stdlib/matlab_bin_path.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
function mpaths = matlab_bin_path()
88

9-
mpaths.arch = computer("arch");
9+
mpaths.arch = computer('arch');
1010
mpaths.root = matlabroot;
1111

1212
mpaths.bin = fullfile(matlabroot, 'bin');

+stdlib/toolbox_used.m

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
% * funUser: all user function files under pkgPath
88

99
function [tbxMathworks, funUser] = toolbox_used(pkgPath)
10-
arguments
11-
pkgPath string
12-
end
1310

1411
[user, mathworks] = matlab.codetools.requiredFilesAndProducts(pkgPath);
1512

scripts/MatlabReleaseUpgrade.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function MatlabReleaseUpgrade()
4949

5050
function exe = legacy_update_path(name)
5151

52-
r = fullfile(matlabroot, 'bin', computer("arch"));
52+
r = fullfile(matlabroot, 'bin', computer('arch'));
5353
mustBeFolder(r)
5454
exe = fullfile(r, name);
5555

@@ -58,7 +58,7 @@ function MatlabReleaseUpgrade()
5858

5959
function exe = new_update_path(name)
6060

61-
arch = computer("arch");
61+
arch = computer('arch');
6262

6363
if ismac()
6464
head = fullfile(getenv('HOME'), 'Library/Application Support/MathWorks');

test/TestParent.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
classdef (SharedTestFixtures={ matlab.unittest.fixtures.PathFixture(fileparts(fileparts(mfilename('fullpath'))))}, ...
2-
TestTags = {'pure'}) ...
2+
TestTags = {'R2017b'}) ...
33
TestParent < matlab.unittest.TestCase
44

55
properties (TestParameter)
66
p = init_parent()
77
end
88

99

10-
methods (Test, TestTags={'R2019b'})
10+
methods (Test)
1111

1212
function test_parent(tc, p)
1313
pr = stdlib.parent(p{1});

test/TestPlatform.m

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
classdef (SharedTestFixtures={ matlab.unittest.fixtures.PathFixture(fileparts(fileparts(mfilename('fullpath'))))}, ...
2-
TestTags = {'R2019b', 'impure'}) ...
1+
classdef (SharedTestFixtures={ matlab.unittest.fixtures.PathFixture(fileparts(fileparts(mfilename('fullpath'))))}) ...
32
TestPlatform < matlab.unittest.TestCase
43

54
properties
65
CI = getenv('CI') == "true" || getenv('GITHUB_ACTIONS') == "true"
76
end
87

98

10-
methods (Test, TestTags = {'toolbox', 'java'})
9+
methods (Test, TestTags = {'R2018a', 'java', 'toolbox'})
1110
function test_all_toolboxes(tc)
11+
tc.assumeFalse(stdlib.matlabOlderThan('R2018a'))
1212
tc.assumeTrue(stdlib.has_java())
1313
tbx = stdlib.allToolboxes();
1414
tc.verifyClass(tbx, 'table')
1515
end
1616
end
1717

1818

19-
methods (Test, TestTags={'toolbox'})
19+
methods (Test, TestTags={'R2017b', 'toolbox'})
2020

2121
function test_toolbox_used(tc)
2222
r = fullfile(fileparts(fileparts(mfilename('fullpath'))), '+stdlib');
@@ -42,21 +42,23 @@ function test_has_parallel_toolbox(tc)
4242
end
4343

4444

45-
methods (Test)
46-
47-
function test_platform_tell(tc)
48-
r = stdlib.platform_tell();
49-
tc.verifyClass(r, 'char')
50-
tc.verifyNotEmpty(r)
51-
end
52-
53-
45+
methods (Test, TestTags={'R2018a'})
5446
function test_perl(tc)
47+
tc.assumeFalse(stdlib.matlabOlderThan('R2018a'))
5548
tc.verifyNotEmpty(stdlib.perl_exe())
5649
tc.verifyNotEmpty(stdlib.perl_version())
5750
tc.verifyTrue(stdlib.has_perl(), "Matlab docs indicate that Perl should always be available")
5851
end
52+
end
53+
5954

55+
methods (Test, TestTags={'R2017b'})
56+
57+
function test_platform_tell(tc)
58+
r = stdlib.platform_tell();
59+
tc.verifyClass(r, 'char')
60+
tc.verifyNotEmpty(r)
61+
end
6062

6163
function test_is_cygwin(tc)
6264
tc.verifyFalse(stdlib.is_cygwin())

0 commit comments

Comments
 (0)