Skip to content

Commit

Permalink
catch for singular matrix MIX
Browse files Browse the repository at this point in the history
  • Loading branch information
rutgerfick committed Oct 4, 2018
1 parent ba3ab9b commit fbac002
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion dmipy/optimizers/mix.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,11 @@ def __call__(self, data, x0_vector=np.array([np.nan])):
# step 2: Estimating linear variables using COBYLA
phi = self.model(self.acquisition_scheme,
quantity="stochastic cost function", **parameters)
phi_inv = np.dot(np.linalg.inv(np.dot(phi.T, phi)), phi.T)
try:
phi_inv = np.dot(np.linalg.inv(np.dot(phi.T, phi)), phi.T)
except np.linalg.linalg.LinAlgError:
# happens when models have the same signal attenuations.
vf = np.ones(self.Nmodels) / float(self.Nmodels)
vf_x0 = np.dot(phi_inv, data)
vf_x0 /= np.sum(np.clip(vf_x0, 0, np.inf))
vf = fmin_cobyla(self.cobyla_cost_function, x0=vf_x0,
Expand Down

0 comments on commit fbac002

Please sign in to comment.