Ticket #12299: trac_12299-reviewer.patch

File trac_12299-reviewer.patch, 7.6 KB (added by kcrisman, 12 months ago)
  • doc/en/reference/interfaces.rst

    # HG changeset patch
    # User Karl-Dieter Crisman <kcrisman@gmail.com>
    # Date 1339899573 14400
    # Node ID 86c00a0d5159f37127be7b89c3e351e566698ddc
    # Parent  441da014640a81abc78847965a5ce89edbcb2d81
    Trac 12299 - reviewer patch in formatting and temp files, add to ref manual
    
    diff --git a/doc/en/reference/interfaces.rst b/doc/en/reference/interfaces.rst
    a b  
    7878   sage/interfaces/sage0 
    7979   sage/interfaces/singular 
    8080   sage/interfaces/tachyon 
     81   sage/interfaces/jmoldata 
  • sage/interfaces/jmoldata.py

    diff --git a/sage/interfaces/jmoldata.py b/sage/interfaces/jmoldata.py
    a b  
    55reads and for generating image files.  
    66 
    77AUTHORS: 
    8 Jonathan Gutow (2012-06-14): complete doctest coverage 
    9 Jonathan Gutow (2012-03-21): initial version 
     8 
     9- Jonathan Gutow (2012-06-14): complete doctest coverage 
     10- Jonathan Gutow (2012-03-21): initial version 
     11""" 
    1012 
    1113#******************************************************************************* 
    1214#       Copyright (C) 2012 Jonathan Gutow (gutow@uwosh.edu) 
     
    1618#  the License, or (at your option) any later version. 
    1719#                  http://www.gnu.org/licenses/ 
    1820#******************************************************************************* 
    19 """ 
     21 
    2022from sage.structure.sage_object import SageObject 
    2123 
    2224from sage.misc.misc import tmp_filename 
     
    2830class JmolDataError(Exception): 
    2931 
    3032    def __init__(self, value): 
    31     """ 
    32     EXAMPLES: 
     33        """ 
     34        TEST:: 
    3335 
    34     JmolDataError __init__ test:: 
    35         sage: from sage.interfaces.jmoldata import JmolDataError 
    36         sage: print(JmolDataError("test of init").value) 
    37         test of init 
    38     """ 
     36            sage: from sage.interfaces.jmoldata import JmolDataError 
     37            sage: print(JmolDataError("test of init").value) 
     38            test of init 
     39        """ 
    3940        self.value = value 
     41 
    4042    def __str__(self): 
    41     """ 
    42     EXAMPLES: 
     43        """ 
     44        TEST:: 
    4345 
    44     JmolDataError __str__ test:: 
    45  
    46         sage: from sage.interfaces.jmoldata import JmolDataError 
    47         sage: print str(JmolDataError("test of error")) 
    48         'test of error' 
    49     """ 
     46            sage: from sage.interfaces.jmoldata import JmolDataError 
     47            sage: print str(JmolDataError("test of error")) 
     48            'test of error' 
     49        """ 
    5050        return repr(self.value) 
    5151 
    5252class JmolData(SageObject): 
    5353    r""" 
    54     .. TODO:: 
    55         DONE 1) create an image file (user choosable JPG, PNG, GIF) 
    56         DONE 1.5) function to check if jvm is available 
    57         DONE 1.75) raise exception if export_image is called without JVM being available. 
    58         2) create an animated image file if spin is on (GIF) 
    59         3) Put data extracted from a file into a variable/string/structure to return  
     54    .. todo:: 
     55 
     56       Create an animated image file (GIF) if spin is on and put data 
     57       extracted from a file into a variable/string/structure to return 
    6058    """ 
    6159    def __init__(self): 
    6260        """ 
    6361        EXAMPLES: 
    6462 
    65         Create a JmolData object 
    66         :: 
     63        Create a JmolData object:: 
    6764 
    6865            sage: from sage.interfaces.jmoldata import JmolData 
    6966            sage: JData = JmolData() 
     
    108105        This executes JmolData.jar to make an image file. 
    109106 
    110107        INPUT: 
    111             targetfile -- the full path to the file where the image should be written. 
    112             datafile   -- full path to the data file Jmol can read or text of a script  
    113                 telling Jmol what to read or load. 
    114             datafile_cmd -- "script" or "load" defaults to "script", should be load for a data file. 
    115             image_type -- "PNG" "JPG" or "GIF" defaults to "PNG" 
    116             figsize -- number = (pixels/side)/100 defaults to 5. 
     108 
     109        - targetfile -- the full path to the file where the image 
     110          should be written. 
     111 
     112        - datafile -- full path to the data file Jmol can read or 
     113          text of a script telling Jmol what to read or load. 
     114 
     115        - datafile_cmd -- (default ``'script'``)  ``'load'`` or ``'script'`` 
     116          should be ``"load"`` for a data file. 
     117 
     118        - image_type -- (default ``"PNG"``) ``'PNG'`` ``'JPG'`` or ``'GIF'`` 
     119 
     120        - figsize -- number (default 5) equal to (pixels/side)/100 
    117121 
    118122        OUTPUT: 
    119             image file , .png, .gif or .jpg (default .png) 
    120123 
    121         .. NOTE:: 
    122             Examples will generate an error message if a functional Java Virtual Machine (JVM) is not installed 
    123             on the machine the Sage instance is running on. 
     124        Image file , .png, .gif or .jpg (default .png) 
    124125 
    125         .. WARNING:: 
    126             Programmers using this module should check that the JVM is available before making calls to 
    127             avoid the user getting error messages.  Check for the JVM using the function  
    128             is_jvm_available(), which returns True if a JVM is available. 
     126        .. note:: 
     127 
     128            Examples will generate an error message if a functional Java Virtual Machine (JVM) 
     129            is not installed on the machine the Sage instance is running on. 
     130 
     131        .. warning:: 
     132 
     133            Programmers using this module should check that the JVM is 
     134            available before making calls to avoid the user getting 
     135            error messages.  Check for the JVM using the function 
     136            :meth:`is_jvm_available`, which returns True if a JVM is available. 
    129137 
    130138        EXAMPLES: 
    131139 
    132         Use Jmol to load a pdb file containing some DNA from a web data base and make an image of the DNA. 
    133         If you execute this in the notebook, the image will appear in the output cell. 
    134         :: 
     140        Use Jmol to load a pdb file containing some DNA from a web data 
     141        base and make an image of the DNA. If you execute this in the 
     142        notebook, the image will appear in the output cell:: 
    135143 
    136144            sage: from sage.interfaces.jmoldata import JmolData 
    137145            sage: JData = JmolData() 
    138146            sage: script = "load =1lcd;display DNA;moveto 0.0 { -473 -713 -518 59.94} 100.0 0.0 0.0 {21.17 26.72 27.295} 27.544636 {0.0 0.0 0.0} -25.287832 64.8414 0.0;" 
    139             sage: testfile = "DNA.png" 
    140             sage: JData.export_image(targetfile=testfile,datafile=script,image_type="PNG") 
    141             sage: print os.path.exists(testfile) 
     147            sage: testfile = tmp_filename()+"DNA.png" 
     148            sage: JData.export_image(targetfile=testfile,datafile=script,image_type="PNG") # optional -- internet 
     149            sage: print os.path.exists(testfile) # optional -- internet 
    142150            True 
    143151 
    144         Use Jmol to save an image of a 3-D object created in Sage.  This method is used internally 
    145         by plot3d to generate static images.  This example doesn't have correct scaling. 
    146         :: 
     152        Use Jmol to save an image of a 3-D object created in Sage. 
     153        This method is used internally by plot3d to generate static images. 
     154        This example doesn't have correct scaling:: 
    147155 
    148156            sage: from sage.interfaces.jmoldata import JmolData 
    149157            sage: JData = JmolData() 
     
    152160            sage: archive_name=os.path.join(SAGE_TMP, "archive.jmol.zip") 
    153161            sage: D.export_jmol(archive_name)  #not scaled properly...need some more steps. 
    154162            sage: testfile = os.path.join(SAGE_TMP, "testimage.png") 
    155             sage: script = 'set defaultdirectory "'+archive_name+'"\n script SCRIPT\n' 
     163            sage: script = 'set defaultdirectory "%s"\\n script SCRIPT\\n'%archive_name 
    156164            sage: JData.export_image(targetfile =testfile,datafile = script, image_type="PNG") 
    157165            sage: print os.path.exists(testfile) 
    158166            True