/usr/lib/python2.7/dist-packages/pymc/calc_utils.py is in python-pymc 2.2+ds-1.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | '''
Created on Jan 20, 2011
@author: jsalvatier
'''
import numpy as np
from collections import defaultdict
_sts_memory = defaultdict(dict)
def sum_to_shape(key1,key2, value, sum_shape):
try :
axes, lx = _sts_memory[key1][key2]
except KeyError:
value_shape = np.array(np.shape(value))
sum_shape_expanded = np.zeros(value_shape.size)
sum_shape_expanded[0:len(sum_shape)] += np.array(sum_shape)
axes = np.where(sum_shape_expanded != value_shape)[0]
lx = np.size(axes)
_sts_memory[key1][key2] = (axes, lx )
if lx > 0:
return np.apply_over_axes(np.sum, value, axes)
else:
return value
|