Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failures in doctests for ismember, unique, etc #129

Open
5 tasks
Tracked by #137
apjanke opened this issue Feb 9, 2024 · 1 comment
Open
5 tasks
Tracked by #137

Failures in doctests for ismember, unique, etc #129

apjanke opened this issue Feb 9, 2024 · 1 comment
Assignees
Labels
bug Something isn't working tests
Milestone

Comments

@apjanke
Copy link
Owner

apjanke commented Feb 9, 2024

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

  • Learn a bit about doctest
  • Fix these test failures
    • calendarDuration.ismember
    • calendarDuration.unique
    • "error: unknown package 'categorical'"

References

@apjanke apjanke self-assigned this Feb 9, 2024
@apjanke apjanke added bug Something isn't working tests labels Feb 9, 2024
@github-project-automation github-project-automation bot moved this to Needs triage in Octave-Tablicious Feb 9, 2024
@apjanke apjanke moved this from Needs triage to High priority in Octave-Tablicious Feb 9, 2024
@apjanke apjanke added this to the 0.5.0 milestone Feb 9, 2024
@apjanke
Copy link
Owner Author

apjanke commented Feb 9, 2024

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
>>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working tests
Projects
Status: High priority
Development

No branches or pull requests

1 participant