apjanke / octave-tablicious

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

Failures in doctests for ismember, unique, etc #129

Open apjanke opened 8 months ago

apjanke commented 8 months ago

Running doctest on Tablicious raises some test failures. I'm not familiar with doctest, so I don't know exactly what's going on here. Check them out.

pkg install -forge doctest
pkg load doctest
doctest ('inst')

The failures

The doctest output is really long, but here's what I see skimming through it. Full output attached.

[...]
calendarDuration.ismember .............................. FAIL    2/3   

   >> a = [3, 10, 1];
    s = [0:9];
    [tf, s_idx] = ismember (a, s)

      expected:       tf = [1, 0, 1]
      s_idx = [4, 0, 2]

      got     : tf =

  1  0  1

s_idx =

   4   0   2

   >> a = [1:3; 5:7; 4:6];
    s = [0:2; 1:3; 2:4; 3:5; 4:6];
    [tf, s_idx] = ismember (a, s, "rows")

      expected:       tf = logical ([1; 0; 1])
      s_idx = [2; 0; 5];

      got     : tf =

  1
  0
  1

s_idx =

   2
   0
   5

[...]
calendarDuration.unique ................................ FAIL    4/4   

   >> unique ([3, 1, 1, 2])

      expected:  [1, 2, 3]

      got     : ans =

   1   2   3

   >> unique ([3, 1, 1, 2], "stable")

      expected:  [3, 1, 2]

      got     : ans =

   3   1   2

   >> [~, I] = unique ([3, 1, 1, 2], "first")

      expected:  I = [2; 4; 1]

      got     : I =

   2
   4
   1

   >> [~, I] = unique ([3, 1, 1, 2], "last")

      expected:  I = [3; 4; 1]

      got     : I =

   3
   4
   1

calendarDuration.vertcat ............................... NO TESTS
error: unknown package 'categorical'
error: called from
    <unknown>
    doctest_collect>extract_docstring at line 367 column 25
    doctest_collect>collect_targets_class at line 330 column 38
    doctest_collect at line 167 column 11
    doctest_collect at line 147 column 13
    doctest at line 356 column 11
>>

TODO

References

apjanke commented 8 months ago

It's running through the files recursively and I think alphabetically. calendarDuration is the first classdef file it's hitting. Then categorical. I'm wondering if my use of "." style names for the texinfo nodes for methods like @node calendarDuration.unique or @node categorical.removecats is confusing it?

Like, these errors for calendarDuration.unique? I don't have those statements anywhere in my calendarDuration code. The word "stable" doesn't appear in the whole calendarDuration.m file. I wonder if it's running the tests for regular Octave unique instead here. And in categorical, it thinks it's a package, because... ???

calendarDuration.unique ................................ FAIL    4/4   

   >> unique ([3, 1, 1, 2])

      expected:  [1, 2, 3]

      got     : ans =

   1   2   3

   >> unique ([3, 1, 1, 2], "stable")

      expected:  [3, 1, 2]

      got     : ans =

   3   1   2

Kinda looks the same for the core unique function. And I see corresponding @example blocks in its code.

>> doctest unique
Doctest v0.8.0: this is Free Software without warranty, see source.

unique ................................................. FAIL    4/4

   >> unique ([3, 1, 1, 2])

      expected:  [1, 2, 3]

      got     : ans =

   1   2   3

   >> unique ([3, 1, 1, 2], "stable")

      expected:  [3, 1, 2]

      got     : ans =

   3   1   2

Yeah, I think something like that. Here's the code in doctest's doctest_collect() where that erorr for categorical is being raised.

function [docstring, error] = extract_docstring(name)
  if is_octave()
    [docstring, format] = get_help_text(name);
    if strcmp(format, 'texinfo')
      [docstring, error] = parse_texinfo(docstring);

In execution:

>> dbstop if error
>> doctest categorical
Doctest v0.8.0+: this is Free Software without warranty, see source.

error: unknown package 'categorical'
error: called from
    <unknown>
    doctest_collect>extract_docstring at line 367 column 25
    doctest_collect>collect_targets_class at line 330 column 38
    doctest_collect at line 167 column 11
    doctest at line 356 column 11
stopped in doctest_collect>extract_docstring at line 367 [/Users/janke/repos/octave-doctest/inst/private/doctest_collect.m]
367:     [docstring, format] = get_help_text(name);
debug> whos
Variables visible from the current scope:

variables in scope: extract_docstring: /Users/janke/repos/octave-doctest/inst/private/doctest_collect.m

  Attr   Name        Size                     Bytes  Class
  ====   ====        ====                     =====  =====
    f    name        1x19                        19  char

Total is 19 elements using 19 bytes

debug> name
name = categorical.missing
debug>

Looks like Octave's get_help_text doesn't like categorical.missing, maybe due to something special about the name "missing"? The categorical.undefined right next to it works okay.

>> [docstring, format] = get_help_text('categorical.missing')
error: unknown package 'categorical'
error: called from
    <unknown>
>> [docstring, format] = get_help_text('categorical.undefined')
docstring =
 @node categorical.undefined
 @deftypefn {Static Method} {@var{out} =} categorical.undefined ()
 @deftypefnx {Static Method} {@var{out} =} categorical.undefined (sz)

 Create an array of undefined categoricals.

 Creates a categorical array whose elements are all <undefined>.

 @var{sz} is the size of the array to create. If omitted or empty, creates
 a scalar.

 Returns a categorical array.

 @seealso{categorical.missing}

 @end deftypefn

format = texinfo
>>