~ubuntu-branches/ubuntu/saucy/python-scipy/saucy

« back to all changes in this revision

Viewing changes to Lib/sandbox/newoptimize/base.py

  • Committer: Bazaar Package Importer
  • Author(s): Ondrej Certik
  • Date: 2008-06-16 22:58:01 UTC
  • mfrom: (2.1.24 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080616225801-irdhrpcwiocfbcmt
Tags: 0.6.0-12
* The description updated to match the current SciPy (Closes: #489149).
* Standards-Version bumped to 3.8.0 (no action needed)
* Build-Depends: netcdf-dev changed to libnetcdf-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
##
2
 
# 16.02.2005, c
3
 
import numpy as nm
4
 
import scipy.optimize as sopt
5
 
import scipy.optimize.linesearch as linesearch
6
 
import pylab
7
 
 
8
 
import glob, re, time, sys
9
 
 
10
 
##
11
 
# 22.09.2005, c
12
 
# 24.10.2005
13
 
if sys.version[:5] < '2.4.0':
14
 
    def sorted( sequence ):
15
 
        tmp = copy( sequence )
16
 
        tmp.sort()
17
 
        return tmp
18
 
 
19
 
 
20
 
# Some usefull definitions.
21
 
 
22
 
##
23
 
# 02.01.2005
24
 
class Struct( object ):
25
 
    # 03.10.2005, c
26
 
    # 26.10.2005
27
 
    def __init__( self, **kwargs ):
28
 
        if kwargs:
29
 
            self.__dict__.update( kwargs )
30
 
        
31
 
    # 08.03.2005
32
 
    def __str__( self ):
33
 
        ss = "%s\n" % self.__class__
34
 
        for key, val in self.__dict__.iteritems():
35
 
            if (issubclass( self.__dict__[key].__class__, Struct )):
36
 
                ss += "  %s:\n    %s\n" % (key, self.__dict__[key].__class__)
37
 
            else:
38
 
                aux = "\n" + str( val )
39
 
                aux = aux.replace( "\n", "\n    " );
40
 
                ss += "  %s:\n%s\n" % (key, aux[1:])
41
 
        return( ss.rstrip() )
42
 
 
43
 
    # 08.03.2005, c
44
 
    def strAll( self ):
45
 
        ss = "%s\n" % self.__class__
46
 
        for key, val in self.__dict__.iteritems():
47
 
            if (issubclass( self.__dict__[key].__class__, Struct )):
48
 
                ss += "  %s:\n" % key
49
 
                aux = "\n" + self.__dict__[key].strAll()
50
 
                aux = aux.replace( "\n", "\n    " );
51
 
                ss += aux[1:] + "\n"
52
 
            else:
53
 
                aux = "\n" + str( val )
54
 
                aux = aux.replace( "\n", "\n    " );
55
 
                ss += "  %s:\n%s\n" % (key, aux[1:])
56
 
        return( ss.rstrip() )
57