Package SloppyCell :: Module OldScipySupport
[hide private]

Source Code for Module SloppyCell.OldScipySupport

 1  """ 
 2  Alters SciPy 0.3.2 to look like version SciPy 0.5.1 as far as SloppyCell is 
 3  concerned. 
 4   
 5  See also addAssignmentRulesToFunctionBody in ReactionNetworks/Network_mod.py 
 6  """ 
 7  import scipy 
 8   
 9  if int(scipy.__version__.split('.')[1]) < 4: 
10      # Type names have changed 
11      scipy.float_ = scipy.Float 
12      scipy.float64 = scipy.Float64 
13      scipy.int_ = scipy.Int 
14      scipy.int32 = scipy.Int32 
15   
16      # Create an empty class to move around the limits module 
17      # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52308 
18 - class Bunch(dict):
19 - def __init__(self,**kw):
20 dict.__init__(self,kw) 21 self.__dict__.update(kw)
22 23 # Move scipy.limits to scipy.misc.limits 24 scipy.misc = Bunch(limits = scipy.limits) 25 26 # The seeding for the random number generator has changed. This 27 # should be compatible and useful 28 scipy.stats.old_seed = scipy.stats.seed
29 - def new_seed(seed=None):
30 if seed is None: 31 scipy.stats.old_seed() 32 return 33 34 try: 35 if len(seed) >= 2: 36 scipy.stats.old_seed(seed[0], seed[1]) 37 else: 38 scipy.stats.old_seed(seed[0]) 39 except TypeError: 40 scipy.stats.old_seed(seed, 0)
41 scipy.random = Bunch(seed = new_seed) 42 43 # Move around fft function 44 scipy.old_fft = scipy.fft 45 scipy.fft = Bunch(rfft = scipy.old_fft, irfft = scipy.ifft) 46 47 # Method renamed 48 scipy.outer = scipy.outerproduct 49 50 scipy.old_sum = scipy.sum
51 - def new_sum(x, axis=None, dtype=None, out=None):
52 if (dtype is not None) or (out is not None): 53 raise ValueError, "This use of sum is incompatible with old scipy." 54 if (axis is not None): 55 return scipy.old_sum(x, axis) 56 57 output = x 58 for ax in range(len(x.shape)): 59 output = scipy.old_sum(output) 60 return output
61 scipy.sum = new_sum 62