# Path: frbpoppy/misc.py
# def pprint(*s, output=True):
#     """Hack to make for more informative print statements."""
#     f = inspect.stack()[1][1].split('/')[-1]
#     m = '{:13.13} |'.format(f)
# 
#     if output:
#         print(m, *s)
#     else:
#         lines = []
#         for e in s:
#             lines.append('\n'.join([f'{m} {f}' for f in e.split('\n')]))
#         return '\n'.join(lines)
# 
# Path: frbpoppy/paths.py
# class Paths():
#     def __init__(self):
#     def __str__(self):
#     def check(self, path):
#     def store(self, name, default, *args):
#     def data(self, *args):
#     def populations(self, *args):
#     def surveys(self, *args):
#     def models(self, *args):
#     def frbcat(self, *args):
# 
# Path: frbpoppy/population.py
# class Population:
#     """Class to hold a population of FRBs."""
# 
#     def __init__(self):
#         """Initializing."""
#         # Population properties
#         self.name = None
# 
#         # Frequency emission limits [MHz]
#         self.f_max = None
#         self.f_min = None
# 
#         # Store FRB sources
#         self.frbs = FRBs()
#         self.uid = None  # Unique Identifier
# 
#     def __str__(self):
#         """Define how to print a population object to a console."""
#         s = 'Population properties:'
# 
#         # TODO: Code this to print all properties
# 
#         return s
# 
#     def to_df(self):
#         """Gather source values into a pandas dataframe."""
#         df = self.frbs.to_df()
#         return df
# 
#     def save(self, path=None):
#         """
#         Write out source properties as data file.
# 
#         Args:
#             path (str): Path to which to save.
#         """
#         if path is None:
#             # Check if a population has been a survey name
#             if not self.name:
#                 file_name = 'pop'
#             else:
#                 file_name = self.name.lower()
# 
#             if self.uid:
#                 file_name += f'_{self.uid}'
# 
#             path = paths.populations() + f'{file_name}.p'
# 
#         self.to_pickle(path)
# 
#     def to_csv(self, path):
#         """Write a population to a csv file.
# 
#         Args:
#             path (str): Path to which to write
# 
#         """
#         df = self.frbs.to_df()
#         df.to_csv(path)
# 
#     def to_pickle(self, path):
#         """Write a population to a pickled file for future use.
# 
#         Args:
#             path (str): Path to which to write
# 
#         """
#         output = open(path, 'wb')
#         pickle.dump(self, output, 2)
#         output.close()
# 
#     def n_sources(self):
#         """Return the number of FRB sources."""
#         return len(self.frbs.ra)
# 
#     def n_srcs(self):
#         return self.n_sources()
# 
#     def n_bursts(self):
#         """Return the number of bursts."""
#         try:  # Will only work for a repeater population
#             n = np.count_nonzero(~np.isnan(self.frbs.time))
#         except TypeError:
#             n = self.n_sources()
#         return n
# 
#     def n_repeaters(self):
#         """Return the numer of repeaters in a population."""
#         try:
#             return np.sum((~np.isnan(self.frbs.time)).sum(1) > 1)
#         except TypeError:
#             return 0
# 
#     def n_rep(self):
#         return self.n_repeaters()
# 
#     def n_one_offs(self):
#         """Return the numer of one-offs in a population."""
#         try:
#             return np.sum((~np.isnan(self.frbs.time)).sum(1) <= 1)
#         except TypeError:
#             return self.n_sources()
# 
#     def n_oneoffs(self):
#         """Return the numer of one-offs in a population."""
#         return self.n_one_offs()


import pandas as pd
    import IPython; IPython.embed()
from frbcat import TNS as BaseTNS
from frbpoppy.misc import pprint
from frbpoppy.paths import paths
from frbpoppy.population import Population
        self.df.at[pmsurv, 'survey'] = 'parkes-pmsurv'
        htru = cond('Parkes') & (self.df[c].dt.year > 2008)
        htru &= (self.df[c].dt.year < 2015)
        self.df.at[htru, 'survey'] = 'parkes-htru'
        # This means the default survey for Parkes is superb!
        superb = cond('Parkes') & (self.df[c].dt.year >= 2015)
        self.df.at[superb, 'survey'] = 'parkes-superb'

        # Manually add some tricky ones
        self.df.at[self.df.name == 'FRB 20010125A', 'survey'] = 'parkes-swmb'
        self.df.at[self.df.name == 'FRB 20150807A', 'survey'] = 'parkes-party'
        ppta = [171209, 171209, 180309, 180309, 180311, 180311, 180714, 180714]
        for frb in ppta:
            mask = self.df.name == f'FRB 20{frb}A'
            self.df.at[mask, 'survey'] = 'parkes-ppta'

        # Check whether any FRBs have not yet been assigned
        no_surveys = self.df['survey'].isnull()
        if interrupt and any(no_surveys):
            pprint(f'There are {sum(no_surveys)} FRBs with undefined surveys')
            m = 'TNS().match_surveys() in frbpoppy/tns.py should be updated'
            pprint(m)

    def to_pop(self, df=None):
        """
        Convert to a Population object.
        """
        if not isinstance(df, pd.DataFrame):
            df = self.df


# Path: frbpoppy/misc.py
# def pprint(*s, output=True):
#     """Hack to make for more informative print statements."""
#     f = inspect.stack()[1][1].split('/')[-1]
#     m = '{:13.13} |'.format(f)
# 
#     if output:
#         print(m, *s)
#     else:
#         lines = []
#         for e in s:
#             lines.append('\n'.join([f'{m} {f}' for f in e.split('\n')]))
#         return '\n'.join(lines)
# 
# Path: frbpoppy/paths.py
# class Paths():
#     def __init__(self):
#     def __str__(self):
#     def check(self, path):
#     def store(self, name, default, *args):
#     def data(self, *args):
#     def populations(self, *args):
#     def surveys(self, *args):
#     def models(self, *args):
#     def frbcat(self, *args):
# 
# Path: frbpoppy/population.py
# class Population:
#     """Class to hold a population of FRBs."""
# 
#     def __init__(self):
#         """Initializing."""
#         # Population properties
#         self.name = None
# 
#         # Frequency emission limits [MHz]
#         self.f_max = None
#         self.f_min = None
# 
#         # Store FRB sources
#         self.frbs = FRBs()
#         self.uid = None  # Unique Identifier
# 
#     def __str__(self):
#         """Define how to print a population object to a console."""
#         s = 'Population properties:'
# 
#         # TODO: Code this to print all properties
# 
#         return s
# 
#     def to_df(self):
#         """Gather source values into a pandas dataframe."""
#         df = self.frbs.to_df()
#         return df
# 
#     def save(self, path=None):
#         """
#         Write out source properties as data file.
# 
#         Args:
#             path (str): Path to which to save.
#         """
#         if path is None:
#             # Check if a population has been a survey name
#             if not self.name:
#                 file_name = 'pop'
#             else:
#                 file_name = self.name.lower()
# 
#             if self.uid:
#                 file_name += f'_{self.uid}'
# 
#             path = paths.populations() + f'{file_name}.p'
# 
#         self.to_pickle(path)
# 
#     def to_csv(self, path):
#         """Write a population to a csv file.
# 
#         Args:
#             path (str): Path to which to write
# 
#         """
#         df = self.frbs.to_df()
#         df.to_csv(path)
# 
#     def to_pickle(self, path):
#         """Write a population to a pickled file for future use.
# 
#         Args:
#             path (str): Path to which to write
# 
#         """
#         output = open(path, 'wb')
#         pickle.dump(self, output, 2)
#         output.close()
# 
#     def n_sources(self):
#         """Return the number of FRB sources."""
#         return len(self.frbs.ra)
# 
#     def n_srcs(self):
#         return self.n_sources()
# 
#     def n_bursts(self):
#         """Return the number of bursts."""
#         try:  # Will only work for a repeater population
#             n = np.count_nonzero(~np.isnan(self.frbs.time))
#         except TypeError:
#             n = self.n_sources()
#         return n
# 
#     def n_repeaters(self):
#         """Return the numer of repeaters in a population."""
#         try:
#             return np.sum((~np.isnan(self.frbs.time)).sum(1) > 1)
#         except TypeError:
#             return 0
# 
#     def n_rep(self):
#         return self.n_repeaters()
# 
#     def n_one_offs(self):
#         """Return the numer of one-offs in a population."""
#         try:
#             return np.sum((~np.isnan(self.frbs.time)).sum(1) <= 1)
#         except TypeError:
#             return self.n_sources()
# 
#     def n_oneoffs(self):
#         """Return the numer of one-offs in a population."""
#         return self.n_one_offs()


# Path: frbpoppy/tns.py
import pandas as pd
    import IPython; IPython.embed()
from frbcat import TNS as BaseTNS
from frbpoppy.misc import pprint
from frbpoppy.paths import paths
from frbpoppy.population import Population

        self.df.at[pmsurv, 'survey'] = 'parkes-pmsurv'
        htru = cond('Parkes') & (self.df[c].dt.year > 2008)
        htru &= (self.df[c].dt.year < 2015)
        self.df.at[htru, 'survey'] = 'parkes-htru'
        # This means the default survey for Parkes is superb!
        superb = cond('Parkes') & (self.df[c].dt.year >= 2015)
        self.df.at[superb, 'survey'] = 'parkes-superb'

        # Manually add some tricky ones
        self.df.at[self.df.name == 'FRB 20010125A', 'survey'] = 'parkes-swmb'
        self.df.at[self.df.name == 'FRB 20150807A', 'survey'] = 'parkes-party'
        ppta = [171209, 171209, 180309, 180309, 180311, 180311, 180714, 180714]
        for frb in ppta:
            mask = self.df.name == f'FRB 20{frb}A'
            self.df.at[mask, 'survey'] = 'parkes-ppta'

        # Check whether any FRBs have not yet been assigned
        no_surveys = self.df['survey'].isnull()
        if interrupt and any(no_surveys):
            pprint(f'There are {sum(no_surveys)} FRBs with undefined surveys')
            m = 'TNS().match_surveys() in frbpoppy/tns.py should be updated'
            pprint(m)

    def to_pop(self, df=None):
        """
        Convert to a Population object.
        """
        if not isinstance(df, pd.DataFrame):
            df = self.df


        pop = Population()