Skip to content

Commit f2b253a

Browse files
committed
arrayfun
1 parent 355ec66 commit f2b253a

File tree

10 files changed

+26
-29
lines changed

10 files changed

+26
-29
lines changed

+stdlib/+java/hard_link_count.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
function c = hard_link_count(p)
22

3-
opt = javaMethod("values", "java.nio.file.LinkOption");
3+
opt = java.nio.file.LinkOption.values();
44
c = java.nio.file.Files.getAttribute(javaPathObject(p), "unix:nlink", opt);
55

66
end

+stdlib/h4exists.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
%%% Outputs
88
% * exists: boolean
99
arguments
10-
file {mustBeTextScalar}
11-
variable {mustBeTextScalar}
10+
file
11+
variable (1,1) string
1212
end
1313

1414
sds = hdfinfo(file).SDS;

+stdlib/h4variables.m

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
% * names: variable names
1010

1111
function names = h4variables(file)
12-
arguments
13-
file {mustBeTextScalar}
14-
end
1512

1613
finf = hdfinfo(file);
1714

+stdlib/h5exists.m

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
function exists = h5exists(file, variable)
1010
arguments
11-
file {mustBeTextScalar}
12-
variable {mustBeTextScalar}
11+
file
12+
variable (1,1) string
1313
end
1414

1515
exists = false;
@@ -18,9 +18,7 @@
1818
h5info(file, variable);
1919
exists = true;
2020
catch e
21-
if ~strcmp(e.identifier, 'MATLAB:imagesci:h5info:unableToFind') && ...
22-
~strncmp(e.message, "h5info: location", 16)
23-
disp(e)
21+
if ~strcmp(e.identifier, 'MATLAB:imagesci:h5info:unableToFind')
2422
rethrow(e)
2523
end
2624
end

+stdlib/h5save.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function h5save(filename, varname, A, opts)
2424
varname (1,1) string
2525
A {mustBeNonempty}
2626
opts.size (1,:) double {mustBeInteger,mustBeNonnegative} = []
27-
opts.type {mustBeTextScalar} = ''
27+
opts.type (1,1) string = ""
2828
opts.compressLevel (1,1) double {mustBeInteger,mustBeNonnegative} = 0
2929
end
3030

+stdlib/h5size.m

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,10 @@
77
% fsize: vector of variable size per dimension. Empty if scalar variable.
88

99
function fsize = h5size(file, variable)
10-
arguments
11-
file {mustBeTextScalar}
12-
variable {mustBeTextScalar}
13-
end
1410

1511
dsi = h5info(file, variable).Dataspace;
1612

17-
if ~stdlib.isoctave() && dsi.Type == "scalar"
13+
if dsi.Type == "scalar"
1814
fsize = [];
1915
else
2016
fsize = dsi.Size;

+stdlib/h5variables.m

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
function names = h5variables(file, group)
1212
arguments
13-
file {mustBeTextScalar}
14-
group {mustBeTextScalar} = ''
13+
file
14+
group (1,1) string = ""
1515
end
1616

1717
if stdlib.strempty(group)
@@ -23,11 +23,9 @@
2323
ds = finf.Datasets;
2424

2525
if isempty(ds)
26-
names = [];
26+
names = string.empty;
2727
else
28-
names = {ds.Name};
28+
names = string({ds.Name});
2929
end
3030

31-
names = string(names);
32-
3331
end

+stdlib/hard_link_count.m

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,15 @@
1212

1313
function [c, b] = hard_link_count(file, backend)
1414
arguments
15-
file {mustBeTextScalar}
15+
file string
1616
backend (1,:) string = ["java", "python", "sys"]
1717
end
1818

1919
[fun, b] = hbackend(backend, "hard_link_count");
2020

21-
c = fun(file);
22-
21+
if isscalar(file)
22+
c = fun(file);
23+
else
24+
c = arrayfun(fun, file);
25+
end
2326
end

+stdlib/ini2struct.m

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

66
function Struct = ini2struct(filename)
77
arguments
8-
filename {mustBeTextScalar,mustBeFile}
8+
filename {mustBeFile}
99
end
1010

1111
f = fopen(filename,'r'); % open file

+stdlib/is_char_device.m

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
%
66
%% Inputs
77
% * file: path to check
8+
% * backend: backend to use
89
%% Outputs
910
% * ok: true if path is a character device
1011
% * b: backend used
@@ -19,12 +20,16 @@
1920

2021
function [ok, b] = is_char_device(file, backend)
2122
arguments
22-
file {mustBeTextScalar}
23+
file string
2324
backend (1,:) string = ["python", "sys"]
2425
end
2526

2627
[fun, b] = hbackend(backend, "is_char_device");
2728

28-
ok = fun(file);
29+
if isscalar(file)
30+
ok = fun(file);
31+
else
32+
ok = arrayfun(fun, file);
33+
end
2934

3035
end

0 commit comments

Comments
 (0)