@@ -90,7 +90,7 @@ def predicted_rb_number(model, target_model, weights=None, d=None, rtype='EI'):
90
90
"""
91
91
if d is None : d = int (round (_np .sqrt (model .dim )))
92
92
p = predicted_rb_decay_parameter (model , target_model , weights = weights )
93
- r = _rbtls .p_to_r (p , d = d , rtype = rtype )
93
+ r = _rbtls .p_to_r (p , d = d , rtype = rtype ) if p != _np . nan else _np . nan
94
94
return r
95
95
96
96
@@ -132,15 +132,18 @@ def predicted_rb_decay_parameter(model, target_model, weights=None):
132
132
The second largest eigenvalue of L. This is the RB decay parameter
133
133
for various types of RB.
134
134
"""
135
- L = L_matrix (model , target_model , weights = weights )
136
- E = _np .absolute (_np .linalg .eigvals (L ))
137
- E = _np .flipud (_np .sort (E ))
138
- if abs (E [0 ] - 1 ) > 10 ** (- 12 ):
139
- _warnings .warn ("Output may be unreliable because the model is not approximately trace-preserving." )
140
-
141
- if E [1 ].imag > 10 ** (- 10 ):
142
- _warnings .warn ("Output may be unreliable because the RB decay constant has a significant imaginary component." )
143
- p = abs (E [1 ])
135
+ try :
136
+ L = L_matrix (model , target_model , weights = weights )
137
+ E = _np .absolute (_np .linalg .eigvals (L ))
138
+ E = _np .flipud (_np .sort (E ))
139
+ if abs (E [0 ] - 1 ) > 10 ** (- 12 ):
140
+ _warnings .warn ("Output may be unreliable because the model is not approximately trace-preserving." )
141
+
142
+ if E [1 ].imag > 10 ** (- 10 ):
143
+ _warnings .warn ("Output may be unreliable because the RB decay constant has a significant imaginary component." )
144
+ p = abs (E [1 ])
145
+ except _np .linalg .LinAlgError :
146
+ p = _np .nan
144
147
return p
145
148
146
149
0 commit comments