C2MV commited on
Commit
981f292
1 Parent(s): b0373ec

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -0
app.py CHANGED
@@ -64,6 +64,14 @@ class CalibrationModel:
64
  self.fit_calibration = self.fit_calibration_linear
65
 
66
  def fit_calibration_linear(self, concentration, absorbance, bounds):
 
 
 
 
 
 
 
 
67
  popt, _ = curve_fit(self.linear, concentration, absorbance, bounds=bounds, maxfev=10000)
68
  self.params['calibration'] = {'m': popt[0], 'b': popt[1]}
69
  y_pred = self.linear(concentration, *popt)
 
64
  self.fit_calibration = self.fit_calibration_linear
65
 
66
  def fit_calibration_linear(self, concentration, absorbance, bounds):
67
+ # Eliminar valores NaN e inf
68
+ mask = ~np.isnan(concentration) & ~np.isnan(absorbance) & np.isfinite(concentration) & np.isfinite(absorbance)
69
+ concentration = concentration[mask]
70
+ absorbance = absorbance[mask]
71
+
72
+ if len(concentration) == 0 or len(absorbance) == 0:
73
+ raise ValueError("No valid data points for fitting.")
74
+
75
  popt, _ = curve_fit(self.linear, concentration, absorbance, bounds=bounds, maxfev=10000)
76
  self.params['calibration'] = {'m': popt[0], 'b': popt[1]}
77
  y_pred = self.linear(concentration, *popt)