Skip to content
This repository was archived by the owner on Dec 10, 2021. It is now read-only.

Commit 71aa75a

Browse files
committed
cmap: Fix map functions returning objects + parallel processing
When using parallel processing on map functions that returned objects, "cmap" would fail. Fixed this by refactoring the code to be more "DRY".
1 parent d7b82f6 commit 71aa75a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

cmap.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@
7070
%% Perform mapping
7171

7272
B = cell(size(A));
73-
outputIsScalar = false(size(A));
7473

7574
if args.useParallel
7675
parfor i = 1:numel(A)
@@ -84,8 +83,6 @@
8483
case 2
8584
B{i} = fun(item, i);
8685
end
87-
88-
outputIsScalar(i) = isscalar(B{i});
8986
end
9087
else
9188
for i = 1:numel(A)
@@ -99,15 +96,18 @@
9996
case 2
10097
B{i} = fun(item, i);
10198
end
102-
103-
outputIsScalar(i) = isscalar(B{i}) && ~isobject(B{i});
10499
end
105100
end
106101

107102

108103
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
109104
%% Process output
110105

106+
outputIsScalar = false(size(A));
107+
for i = 1:numel(B)
108+
outputIsScalar(i) = isscalar(B{i}) && ~isobject(B{i});
109+
end
110+
111111
if isempty(B)
112112
B = [];
113113
elseif ndArrayProcessing

0 commit comments

Comments
 (0)