fix: Fixed numpy 1.12 indexing and shape preservation

This commit is contained in:
mzwiessele 2017-02-23 14:45:18 +00:00
parent afe37dbfd8
commit 6cd13ac2b3
9 changed files with 26 additions and 25 deletions

View file

@ -293,13 +293,13 @@ class StateSpace(Model):
# Update step (only if there is data)
if not np.isnan(Y[:,k]):
if Y.shape[0]==1:
K = PF[:,:,k].dot(H.T)/(H.dot(PF[:,:,k]).dot(H.T) + R)
else:
LL = linalg.cho_factor(H.dot(PF[:,:,k]).dot(H.T) + R)
K = linalg.cho_solve(LL, H.dot(PF[:,:,k].T)).T
MF[:,k] += K.dot(Y[:,k]-H.dot(MF[:,k]))
PF[:,:,k] -= K.dot(H).dot(PF[:,:,k])
if Y.shape[0]==1:
K = PF[:,:,k].dot(H.T)/(H.dot(PF[:,:,k]).dot(H.T) + R)
else:
LL = linalg.cho_factor(H.dot(PF[:,:,k]).dot(H.T) + R)
K = linalg.cho_solve(LL, H.dot(PF[:,:,k].T)).T
MF[:,k] += K.dot(Y[:,k]-H.dot(MF[:,k]))
PF[:,:,k] -= K.dot(H).dot(PF[:,:,k])
# Return values
return (MF, PF)

View file

@ -215,7 +215,7 @@ class R_handling_Python(Measurement_Callables_Class):
inv_R_square_root(k)
"""
self.R = R
self.index = index
self.index = np.asarray(index, np.int_)
self.R_time_var_index = int(R_time_var_index)
self.dR = dR
@ -350,7 +350,7 @@ class Q_handling_Python(Dynamic_Callables_Class):
"""
self.Q = Q
self.index = index
self.index = np.asarray(index, np.int_)
self.Q_time_var_index = Q_time_var_index
self.dQ = dQ
@ -427,7 +427,7 @@ class Std_Dynamic_Callables_Python(Q_handling_Class):
self).__init__(Q, index, Q_time_var_index, unique_Q_number, dQ)
self.A = A
self.A_time_var_index = A_time_var_index
self.A_time_var_index = np.asarray(A_time_var_index, np.int_)
self.dA = dA
def f_a(self, k, m, A):