Skip to content

Commit

Permalink
fix size-vs-numel bug in duration ctor that broke conversion of cells…
Browse files Browse the repository at this point in the history
…tr row vectors

The `for i = 1:size (strs)` is a bug; it should be `numel (strs)`. When using `size()`, you get a vector, then I think the `1:x` colon operator just uses the first element of the RHS, so it under-counts if dim 2 or higher is nonzero, and leaves the ignored elements as NaN in the output.

See: #134
  • Loading branch information
apjanke committed Jul 6, 2024
1 parent 94c34d1 commit a77a220
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Tablicious Changelog
* Fix assignment to some `table.Properties.<X>` pseudo-properties.
* Apply object validation after more mutation operations.
* Fix variable number display in table.summary.
* Fix duration ctor bug that returned NaNs in cellstr row vectors. ([#134](https://github.com/apjanke/octave-tablicious/issues/134))

0.4.2 (2024-02-07)
------------------
Expand Down
2 changes: 1 addition & 1 deletion inst/@duration/duration.m
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ function disp (this)
function out = parseTimeStringsToDatenum (strs)
strs = cellstr (strs);
out = NaN (size (strs));
for i = 1:size (strs)
for i = 1:numel (strs)
strIn = strs{i};
str = strIn;
ixDot = find (str == '.');
Expand Down

0 comments on commit a77a220

Please sign in to comment.