Skip to content

Commit

Permalink
Catch LinalgError (#362)
Browse files Browse the repository at this point in the history
  • Loading branch information
JulienPeloton authored Dec 12, 2023
1 parent b855ff1 commit 6c2656b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
3 changes: 2 additions & 1 deletion fink_science/agn/feature_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from pandas.testing import assert_frame_equal # noqa: F401
import fink_science.agn.kernel as k
import numpy as np
from numpy.linalg import LinAlgError
import pickle # noqa: F401
from scipy.optimize import curve_fit
import warnings
Expand Down Expand Up @@ -534,7 +535,7 @@ def parametric_bump(ps, band):
fit = curve_fit(mod.bump, ps[f"cjd_{band}"], ps[f"cflux_{band}"], sigma=ps[f"csigflux_{band}"],
p0=[0.225, -2.5, 0.038, get_min(ps[f"cflux_{band}"])], maxfev=k.MAXFEV)

except (RuntimeError, ValueError):
except (RuntimeError, ValueError, LinAlgError):
fit = [[0.225, -2.5, 0.038, -1]]

return fit[0]
Expand Down
15 changes: 9 additions & 6 deletions fink_science/slsn/feature_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,19 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pickle # noqa: F401
import warnings
from scipy.optimize import curve_fit

import pandas as pd
import numpy as np
from numpy.linalg import LinAlgError

import fink_science.slsn.kernel as k
import fink_science.slsn.models as mod
import fink_science.agn.feature_extraction as fe_agn

from pandas.testing import assert_frame_equal # noqa: F401
import fink_science.slsn.kernel as k
import numpy as np
import pickle # noqa: F401
from scipy.optimize import curve_fit
import warnings


def transform_data(formated):
Expand Down Expand Up @@ -109,7 +112,7 @@ def parametric_func(ps, band):
try:
fit = curve_fit(mod.mvsr_right_transient, ps[f"cjd_{band}"], ps[f"cflux_{band}"], sigma=ps[f"csigflux_{band}"], p0=[-0.005, 0.015, 15], bounds=([-2, 0, -300], [0, 2, 300]), maxfev=k.MAXFEV)

except (RuntimeError, ValueError):
except (RuntimeError, ValueError, LinAlgError):
fit = [[0, 0, 0]]

return fit[0]
Expand Down

0 comments on commit 6c2656b

Please sign in to comment.