# import standard modules
import numpy as np
# import custom modules
[docs]def checkinvPriorShape(livePointsPhys, livePointsShape):
"""
check livePointsPhys is correct shape
"""
assert (livePointsPhys.shape == livePointsShape
), "livePointsPhys shape must be same as livePoints shape"
[docs]def checkLhoodShape(livePointsLhood, nLive):
"""
scipy.stats.continuous_rv methods return Lhoods of shape (nLive, 1)
whereas scipy.stats.multivariate_normal method return Lhoods of shape (nLive,).
The former is converted to the latter for consistency (and the Keeton equations don't work otherwise)
"""
assert (livePointsLhood.shape == (nLive, 1) or
livePointsLhood.shape == (nLive, )
), "livePointsLhood wrong shape. should be (%s,) or (%s,1)" % (
nLive, nLive)
if livePointsLhood.shape == (nLive, 1):
print("converting shape from (%s, 1) to (%s,)" % (nLive, nLive))
return livePointsLhood.reshape(-1, )
else:
return livePointsLhood
[docs]def checkTargSupShape(targetSupport, nDims):
"""
check targetSupport is correct shape
"""
assert (targetSupport.shape == (
3, nDims)), "target support array should have shape (3, nDims)"