Skip to content

Commit 083b1b0

Browse files
HanSur94claude
andcommitted
fix(loadModuleMetadata): handle column cell arrays in compression
Reshape cell-array strcmp result to row before concatenation. Also reshape Y output unconditionally for both numeric and cell types. Fix docstring accuracy for empty-condition rules. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 02bb4f2 commit 083b1b0

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

libs/SensorThreshold/loadModuleMetadata.m

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
% arrays or cell arrays of char.
1111
%
1212
% ThresholdRules must be attached to sensors before calling this
13-
% function. Sensors with no rules or rules with empty conditions are
14-
% skipped. State keys not found in the metadata are skipped silently.
13+
% function. Sensors with no rules are skipped. Rules with empty
14+
% conditions (unconditional) contribute no state keys. State keys not
15+
% found in the metadata are skipped silently.
1516
%
1617
% Each sensor receives its own StateChannel instance (no shared
1718
% handles). Compressed data is cached so each field is processed once.
@@ -101,23 +102,20 @@
101102
end
102103
end
103104

104-
105105
function result = compressTransitions(X, Y_dense)
106106
%COMPRESSTRANSITIONS Compress dense state signal to sparse transitions.
107107
% result = compressTransitions(X, Y_dense) returns struct with fields
108108
% X and Y containing only the transition points (plus the first point).
109109
% Handles both numeric arrays and cell arrays of char.
110110

111111
if iscell(Y_dense)
112-
changes = [true, ~strcmp(Y_dense(1:end-1), Y_dense(2:end))];
112+
cmp = ~strcmp(Y_dense(1:end-1), Y_dense(2:end));
113+
changes = [true, reshape(cmp, 1, [])];
113114
else
114115
changes = [true, reshape(diff(Y_dense) ~= 0, 1, [])];
115116
end
116117

117118
% Ensure row orientation (1xN) per StateChannel contract
118119
result.X = reshape(X(changes), 1, []);
119-
result.Y = Y_dense(changes);
120-
if ~iscell(result.Y)
121-
result.Y = reshape(result.Y, 1, []);
122-
end
120+
result.Y = reshape(Y_dense(changes), 1, []);
123121
end

0 commit comments

Comments
 (0)