validate inputs in LightCurve
@@ -35,13 +35,21 @@ class LightCurve(object):
"""
def __init__(self, time, flux, flux_err=None, meta={}):
- self.time = np.asarray(time)
- self.flux = np.asarray(flux)
+ self.time, self.flux, self.flux_err = self._validate_inputs(time, flux, flux_err)
+ self.meta = meta
+
+ def _validate_inputs(self, time, flux, flux_err):
if flux_err is not None:
- self.flux_err = np.asarray(flux_err)
+ flux_err = np.asarray(flux_err)
else:
- self.flux_err = np.nan * np.ones_like(self.time)
- self.meta = meta
+ flux_err = np.nan * np.ones_like(time)
+
+ if ~(len(time) == len(flux) == len(flux_err)):
+ raise ValueError("Input arrays have different lengths."
+ "len(time)={}, len(flux)={}, len(flux_err)={}"
+ .format(len(time), len(flux), len(flux_err)))
+
+ return np.asarray(time), np.asarray(flux), flux_err
def stitch(self, *others):
"""
