# 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)


import numpy as np
from frbpoppy.misc import pprint

    def __str__(self):
        """How to print the class."""
        # Set up title
        f = '{:20.19} {:>10} {:>10} {:>10}\n'
        t = f.format(self.name, 'Days', f'{self.object_type.title()}s', '%')
        line = '-'*len(t.split('\n')[-2].strip()) + '\n'
        t += line

        def r(value, d=4):
            """Round a value"""
            return round(value, d)

        def per(value):
            """Calculate the percentage."""
            return r(value/self.tot * 100)

        # Format rates
        days = r(self.days)
        t += f.format('Cosmic Population', days, r(self.tot), 100)
        t += f.format('Too late', days, r(self.late), per(self.late))
        t += f.format('Outside survey', days, r(self.out), per(self.out))
        t += f.format('Outside pointings', days, r(self.pointing),
                      per(self.pointing))
        t += f.format('Too faint', days, r(self.faint), per(self.faint))
        t += f.format('Detected', days, r(self.det), per(self.det))
        t += f.format('/Gpc^3', 365.25, r(self.vol, 2), '-')
        t += f.format('Expected', r(self.exp, 4), 1, '-')
        t += line


# 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/rates.py
import numpy as np
from frbpoppy.misc import pprint


    def __str__(self):
        """How to print the class."""
        # Set up title
        f = '{:20.19} {:>10} {:>10} {:>10}\n'
        t = f.format(self.name, 'Days', f'{self.object_type.title()}s', '%')
        line = '-'*len(t.split('\n')[-2].strip()) + '\n'
        t += line

        def r(value, d=4):
            """Round a value"""
            return round(value, d)

        def per(value):
            """Calculate the percentage."""
            return r(value/self.tot * 100)

        # Format rates
        days = r(self.days)
        t += f.format('Cosmic Population', days, r(self.tot), 100)
        t += f.format('Too late', days, r(self.late), per(self.late))
        t += f.format('Outside survey', days, r(self.out), per(self.out))
        t += f.format('Outside pointings', days, r(self.pointing),
                      per(self.pointing))
        t += f.format('Too faint', days, r(self.faint), per(self.faint))
        t += f.format('Detected', days, r(self.det), per(self.det))
        t += f.format('/Gpc^3', 365.25, r(self.vol, 2), '-')
        t += f.format('Expected', r(self.exp, 4), 1, '-')
        t += line


        return pprint(t, output=False)