Skip to content

Commit c362b12

Browse files
committed
stem: don't coerce
1 parent 04896f6 commit c362b12

File tree

2 files changed

+6
-19
lines changed

2 files changed

+6
-19
lines changed

+stdlib/stem.m

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@
99
% * s: Character vector or string scalar containing the file name without directory or suffix.
1010
%
1111
% Note: fileparts() was about 100x faster then using multiple steps with pattern.
12+
1213
function s = stem(filepath)
13-
arguments
14-
filepath string
15-
end
1614

1715
[~, s, e] = fileparts(filepath);
1816

19-
i = stdlib.strempty(s);
20-
s(i) = e(i);
17+
if stdlib.strempty(s)
18+
s = e;
19+
end
2120

2221
end

test/TestStem.m

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
{"a/b/c.txt", "c"}, ...
1212
{"a/b/c.txt.gz", "c.txt"}, ...
1313
{"a/b/.c", ".c"}, ...
14-
{'a/b/.c', ".c"}, ...
14+
{'a/b/.c', '.c'}, ...
1515
{".config", ".config"}, ...
1616
{"", ""}, ...
17-
{'', ""}
17+
{'', ''}
1818
}
1919
end
2020

@@ -27,16 +27,4 @@ function test_stem(tc, p)
2727

2828
end
2929

30-
methods (Test, TestTags={'R2020b'})
31-
32-
function test_stem_array(tc)
33-
tc.assumeFalse(stdlib.matlabOlderThan('R2020b'))
34-
in = ["", ".txt", "a/b/c.txt", "a/b/c.txt.gz", "a/b/c"];
35-
exp = ["", ".txt", "c", "c.txt", "c"];
36-
out = stdlib.stem(in);
37-
tc.verifyEqual(out, exp)
38-
end
39-
40-
end
41-
4230
end

0 commit comments

Comments
 (0)