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

« back to all changes in this revision

Viewing changes to Lib/interpolate/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
 
 
2
from scipy_base import *
 
3
from scipy_base.fastumath import *
 
4
 
 
5
def myasarray(a):
 
6
    if type(a) in [type(1.0),type(1L),type(1),type(1j)]:
 
7
        return asarray([a])
 
8
    elif type(a) is ArrayType and len(a)==1:
 
9
        # Takes care of mapping array(number) to array([number])
 
10
        return asarray([a[0]])
 
11
    else:
 
12
        return asarray(a)
 
13
 
 
14
def check_func(thefunc, x0, args, numinputs, output_shape=None):
 
15
    args = (x0[:numinputs],) + args
 
16
    res = myasarray(apply(thefunc,args))
 
17
    if (output_shape != None) and (res.shape != output_shape):
 
18
        if (output_shape[0] != 1):
 
19
            if len(output_shape) > 1:
 
20
                if output_shape[1] == 1:
 
21
                    return res.shape
 
22
            raise TypeError, "There is a mismatch between the input and output shape of %s." % thefunc.func_name
 
23
    return res.shape
 
24
 
 
25
 
 
26