bugGNU Octave - Bugs: bug #50282, CS-list example in documentation...

 
 

bug #50282: CS-list example in documentation doesn't output stated output

Submitter:  Martin Castillo <castilma>
Submitted:  Sat 11 Feb 2017 11:33:46 PM UTC
   
 
Category:  Documentation Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Documentation
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 4.2.0 Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Wed 22 Feb 2017 04:02:07 PM UTC, comment #7: 

I fixed some of the immediate examples of problems in this cset (http://hg.savannah.gnu.org/hgweb/octave/rev/54404cc32903).  I'm going to close this report, but another one can be opened if desired on why doctest has problems with @opindex, @EXAMPLEFILE, etc.

Rik <rik5>
Group administrator
Mon 20 Feb 2017 10:32:09 PM UTC, comment #6: 

Without expanding the scope of this bug to all possible typos or strict incompatibilities with the doctest command, do we have a working patch for the original doc fix?

Or is the original bug not urgent enough that we might as well turn this into a long investigation and discussion of how or whether to make all examples fully doctest-compatible? That has been discussed before, but I don't remember if there is an open bug on it or if it was on the maintainers list.

Mike Miller <mtmiller>
Group Member
Sat 18 Feb 2017 03:39:00 PM UTC, comment #5: 


> if you look there, you'll see a lot problems. and many seem to be the way things are tested. for example:

rounding errors

> [...]
> tests for wrong type(?)
> [...]
> testing strings (?) instead values.


I don't think that is an issue with doctest, that is exactly what doctest is supposed to do. It compares a command in the examples, with the output it generates at the prompt, and that is a string.

Carnë Draug <carandraug>
Group Member
Sat 18 Feb 2017 04:29:35 AM UTC, comment #4: 

I tried doctest on doc/interpreter/
the result is in doctest.log.
if you look there, you'll see a lot problems. and many seem to be  the way things are tested. for example:
rounding errors

 >> (-1) ^ (1 / 3)

      expected:  0.50000 - 0.86603i

      got     : ans =  0.50000 + 0.86603i


tests for wrong type(?)

   >> prod ([true, true], "native")

      expected:     true

      got     : ans = 1


testing strings (?) instead values.

   >> min ([-1 i 1 -i])

      expected:      -i

      got     : ans = -0 - 1i


I don't know what happened here...

  >> w =  1  3  3  6  6  6
    iw = 1  2  2  4  4  4


      expected:
      got     : ??? parse error:

  syntax error

>>> w =  1  3  3  6  6  6
    iw = 1  2  2  4  4  4

            ^


Oh man:

   >> chop (-pi, 5, 5)

      expected:     -3.14150000000000

      got     : ans = -3.1415


   >> [ 1/0 e^800 ]

      expected:  Inf   Inf

      got     : warning: division by zero
ans =

   Inf   Inf


my favourite(before 'doctest .' I typed 'doctest'):

   >> disp (1)
    disp (2)
    run_history -1 -2

      expected:
 2
 1

      got     :  1
 2
'doctest' is a function from the file /home/mcd/octave/doctest-0.5.0/doctest.m

 -- doctest TARGET
 -- doctest TARGET -nonrecursive
 -- SUCCESS = doctest (TARGET, …)
 -- [NUMPASS, NUMTESTS, SUMMARY] = doctest (…)
     Run examples embedded in documentation.

     Doctest finds and runs code found in TARGET, which can be a:
        • function;
        • class;
        • Texinfo file;
        • directory/folder (pass ‘-nonrecursive’ to skip subfolders);
[...]



and while running, I got a bunch of the following:

/tmp/octave-help-Rrv4KT:1037: unknown command `DOCSTRING'
/tmp/octave-help-1gStjQ:1097: unknown command `opindex'
/tmp/octave-help-1gStjQ:1098: unknown command `opindex'
/tmp/octave-help-1gStjQ:1099: unknown command `opindex'
/tmp/octave-help-1gStjQ:1100: unknown command `opindex'
/tmp/octave-help-1gStjQ:1101: unknown command `opindex'
/tmp/octave-help-1gStjQ:1102: unknown command `opindex'
/tmp/octave-help-1gStjQ:1103: unknown command `opindex'
/tmp/octave-help-1gStjQ:1104: unknown command `opindex'
/tmp/octave-help-1gStjQ:1105: unknown command `opindex'
/tmp/octave-help-1gStjQ:1106: unknown command `opindex'
/tmp/octave-help-1gStjQ:1107: unknown command `opindex'
/tmp/octave-help-1gStjQ:1108: unknown command `opindex'
/tmp/octave-help-1gStjQ:1109: unknown command `opindex'
/tmp/octave-help-1gStjQ:1110: unknown command `opindex'
/tmp/octave-help-1gStjQ:1111: unknown command `opindex'
/tmp/octave-help-1gStjQ:1112: unknown command `opindex'
/tmp/octave-help-1gStjQ:1113: unknown command `opindex'
/tmp/octave-help-1gStjQ:1114: unknown command `opindex'
/tmp/octave-help-1gStjQ:1115: unknown command `opindex'
/tmp/octave-help-1gStjQ:1116: unknown command `opindex'
/tmp/octave-help-1gStjQ:1117: unknown command `opindex'
/tmp/octave-help-1gStjQ:1118: unknown command `opindex'
/tmp/octave-help-1gStjQ:1119: unknown command `opindex'
/tmp/octave-help-1gStjQ:1120: unknown command `opindex'
/tmp/octave-help-Phf2CQ:212: unknown command `EXAMPLEFILE'
/tmp/octave-help-Phf2CQ:212: unknown command `polynomial'
/tmp/octave-help-Phf2CQ:258: unknown command `DOCSTRING'
/tmp/octave-help-Phf2CQ:264: unknown command `DOCSTRING'
/tmp/octave-help-Phf2CQ:270: unknown command `DOCSTRING'
/tmp/octave-help-Phf2CQ:296: unknown command `DOCSTRING'
/tmp/octave-help-Phf2CQ:303: unknown command `EXAMPLEFILE'
/tmp/octave-help-Phf2CQ:303: unknown command `polynomial'
/tmp/octave-help-Phf2CQ:322: unknown command `EXAMPLEFILE'
/tmp/octave-help-Phf2CQ:322: unknown command `polynomial'
/tmp/octave-help-Phf2CQ:332: unknown command `EXAMPLEFILE'
/tmp/octave-help-Phf2CQ:332: unknown command `polynomial'
/tmp/octave-help-Phf2CQ:373: unknown command `DOCSTRING'
/tmp/octave-help-Phf2CQ:381: unknown command `DOCSTRING'
/tmp/octave-help-Phf2CQ:403: unknown command `DOCSTRING'
/tmp/octave-help-Phf2CQ:412: unknown command `EXAMPLEFILE'
/tmp/octave-help-Phf2CQ:412: unknown command `polynomial'
/tmp/octave-help-Phf2CQ:419: unknown command `DOCSTRING'
/tmp/octave-help-Phf2CQ:421: unknown command `DOCSTRING'
/tmp/octave-help-Phf2CQ:435: unknown command `EXAMPLEFILE'
/tmp/octave-help-Phf2CQ:435: unknown command `polynomial'
/tmp/octave-help-Phf2CQ:458: unknown command `DOCSTRING'
/tmp/octave-help-Phf2CQ:462: unknown command `DOCSTRING'
/tmp/octave-help-Phf2CQ:558: unknown command `EXAMPLEFILE'
/tmp/octave-help-Phf2CQ:558: unknown command `polynomial'
/tmp/octave-help-Phf2CQ:570: unknown command `EXAMPLEFILE'
/tmp/octave-help-Phf2CQ:570: unknown command `polynomial'
/tmp/octave-help-Phf2CQ:589: unknown command `EXAMPLEFILE'
/tmp/octave-help-Phf2CQ:589: unknown command `polynomial'
/tmp/octave-help-Phf2CQ:640: unknown command `opindex'
/tmp/octave-help-Phf2CQ:641: unknown command `opindex'


what does doctest try to compile?

/tmp/octave-help-qKjsmM:2261: unknown command `DOCSTRING'
gfortran: error: fortransub.f: Datei oder Verzeichnis nicht gefunden
gfortran: fatal error: no input files
compilation terminated.
/tmp/octave-help-q0r9Ch:407: unknown command `DOCSTRING'


(file #39781)

Martin Castillo <castilma>
Sat 18 Feb 2017 02:15:04 AM UTC, comment #3: 

Rik, that is the same output I got.

Carnë, when should those tests be executed? I think they should be executed automatically, with 'make check'. But for that to work, you'd need the doctest package...

Martin Castillo <castilma>
Tue 14 Feb 2017 02:02:06 PM UTC, comment #2: 

The doctest package may be of use to identify this issues https://octave.sourceforge.io/doctest/index.html

I executes all the example blocks and checks that the output matches.

Carnë Draug <carandraug>
Group Member
Mon 13 Feb 2017 11:47:53 PM UTC, comment #1: 

It seems that the situation is even worse than you suggest.  I tried the sample code from the documentation in Octave 4.2.0 and I get something something completely different from the stated results:


octave:1> in{1} = [10, 20, 30, 40, 50, 60, 70, 80, 90];
octave:2> in{2} = inf;
octave:3> in{3} = "last";
octave:4> in{4} = "first";
octave:5> out = cell (4, 1);
octave:6> [out{1:3}] = find (in{1 : 3});
octave:7> [out{4:6}] = find (in{[1, 2, 4]})
out =
{
  [1,1] =

     1   1   1   1   1   1   1   1   1

  [2,1] =

     1   2   3   4   5   6   7   8   9

  [3,1] =

     10   20   30   40   50   60   70   80   90

  [4,1] =

     1   1   1   1   1   1   1   1   1

  [5,1] =

     1   2   3   4   5   6   7   8   9

  [6,1] =

     10   20   30   40   50   60   70   80   90

}


Can you verify this?  Are there other changes to the documentation that need to be made here?

Rik <rik5>
Group administrator
Sat 11 Feb 2017 11:33:46 PM UTC, original submission:  

https://www.gnu.org/software/octave/doc/interpreter/Comma-Separated-Lists-Generated-from-Cell-Arrays.html#Comma-Separated-Lists-Generated-from-Cell-Arrays

The last example here does only print the given output, if the second line is

in{2}==1;


My first patch is attached.

Martin Castillo <castilma>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #39781:  doctest.log added by castilma (120KiB - text/x-log)
file #39729:  doc.patch added by castilma (621B - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by castilma (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-02-22 rik5 StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2017-02-18 castilma Attached File- Added doctest.log, #39781
    2017-02-13 rik5 StatusNone Confirmed
        Summaryexample in documentation doesn't output stated output CS-list example in documentation doesn't output stated output
    2017-02-11 castilma Attached File- Added doc.patch, #39729

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code