Ticket #7650: trac_7650-reviewer_v2.patch

File trac_7650-reviewer_v2.patch, 11.5 KB (added by mpatel, 13 years ago)

Fix two doctest failures. Replaces reviewer patch. sagenb repo.

  • sagenb/notebook/cell.py

    # HG changeset patch
    # User Mitesh Patel <qed777@gmail.com>
    # Date 1263787703 28800
    # Node ID c3286f123cf28534316c0a65fe2c1e1ef56c45c0
    # Parent  24f716c44dc487898a1fcc66e02cbaa296af4be5
    A few documentation fixes for #7650.
    
    diff --git a/sagenb/notebook/cell.py b/sagenb/notebook/cell.py
    a b class Cell_generic: 
    6868        Delete all output in this cell. This is not executed - it is an
    6969        abstract function that must be overwritten in a derived class.
    7070
    71         EXAMPLES: This function just raises a NotImplementedError, since it
    72         most be defined in derived class.::
     71        EXAMPLES:
     72
     73        This function just raises a NotImplementedError, since it must
     74        be defined in a derived class.
     75
     76        ::
    7377
    7478            sage: C = sagenb.notebook.cell.Cell_generic()
    7579            sage: C.delete_output()
    class Cell(Cell_generic): 
    485489            sage: C     # random output -- depends on computer speed
    486490            Cell 0; in=2+3, out=
    487491
    488         And the cell is considered to have been evaluated.::
     492        And the cell is considered to have been evaluated.
     493
     494        ::
    489495
    490496            sage: C.evaluated()     # random output -- depends on computer speed
    491497            True
  • sagenb/notebook/interact.py

    diff --git a/sagenb/notebook/interact.py b/sagenb/notebook/interact.py
    a b class InputBox(InteractControl): 
    944944        EXAMPLES::
    945945
    946946            sage: sagenb.notebook.interact.InputBox('theta', Color('red'), type=Color)._adaptor('#aaaaaa',globals())
    947             RGB color (0.66666666666666663, 0.66666666666666663, 0.66666666666666663)
     947            RGB color (0.66..., 0.66..., 0.66...)
    948948        """
    949949        if self.__type is None:
    950950            return sage_eval(value, globs)
    class color_selector(input_box): 
    27232723            ...
    27242724            ValueError: unknown color 'crayon'
    27252725            sage: color_selector('#abcdef', label='height', widget='jpicker')
    2726             Interact color selector labeled 'height', with default RGB color (0.6705882352941176, 0.80392156862745101, 0.93725490196078431), widget 'jpicker', and visible input box
     2726            Interact color selector labeled 'height', with default RGB color (0.6..., 0.8..., 0.9...), widget 'jpicker', and visible input box
    27272727            sage: color_selector('abcdef', label='height', widget='jpicker')
    27282728            Traceback (most recent call last):
    27292729            ...
  • sagenb/notebook/worksheet.py

    diff --git a/sagenb/notebook/worksheet.py b/sagenb/notebook/worksheet.py
    a b class Worksheet(object): 
    877877        OUTPUT: a Notebook object.
    878878
    879879        EXAMPLES: This really returns the Notebook object that is set as a
    880         global variable of the twist module.::
     880        global variable of the twist module.
     881
     882        ::
    881883
    882884            sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir()+'.sagenb')
    883885            sage: W = nb.create_new_worksheet('A Test Worksheet', 'admin')
    class Worksheet(object): 
    12291231        -  ``username`` - string
    12301232
    12311233        EXAMPLES: We create a worksheet and rate it, then look at the
    1232         ratings.::
     1234        ratings.
     1235
     1236        ::
    12331237
    12341238            sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir()+'.sagenb')
    12351239            sage: W = nb.create_new_worksheet('Publish Test', 'admin')
    class Worksheet(object): 
    14151419
    14161420            sage: W.move_to_archive('admin')
    14171421
    1418         The view is now archive.::
     1422        The view is now archive.
     1423
     1424        ::
    14191425
    14201426            sage: W.user_view('admin')
    14211427            0
    14221428            sage: sagenb.notebook.worksheet.ARCHIVED
    14231429            0
    14241430
    1425         For any other random viewer the view is set by default to ACTIVE.::
     1431        For any other random viewer the view is set by default to ACTIVE.
     1432
     1433        ::
    14261434
    14271435            sage: W.user_view('foo')
    14281436            1
    class Worksheet(object): 
    17401748
    17411749        OUTPUT: bool
    17421750
    1743         EXAMPLES: We create a notebook with one worksheet and two users.::
     1751        EXAMPLES: We create a notebook with one worksheet and two users.
     1752
     1753        ::
    17441754
    17451755            sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir()+'.sagenb')
    17461756            sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
    class Worksheet(object): 
    17551765            False
    17561766
    17571767        After adding 'william' as a collaborator he can edit the
    1758         worksheet.::
     1768        worksheet.
     1769
     1770        ::
    17591771
    17601772            sage: W.add_collaborator('william')
    17611773            sage: W.user_can_edit('william')
    class Worksheet(object): 
    17761788        -  ``user`` - string; the name of a user
    17771789
    17781790        EXAMPLES: We create a notebook with 2 users and 1 worksheet that
    1779         both view.::
     1791        both view.
     1792
     1793        ::
    17801794
    17811795            sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir()+'.sagenb')
    17821796            sage: nb.add_user('wstein','sage','wstein@sagemath.org',force=True)
    class Worksheet(object): 
    17891803            ['wstein']
    17901804
    17911805        We delete the sage user from the worksheet W. This makes wstein the
    1792         new owner.::
     1806        new owner.
     1807
     1808        ::
    17931809
    17941810            sage: W.delete_user('sage')
    17951811            sage: W.viewers()
    class Worksheet(object): 
    17971813            sage: W.owner()
    17981814            'wstein'
    17991815
    1800         Then we delete wstein from W, which makes the owner None::
     1816        Then we delete wstein from W, which makes the owner None.
     1817
     1818        ::
    18011819
    18021820            sage: W.delete_user('wstein')
    18031821            sage: W.owner() is None
    class Worksheet(object): 
    18051823            sage: W.viewers()
    18061824            []
    18071825
    1808         Finally, we clean up.::
     1826        Finally, we clean up.
     1827
     1828        ::
    18091829
    18101830            sage: nb.delete()
    18111831        """
    class Worksheet(object): 
    21352155           ignore all the IDs in the {{{}}} code block.
    21362156
    21372157
    2138         EXAMPLES: We create a new test notebook and a worksheet.::
     2158        EXAMPLES:
     2159
     2160        We create a new test notebook and a worksheet.
     2161
     2162        ::
    21392163
    21402164            sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir()+'.sagenb')
    21412165            sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
    21422166            sage: W = nb.create_new_worksheet('Test Edit Save', 'sage')
    21432167
    2144         We set the contents of the worksheet using the edit_save command.::
     2168        We set the contents of the worksheet using the edit_save command.
     2169
     2170        ::
    21452171
    21462172            sage: W.edit_save('{{{\n2+3\n///\n5\n}}}\n{{{\n2+8\n///\n10\n}}}')
    21472173            sage: W
    class Worksheet(object): 
    24452471            1255029800.0
    24462472            sage: W.last_to_edit()
    24472473            'john'
    2448             sage: W.date_edited()
    2449             time.struct_time(tm_year=2009, tm_mon=10, tm_mday=8, tm_hour=12, tm_min=23, tm_sec=20, tm_wday=3, tm_yday=281, tm_isdst=1)
     2474            sage: W.date_edited()                # output depends on timezone
     2475            time.struct_time(tm_year=2009, tm_mon=10, ...)
    24502476            sage: t = W.time_since_last_edited() # just test that call works
    24512477        """
    24522478        username = str(username); tm = float(tm)
    class Worksheet(object): 
    25422568            sage: W = nb.create_new_worksheet('Test Edit Save', 'admin')
    25432569
    25442570        Now we set the worksheet to have two cells with the default id of 0
    2545         and another with id 10.::
     2571        and another with id 10.
     2572
     2573        ::
    25462574
    25472575            sage: W.edit_save('{{{\n2+3\n///\n5\n}}}\n{{{id=10|\n2+8\n///\n10\n}}}')
    25482576            sage: W.cell_id_list()
    from sagenb.notebook.all import * 
    31553183            sage: W.check_comp()
    31563184            ('w', Cell 0; in=factor(2^997-1), out=...)
    31573185
    3158         We interrupt it successfully.::
     3186        We interrupt it successfully.
     3187
     3188        ::
    31593189
    31603190            sage: W.interrupt()         # random -- could fail on heavily loaded machine
    31613191            True
    31623192
    3163         Now we check and nothing is computing.::
     3193        Now we check and nothing is computing.
     3194
     3195        ::
    31643196
    31653197            sage: W.check_comp()        # random -- could fail on heavily loaded machine
    31663198            ('e', None)
    31673199
    3168         Clean up.::
     3200        Clean up.
     3201
     3202        ::
    31693203
    31703204            sage: W.quit()
    31713205            sage: nb.delete()
    from sagenb.notebook.all import * 
    35193553                        l += k+1
    35203554                        I = C._before_preparse.split('\n')
    35213555                        out = out[:i + len(tb)+1] + '    ' + I[n-2] + out[l:]
    3522         except (ValueError, IndexError), msg:
     3556        except (ValueError, IndexError) as msg:
    35233557            pass
    35243558        return out
    35253559
    from sagenb.notebook.all import * 
    36533687                cur = os.path.abspath(os.curdir)
    36543688                try:
    36553689                    mod, dir  = cython.cython(filename_orig, compile_message=True, use_cache=True)
    3656                 except (IOError, OSError, RuntimeError), msg:
     3690                except (IOError, OSError, RuntimeError) as msg:
    36573691                    return "print r'''Error compiling cython file:\n%s'''"%msg
    36583692                t  = "import sys\n"
    36593693                t += "sys.path.append('%s')\n"%dir
    from sagenb.notebook.all import * 
    37443778
    37453779        -  ``C`` - the cell object
    37463780
    3747         EXAMPLES: First, we set up a new notebook and worksheet.::
     3781        EXAMPLES: First, we set up a new notebook and worksheet.
     3782
     3783        ::
    37483784
    37493785            sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir()+'.sagenb')
    37503786            sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
    37513787            sage: W = nb.create_new_worksheet('Test', 'sage')
    37523788
    37533789        We first test running a native command in 'sage' mode and then a
    3754         GAP cell within Sage mode.::
     3790        GAP cell within Sage mode.
     3791
     3792        ::
    37553793
    37563794            sage: W.edit_save('{{{\n2+3\n}}}\n\n{{{\n%gap\nSymmetricGroup(5)\n}}}')
    37573795            sage: c0, c1 = W.cell_list()
    from sagenb.notebook.all import * 
    37743812            Sym( [ 1 .. 5 ] )
    37753813            )
    37763814
    3777         Next, we run the same commands but from 'gap' mode.::
     3815        Next, we run the same commands but from 'gap' mode.
     3816
     3817        ::
    37783818
    37793819            sage: W.edit_save('{{{\n%sage\n2+3\n}}}\n\n{{{\nSymmetricGroup(5)\n}}}')
    37803820            sage: W.set_system('gap')
    from sagenb.notebook.all import * 
    38423882           deletion.
    38433883
    38443884        EXAMPLES: We create a new notebook, user, and a worksheet with one
    3845         cell.::
     3885        cell.
     3886
     3887        ::
    38463888
    38473889            sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir()+'.sagenb')
    38483890            sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
    38493891            sage: W = nb.create_new_worksheet('Test', 'sage')
    38503892            sage: W.edit_save('{{{\n2+3\n///\n5\n}}}')
    38513893
    3852         Notice that there is 1 cell with 5 in its output.::
     3894        Notice that there is 1 cell with 5 in its output.
     3895
     3896        ::
    38533897
    38543898            sage: W.cell_list()
    38553899            [Cell 0; in=2+3, out=
    38563900            5]
    38573901
    3858         We now delete the output, observe that it is gone.::
     3902        We now delete the output, observe that it is gone.
     3903
     3904        ::
    38593905
    38603906            sage: W.delete_all_output('sage')
    38613907            sage: W.cell_list()
    38623908            [Cell 0; in=2+3, out=]
    38633909
    3864         If an invalid user tries to delete all, a ValueError is raised.::
     3910        If an invalid user tries to delete all, a ValueError is raised.
     3911
     3912        ::
    38653913
    38663914            sage: W.delete_all_output('hacker')
    38673915            Traceback (most recent call last):
    38683916            ...
    38693917            ValueError: user 'hacker' not allowed to edit this worksheet
    38703918
    3871         Clean up.::
     3919        Clean up.
     3920
     3921        ::
    38723922
    38733923            sage: nb.delete()
    38743924        """