Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write unit tests #223

Open
29 of 76 tasks
nielsenmb opened this issue Feb 25, 2020 · 1 comment
Open
29 of 76 tasks

Write unit tests #223

nielsenmb opened this issue Feb 25, 2020 · 1 comment

Comments

@nielsenmb
Copy link
Collaborator

nielsenmb commented Feb 25, 2020

This is a problem description for the PBjam Hackday:

Problem: Currently only some of the modules in PBjam have unit tests, and those that do are probably not complete and/or tested in a sensible way.

Possible Solution: Have a look at some of the unit tests that are already written for PBjam, and maybe duplicate these to test other parts of PBjam. Some of these may be simple tests that check the shape of an object given some sensible (or not) input, or that a function returns a known value given some predefined input, e.g. 1+1 = 2. Other functions may require more bespoke tests.

asy_peakbag.py

  • pbjam/asy_peakbag.py: def _get_nmax(self, dnu, numax, eps):
  • pbjam/asy_peakbag.py: def _get_enns(self, nmax, norders):
  • pbjam/asy_peakbag.py: def _asymptotic_relation(self, numax, dnu, eps, alpha, norders):
  • pbjam/asy_peakbag.py: def _P_envelope(self, nu, hmax, numax, width):
  • pbjam/asy_peakbag.py: def _lor(self, freq, h, w):
  • pbjam/asy_peakbag.py: def _pair(self, freq0, h, w, d02, hfac=0.7):
  • pbjam/asy_peakbag.py: def model(self, dnu, numax, eps, d02, alpha, hmax, envwidth, modewidth,
  • pbjam/asy_peakbag.py: def call(self, p): # asymp_spec_model class init
  • pbjam/asy_peakbag.py: def init(self, f, norders): # asymp_spec_model class call
  • pbjam/asy_peakbag.py: def init(self, st, norders=None): # asymptotic fit class init
  • pbjam/asy_peakbag.py: def call(self): # asymptotic fit class call This is a slow one
  • pbjam/asy_peakbag.py: def prior(self, p):
  • pbjam/asy_peakbag.py: def likelihood(self, p):
  • pbjam/asy_peakbag.py: def _get_summary_stats(self, fit):
  • pbjam/asy_peakbag.py: def get_modeIDs(self, fit, norders):
  • pbjam/asy_peakbag.py: def _get_asy_start(self):
  • pbjam/asy_peakbag.py: def _get_freq_range(self):

jar.py

  • pbjam/jar.py:def get_priorpath():
  • pbjam/jar.py:def get_percentiles(X, sigma = 2, **kwargs):
  • pbjam/jar.py:def to_log10(x, xerr):
  • pbjam/jar.py:def normal(x, mu, sigma):

mcmc.py

  • pbjam/mcmc.py: def init(self, start, likelihood, prior, nwalkers=50): # mcmc class init
  • pbjam/mcmc.py: def logpost(self, p):
  • pbjam/mcmc.py: def stationarity(self, nfactor=20):
  • pbjam/mcmc.py: def call(self, max_iter=20000, spread=1e-4, start_samples=[]):
  • pbjam/mcmc.py: def fold(self, pos, accept_lim = 0.2, spread=0.1): # mcmc class call

peakbag.py

  • pbjam/peakbag.py: def init(self, starinst, init=True, path=None, verbose=False): # Peakbag class init
  • pbjam/peakbag.py: def make_start(self):
  • pbjam/peakbag.py: def remove_outsiders(self, l0, l2):
  • pbjam/peakbag.py: def trim_ladder(self, lw_fac=10, extra=0.01, verbose=False):
  • pbjam/peakbag.py: def lor(self, freq, w, h):
  • pbjam/peakbag.py: def model(self, l0, l2, width0, width2, height0, height2, back):
  • pbjam/peakbag.py: def init_model(self, model_type):
  • pbjam/peakbag.py: def call(self, model_type='simple', tune=1500, nthreads=1, maxiter=4,) # Peakbag class call

plotting.py

  • pbjam/plotting.py: def init(self): # Plotting class init
  • pbjam/plotting.py: def _save_my_fig(self, fig, figtype, path, ID):
  • pbjam/plotting.py: def plot_echelle(self, pg=None, path=None, ID=None, savefig=False):
  • pbjam/plotting.py: def plot_corner(self, path=None, ID=None, savefig=False):
  • pbjam/plotting.py: def plot_spectrum(self, pg=None, path=None, ID=None, savefig=False):
  • pbjam/plotting.py: def _fill_diag(self, axes, vals, vals_err, idxs):
  • pbjam/plotting.py: def _plot_offdiag(self, axes, vals, vals_err, idxs):
  • pbjam/plotting.py: def _make_prior_corner(self, df, numax_rng = 100):
  • pbjam/plotting.py: def plot_prior(self, path=None, ID=None, savefig=False):
  • pbjam/plotting.py: def plot_start(self):

prior.py

  • pbjam/priors.py: def init(self, starinst=None, prior_file=None): # KDE class init
  • pbjam/priors.py: def select_prior_data(self, numax=None, KDEsize = 100):
  • pbjam/priors.py: def _prior_size_check(self, pdata, numax, KDEsize):
  • pbjam/priors.py: def make_kde(self, bw_fac=1.0):
  • pbjam/priors.py: def prior(self, p):
  • pbjam/priors.py: def likelihood(self, p):
  • pbjam/priors.py: def kde_predict(self, n):
  • pbjam/priors.py: def kde_sampler(self, nwalkers=50):
  • pbjam/priors.py: def call(self, dnu=[1, -1], numax=[1, -1], teff=[1, -1], # KDE class call

session.py

  • pbjam/session.py:def _organize_sess_dataframe(vardf):
  • pbjam/session.py:def _organize_sess_input(**vardct):
  • pbjam/session.py:def _launch_query(id, download_dir, lkwargs):
  • pbjam/session.py:def _sort_lc(lc):
  • pbjam/session.py:def _clean_lc(lc):
  • pbjam/session.py:def _set_cadence(lkwargs):
  • pbjam/session.py:def _set_cache_dir(download_dir):
  • pbjam/session.py:def _set_mission(ID, lkwargs):
  • pbjam/session.py:def _lookup_cached_files(id, download_dir, ext):
  • pbjam/session.py:def _query_lightkurve(id, download_dir, use_cached, lkwargs):
  • pbjam/session.py:def _arr_to_lk(x, y, name, typ):
  • pbjam/session.py:def _format_col(vardf, col, key):
  • pbjam/session.py:def _lc_to_lk(vardf, download_dir, use_cached=True):
  • pbjam/session.py:def _lk_to_pg(vardf):
  • pbjam/session.py: def init(self, ID=None, numax=None, dnu=None, teff=None, bp_rp=None) # Session class init
  • pbjam/session.py: def call(self, bw_fac=1, norders=8, model_type='simple', tune=1500,) # Session class call

star.py

  • pbjam/star.py: def init(self, ID, pg, numax, dnu, teff, bp_rp, path=None) # Star class init
  • pbjam/star.py: def _outpath(self, x):
  • pbjam/star.py: def _set_outpath(self, path):
  • pbjam/star.py: def run_kde(self, bw_fac=1.0, make_plots=False):
  • pbjam/star.py: def run_asy_peakbag(self, norders, make_plots=False,
  • pbjam/star.py: def run_peakbag(self, model_type='simple', tune=1500, nthreads=1,
  • pbjam/star.py: def call(self, bw_fac=1.0, norders=8, model_type='simple', tune=1500) # Star class call
@grd349
Copy link
Owner

grd349 commented Mar 18, 2020

Let's write lots of unit tests. It would be nice if we could get a figure for code coverage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants