# Path: thejoker/logging.py
# class JokerHandler(StreamHandler):
# class JokerLogger(logging.getLoggerClass()):
#     def emit(self, record):
#     def _set_defaults(self):
# 
# Path: thejoker/data_helpers.py
# def guess_time_format(time_val):
#     """Guess the `astropy.time.Time` format from the input value(s).
# 
#     Parameters
#     ----------
#     time_val : float, array_like
#         The value or values to guess the format from.
# 
#     Returns
#     -------
#     format : str
#         The `astropy.time.Time` format string, guessed from the value.
# 
#     """
#     arr = np.array(time_val)
# 
#     # Only support float or int times
#     if arr.dtype.char not in ['f', 'd', 'i', 'l']:
#         raise NotImplementedError("We can only try to guess "
#                                   "the time format with a numeric "
#                                   "time value. Sorry about that!")
# 
#     # HACK: magic number!
#     dt_thresh = 50*u.year
# 
#     jd_check = np.abs(arr - Time('2010-01-01').jd) * u.day < dt_thresh
#     jd_check = np.all(jd_check)
# 
#     mjd_check = np.abs(arr - Time('2010-01-01').mjd) * u.day < dt_thresh
#     mjd_check = np.all(mjd_check)
# 
#     err_msg = ("Unable to guess time format! Initialize with an "
#                "explicit astropy.time.Time() object instead.")
#     if jd_check and mjd_check:
#         raise ValueError(err_msg)
# 
#     elif jd_check:
#         return 'jd'
# 
#     elif mjd_check:
#         return 'mjd'
# 
#     else:
#         raise ValueError(err_msg)
# 
# Path: thejoker/exceptions.py
# class TheJokerDeprecationWarning(Warning):
#     """Because standard deprecation warnings are ignored!"""
#     pass


import warnings
import astropy.units as u
import numpy as np
            import matplotlib.pyplot as plt
from astropy.table import Table
from astropy.time import Time
from astropy.utils.decorators import deprecated_renamed_argument
from .logging import logger
from .data_helpers import guess_time_format
from .exceptions import TheJokerDeprecationWarning
                from fuzzywuzzy import process
        from astropy.timeseries import TimeSeries
        from astropy.timeseries import TimeSeries

        if self.rv_err.ndim == 1:
            self._has_cov = False
        elif self.rv_err.ndim == 2:
            self._has_cov = True

        if (self.rv_err.shape != (self.rv.size, self.rv.size)
                and self.rv_err.shape != (self.rv.size, )):
            raise ValueError(f"Invalid shape for input RV error "
                             f"{self.rv_err.shape}. Should either be "
                             f"({self.rv.size},) or "
                             f"({self.rv.size}, {self.rv.size})")

        # make sure shapes are consistent
        if self._t_bmjd.shape != self.rv.shape:
            raise ValueError(f"Shape of input times and RVs must be consistent"
                             f" ({self._t_bmjd.shape} vs {self.rv.shape})")

        if clean:
            # filter out NAN or INF data points
            idx = (np.isfinite(self._t_bmjd)
                   & np.isfinite(self.rv))

            if self._has_cov:
                idx &= np.isfinite(self.rv_err).all(axis=0)
            else:
                idx &= np.isfinite(self.rv_err)

            n_filter = len(self.rv) - idx.sum()
            if n_filter > 0:

# Path: thejoker/logging.py
# class JokerHandler(StreamHandler):
# class JokerLogger(logging.getLoggerClass()):
#     def emit(self, record):
#     def _set_defaults(self):
# 
# Path: thejoker/data_helpers.py
# def guess_time_format(time_val):
#     """Guess the `astropy.time.Time` format from the input value(s).
# 
#     Parameters
#     ----------
#     time_val : float, array_like
#         The value or values to guess the format from.
# 
#     Returns
#     -------
#     format : str
#         The `astropy.time.Time` format string, guessed from the value.
# 
#     """
#     arr = np.array(time_val)
# 
#     # Only support float or int times
#     if arr.dtype.char not in ['f', 'd', 'i', 'l']:
#         raise NotImplementedError("We can only try to guess "
#                                   "the time format with a numeric "
#                                   "time value. Sorry about that!")
# 
#     # HACK: magic number!
#     dt_thresh = 50*u.year
# 
#     jd_check = np.abs(arr - Time('2010-01-01').jd) * u.day < dt_thresh
#     jd_check = np.all(jd_check)
# 
#     mjd_check = np.abs(arr - Time('2010-01-01').mjd) * u.day < dt_thresh
#     mjd_check = np.all(mjd_check)
# 
#     err_msg = ("Unable to guess time format! Initialize with an "
#                "explicit astropy.time.Time() object instead.")
#     if jd_check and mjd_check:
#         raise ValueError(err_msg)
# 
#     elif jd_check:
#         return 'jd'
# 
#     elif mjd_check:
#         return 'mjd'
# 
#     else:
#         raise ValueError(err_msg)
# 
# Path: thejoker/exceptions.py
# class TheJokerDeprecationWarning(Warning):
#     """Because standard deprecation warnings are ignored!"""
#     pass


# Path: thejoker/data.py
import warnings
import astropy.units as u
import numpy as np
            import matplotlib.pyplot as plt
from astropy.table import Table
from astropy.time import Time
from astropy.utils.decorators import deprecated_renamed_argument
from .logging import logger
from .data_helpers import guess_time_format
from .exceptions import TheJokerDeprecationWarning
                from fuzzywuzzy import process
        from astropy.timeseries import TimeSeries
        from astropy.timeseries import TimeSeries


        if self.rv_err.ndim == 1:
            self._has_cov = False
        elif self.rv_err.ndim == 2:
            self._has_cov = True

        if (self.rv_err.shape != (self.rv.size, self.rv.size)
                and self.rv_err.shape != (self.rv.size, )):
            raise ValueError(f"Invalid shape for input RV error "
                             f"{self.rv_err.shape}. Should either be "
                             f"({self.rv.size},) or "
                             f"({self.rv.size}, {self.rv.size})")

        # make sure shapes are consistent
        if self._t_bmjd.shape != self.rv.shape:
            raise ValueError(f"Shape of input times and RVs must be consistent"
                             f" ({self._t_bmjd.shape} vs {self.rv.shape})")

        if clean:
            # filter out NAN or INF data points
            idx = (np.isfinite(self._t_bmjd)
                   & np.isfinite(self.rv))

            if self._has_cov:
                idx &= np.isfinite(self.rv_err).all(axis=0)
            else:
                idx &= np.isfinite(self.rv_err)

            n_filter = len(self.rv) - idx.sum()
            if n_filter > 0:

                logger.info(f"Filtering {n_filter} NaN/Inf data points")