MCPcopy
hub / github.com/mne-tools/mne-python / _safe_svd

Function _safe_svd

mne/fixes.py:120–136  ·  view source on GitHub ↗

Get around the SVD did not converge error of death.

(A, **kwargs)

Source from the content-addressed store, hash-verified

118
119
120def _safe_svd(A, **kwargs):
121 """Get around the SVD did not converge error of death."""
122 # Intel has a bug with their GESVD driver:
123 # https://software.intel.com/en-us/forums/intel-distribution-for-python/topic/628049 # noqa: E501
124 # For SciPy 0.18 and up, we can work around it by using
125 # lapack_driver='gesvd' instead.
126 from scipy import linalg
127
128 if kwargs.get("overwrite_a", False):
129 raise ValueError("Cannot set overwrite_a=True with this function")
130 try:
131 return linalg.svd(A, **kwargs)
132 except np.linalg.LinAlgError as exp:
133 from .utils import warn
134
135 warn(f"SVD error ({exp}), attempting to use GESVD instead of GESDD")
136 return linalg.svd(A, lapack_driver="gesvd", **kwargs)
137
138
139def _csc_array_cast(x):

Callers 15

get_dataFunction · 0.90
label_sign_flipFunction · 0.85
_pca_flipFunction · 0.85
_compute_projFunction · 0.85
sensitivity_mapFunction · 0.85
regularizeFunction · 0.85
_fit_QFunction · 0.85
fit_dipoleFunction · 0.85
_pinv_truncFunction · 0.85
pinvFunction · 0.85

Calls 1

warnFunction · 0.85

Tested by 2

get_dataFunction · 0.72