~ubuntu-branches/ubuntu/karmic/python-scipy/karmic

« back to all changes in this revision

Viewing changes to Lib/optimize/common_routines.py

  • Committer: Bazaar Package Importer
  • Author(s): Daniel T. Chen (new)
  • Date: 2005-03-16 02:15:29 UTC
  • Revision ID: james.westby@ubuntu.com-20050316021529-xrjlowsejs0cijig
Tags: upstream-0.3.2
ImportĀ upstreamĀ versionĀ 0.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from scipy_base import *
 
2
from scipy_base.fastumath import *
 
3
 
 
4
def myasarray(a):
 
5
    if type(a) in [type(1.0),type(1L),type(1),type(1j)]:
 
6
        a = asarray([a])
 
7
    if len(a) == 0:
 
8
        a = asarray([a])
 
9
    return a
 
10
 
 
11
def check_func(thefunc, x0, args, numinputs, output_shape=None):
 
12
    args = (x0[:numinputs],) + args
 
13
    res = myasarray(apply(thefunc,args))
 
14
    if (output_shape != None) and (shape(res) != output_shape):
 
15
        if (output_shape[0] != 1):
 
16
            if len(output_shape) > 1:
 
17
                if output_shape[1] == 1:
 
18
                    return shape(res)
 
19
            raise TypeError, "There is a mismatch between the input and output shape of %s." % thefunc.func_name
 
20
    return shape(res)
 
21
 
 
22
 
 
23