Ticket #7494: trac_7494.patch

File trac_7494.patch, 5.1 KB (added by was, 8 years ago)
  • sage/finance/stock.py

    # HG changeset patch
    # User William Stein <wstein@gmail.com>
    # Date 1314168158 25200
    # Node ID 9ac9e0edc71d79e9c181c3bb0520bf2e6fa55aa0
    # Parent  43d128c82f60965828f9fc26207465b1ad5a36f8
    trac 7494: remove SAGE_ROOT/examples
    
    diff --git a/sage/finance/stock.py b/sage/finance/stock.py
    a b  
    424424        ``AAPL-minutely.csv``. One can load this information into a Stock
    425425        object like so. Note that the path must be explicit::
    426426
    427             sage: finance.Stock('aapl').load_from_file(SAGE_ROOT + '/examples/finance/AAPL-minutely.csv')[:5]
     427            sage: filename = tmp_filename() + '.csv'
     428            sage: open(filename,'w').write("Date,Open,High,Low,Close,Volume\n1212405780,187.80,187.80,187.80,187.80,100\n1212407640,187.75,188.00,187.75,188.00,2000\n1212407700,188.00,188.00,188.00,188.00,1000\n1212408000,188.00,188.11,188.00,188.00,2877\n1212408060,188.00,188.00,188.00,188.00,687")
     429            sage: finance.Stock('aapl').load_from_file(filename)[:5]
    428430            [
    429431            1212408060 188.00 188.00 188.00 188.00        687,
    430432            1212408000 188.00 188.11 188.00 188.00       2877,
     
    440442        example, we can initialize a Stock object with the symbol ``'goog'``,
    441443        but load data from ``'aapl'`` stock prices::
    442444
    443             sage: finance.Stock('goog').load_from_file(SAGE_ROOT + '/examples/finance/AAPL-minutely.csv')[:5]
     445            sage: finance.Stock('goog').load_from_file(filename)[:5]
    444446            [
    445447            1212408060 188.00 188.00 188.00 188.00        687,
    446448            1212408000 188.00 188.11 188.00 188.00       2877,
     
    452454        This tests a file that doesn't exist::
    453455
    454456            sage: finance.Stock("AAPL").load_from_file("I am not a file")
    455             Bad path or file name
     457            Traceback (most recent call last):
     458            ...
     459            IOError: [Errno 2] No such file or directory: 'I am not a file'
    456460        """
    457         try:
    458             file_obj = open(file, 'r')
    459             R = file_obj.read();
    460             self.__historical = self._load_from_csv(R)
    461             file_obj.close()
    462             return self.__historical
    463         except IOError, msg:
    464             print "Bad path or file name"
     461        file_obj = open(file, 'r')
     462        R = file_obj.read();
     463        self.__historical = self._load_from_csv(R)
     464        file_obj.close()
     465        return self.__historical
     466
    465467       
    466468    def _load_from_csv(self, R):
    467469        """
     
    469471
    470472        This indirectly tests ``_load_from_csv()``::
    471473
    472             sage: finance.Stock('aapl').load_from_file(SAGE_ROOT + "/examples/finance/AAPL-minutely.csv")
     474            sage: filename = tmp_filename() + '.csv'
     475            sage: open(filename,'w').write("Date,Open,High,Low,Close,Volume\n1212405780,187.80,187.80,187.80,187.80,100\n1212407640,187.75,188.00,187.75,188.00,2000\n1212407700,188.00,188.00,188.00,188.00,1000\n1212408000,188.00,188.11,188.00,188.00,2877\n1212408060,188.00,188.00,188.00,188.00,687")
     476            sage: finance.Stock('aapl').load_from_file(filename)
    473477            [
    474478            1212408060 188.00 188.00 188.00 188.00        687,
    475479            1212408000 188.00 188.11 188.00 188.00       2877,
  • sage/misc/hg.py

    diff --git a/sage/misc/hg.py b/sage/misc/hg.py
    a b  
    12591259                obj_name='extcode')
    12601260
    12611261
    1262 hg_examples = HG('%s/data/examples'%SAGE_ROOT,
    1263                  'Sage Examples',
    1264                  pull_url='%s/examples/'%SAGE_INCOMING_SERVER,
    1265                  push_url='%s/examples/'%SAGE_OUTGOING_SERVER,
    1266                  obj_name='examples')
    1267 
    12681262hg_root = HG(SAGE_ROOT,
    12691263             'Sage Root',
    12701264             pull_url=SAGE_INCOMING_SERVER,
  • sage/misc/inline_fortran.py

    diff --git a/sage/misc/inline_fortran.py b/sage/misc/inline_fortran.py
    a b  
    2121
    2222    def eval(self,x,globals=None, locals=None):
    2323        """
    24         EXAMPLES:
    25             sage: from sage.misc.inline_fortran import InlineFortran
    26             sage: import os
    27             sage: s = open(os.environ['SAGE_ROOT'] + '/examples/fortran/FIB1.F').read()
     24        EXAMPLES::
     25       
     26            sage: from sage.misc.inline_fortran import InlineFortran, _example
    2827            sage: test_fortran = InlineFortran(globals())   # optional -- fortran
    29             sage: test_fortran(s)                           # optional -- fortran
     28            sage: test_fortran(_example)                    # optional -- fortran
    3029            sage: import numpy
    3130            sage: n = numpy.array(range(10),dtype=float)
    3231            sage: fib(n,int(10))                            # optional -- fortran
     
    101100    def add_library_path(self,s):
    102101       self.library_paths.append(s)
    103102   
     103
     104_example = """
     105C FILE: FIB1.F
     106      SUBROUTINE FIB(A,N)
     107C
     108C     CALCULATE FIRST N FIBONACCI NUMBERS
     109C
     110      INTEGER N
     111      REAL*8 A(N)
     112      DO I=1,N
     113         IF (I.EQ.1) THEN
     114            A(I) = 0.0D0
     115         ELSEIF (I.EQ.2) THEN
     116            A(I) = 1.0D0
     117         ELSE
     118            A(I) = A(I-1) + A(I-2)
     119         ENDIF
     120      ENDDO
     121      END
     122C END FILE FIB1.F
     123"""