apjanke / octave-tablicious

Table (relational, tabular data) implementation for GNU Octave
https://apjanke.github.io/octave-tablicious/
GNU General Public License v3.0
28 stars 11 forks source link

bad string assignment with `str(end) = NaS` #123

Closed apjanke closed 5 months ago

apjanke commented 5 months ago

In 0.4.1, looks like str(end) = ... isn't working right for strings.

>> foo = [1:4 NaN]'; bar = string({'foo','bar','baz''qux','x'}'); bar(end) = NaS; baz = [1:4 NaN]' + .234; tbl = table(foo, bar, baz)
error: table: Inconsistent sizes: var 1 (foo) is 5 rows; var 2 (bar) is 4 rows
error: called from
    table at line 221 column 13
>> foo = [1:4 NaN]'; bar = string({'foo','bar','baz''qux','x'}'); bar(5) = NaS; baz = [1:4 NaN]' + .234; tbl = table(foo, bar, baz)
tbl =
table: 5 rows x 3 variables
  VariableNames: foo, bar, baz
>>
apjanke commented 5 months ago

Yup. Looks like the regular end operation doesn't respect the size override method?

>> strs = string({'foo','bar','baz'})
strs =
"foo"   "bar"   "baz"
>> s2 = strs
s2 =
"foo"   "bar"   "baz"
>> s2(end) = NaS
s2 =
<missing>   "bar"   "baz"
>>

Adding an end override method gives me this:

>> s2 = strs
s2 =
"foo"   "bar"   "baz"
>> s2(end) = NaS
s2 =
"foo"   "bar"   <missing>
>>

Needed for datetime, categorical, duration, calendarDuration, too.

Fixed in https://github.com/apjanke/octave-tablicious/commit/876cc52d20fcbd83ee96d1abe0ee0b3b23c27b6c.