repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
vallis/libstempo
libstempo/spharmORFbasis.py
real_rotated_Gammas
def real_rotated_Gammas(m,l,phi1,phi2,theta1,theta2,gamma_ml): """ This function returns the real-valued form of the Overlap Reduction Functions, see Eqs 47 in Mingarelli et al, 2013. """ if m>0: ans=(1./sqrt(2))*(rotated_Gamma_ml(m,l,phi1,phi2,theta1,theta2,gamma_ml) + \ ...
python
def real_rotated_Gammas(m,l,phi1,phi2,theta1,theta2,gamma_ml): """ This function returns the real-valued form of the Overlap Reduction Functions, see Eqs 47 in Mingarelli et al, 2013. """ if m>0: ans=(1./sqrt(2))*(rotated_Gamma_ml(m,l,phi1,phi2,theta1,theta2,gamma_ml) + \ ...
[ "def", "real_rotated_Gammas", "(", "m", ",", "l", ",", "phi1", ",", "phi2", ",", "theta1", ",", "theta2", ",", "gamma_ml", ")", ":", "if", "m", ">", "0", ":", "ans", "=", "(", "1.", "/", "sqrt", "(", "2", ")", ")", "*", "(", "rotated_Gamma_ml", ...
This function returns the real-valued form of the Overlap Reduction Functions, see Eqs 47 in Mingarelli et al, 2013.
[ "This", "function", "returns", "the", "real", "-", "valued", "form", "of", "the", "Overlap", "Reduction", "Functions", "see", "Eqs", "47", "in", "Mingarelli", "et", "al", "2013", "." ]
train
https://github.com/vallis/libstempo/blob/0b19300a9b24d64c9ddc25cd6ddbfd12b6231990/libstempo/spharmORFbasis.py#L281-L297
vallis/libstempo
libstempo/fit.py
chisq
def chisq(psr,formbats=False): """Return the total chisq for the current timing solution, removing noise-averaged mean residual, and ignoring deleted points.""" if formbats: psr.formbats() res, err = psr.residuals(removemean=False)[psr.deleted == 0], psr.toaerrs[psr.deleted == 0] ...
python
def chisq(psr,formbats=False): """Return the total chisq for the current timing solution, removing noise-averaged mean residual, and ignoring deleted points.""" if formbats: psr.formbats() res, err = psr.residuals(removemean=False)[psr.deleted == 0], psr.toaerrs[psr.deleted == 0] ...
[ "def", "chisq", "(", "psr", ",", "formbats", "=", "False", ")", ":", "if", "formbats", ":", "psr", ".", "formbats", "(", ")", "res", ",", "err", "=", "psr", ".", "residuals", "(", "removemean", "=", "False", ")", "[", "psr", ".", "deleted", "==", ...
Return the total chisq for the current timing solution, removing noise-averaged mean residual, and ignoring deleted points.
[ "Return", "the", "total", "chisq", "for", "the", "current", "timing", "solution", "removing", "noise", "-", "averaged", "mean", "residual", "and", "ignoring", "deleted", "points", "." ]
train
https://github.com/vallis/libstempo/blob/0b19300a9b24d64c9ddc25cd6ddbfd12b6231990/libstempo/fit.py#L4-L15
vallis/libstempo
libstempo/fit.py
dchisq
def dchisq(psr,formbats=False,renormalize=True): """Return gradient of total chisq for the current timing solution, after removing noise-averaged mean residual, and ignoring deleted points.""" if formbats: psr.formbats() res, err = psr.residuals(removemean=False)[psr.deleted == 0], psr.toa...
python
def dchisq(psr,formbats=False,renormalize=True): """Return gradient of total chisq for the current timing solution, after removing noise-averaged mean residual, and ignoring deleted points.""" if formbats: psr.formbats() res, err = psr.residuals(removemean=False)[psr.deleted == 0], psr.toa...
[ "def", "dchisq", "(", "psr", ",", "formbats", "=", "False", ",", "renormalize", "=", "True", ")", ":", "if", "formbats", ":", "psr", ".", "formbats", "(", ")", "res", ",", "err", "=", "psr", ".", "residuals", "(", "removemean", "=", "False", ")", "...
Return gradient of total chisq for the current timing solution, after removing noise-averaged mean residual, and ignoring deleted points.
[ "Return", "gradient", "of", "total", "chisq", "for", "the", "current", "timing", "solution", "after", "removing", "noise", "-", "averaged", "mean", "residual", "and", "ignoring", "deleted", "points", "." ]
train
https://github.com/vallis/libstempo/blob/0b19300a9b24d64c9ddc25cd6ddbfd12b6231990/libstempo/fit.py#L17-L41
vallis/libstempo
libstempo/fit.py
findmin
def findmin(psr,method='Nelder-Mead',history=False,formbats=False,renormalize=True,bounds={},**kwargs): """Use scipy.optimize.minimize to find minimum-chisq timing solution, passing through all extra options. Resets psr[...].val to the final solution, and returns the final chisq. Will use chisq gradient if ...
python
def findmin(psr,method='Nelder-Mead',history=False,formbats=False,renormalize=True,bounds={},**kwargs): """Use scipy.optimize.minimize to find minimum-chisq timing solution, passing through all extra options. Resets psr[...].val to the final solution, and returns the final chisq. Will use chisq gradient if ...
[ "def", "findmin", "(", "psr", ",", "method", "=", "'Nelder-Mead'", ",", "history", "=", "False", ",", "formbats", "=", "False", ",", "renormalize", "=", "True", ",", "bounds", "=", "{", "}", ",", "*", "*", "kwargs", ")", ":", "ctr", ",", "err", "="...
Use scipy.optimize.minimize to find minimum-chisq timing solution, passing through all extra options. Resets psr[...].val to the final solution, and returns the final chisq. Will use chisq gradient if method requires it. Ignores deleted points.
[ "Use", "scipy", ".", "optimize", ".", "minimize", "to", "find", "minimum", "-", "chisq", "timing", "solution", "passing", "through", "all", "extra", "options", ".", "Resets", "psr", "[", "...", "]", ".", "val", "to", "the", "final", "solution", "and", "r...
train
https://github.com/vallis/libstempo/blob/0b19300a9b24d64c9ddc25cd6ddbfd12b6231990/libstempo/fit.py#L43-L101
vallis/libstempo
libstempo/fit.py
glsfit
def glsfit(psr,renormalize=True): """Solve local GLS problem using scipy.linalg.cholesky. Update psr[...].val and psr[...].err from solution. If renormalize=True, normalize each design-matrix column by its norm.""" mask = psr.deleted == 0 res, err = psr.residuals(removemean=False)[mask], psr.to...
python
def glsfit(psr,renormalize=True): """Solve local GLS problem using scipy.linalg.cholesky. Update psr[...].val and psr[...].err from solution. If renormalize=True, normalize each design-matrix column by its norm.""" mask = psr.deleted == 0 res, err = psr.residuals(removemean=False)[mask], psr.to...
[ "def", "glsfit", "(", "psr", ",", "renormalize", "=", "True", ")", ":", "mask", "=", "psr", ".", "deleted", "==", "0", "res", ",", "err", "=", "psr", ".", "residuals", "(", "removemean", "=", "False", ")", "[", "mask", "]", ",", "psr", ".", "toae...
Solve local GLS problem using scipy.linalg.cholesky. Update psr[...].val and psr[...].err from solution. If renormalize=True, normalize each design-matrix column by its norm.
[ "Solve", "local", "GLS", "problem", "using", "scipy", ".", "linalg", ".", "cholesky", ".", "Update", "psr", "[", "...", "]", ".", "val", "and", "psr", "[", "...", "]", ".", "err", "from", "solution", ".", "If", "renormalize", "=", "True", "normalize", ...
train
https://github.com/vallis/libstempo/blob/0b19300a9b24d64c9ddc25cd6ddbfd12b6231990/libstempo/fit.py#L103-L132
vallis/libstempo
libstempo/utils.py
create_fourier_design_matrix
def create_fourier_design_matrix(t, nmodes, freq=False, Tspan=None, logf=False, fmin=None, fmax=None): """ Construct fourier design matrix from eq 11 of Lentati et al, 2013 :param t: vector of time series in seconds :param nmodes: number of fourier coefficients to use ...
python
def create_fourier_design_matrix(t, nmodes, freq=False, Tspan=None, logf=False, fmin=None, fmax=None): """ Construct fourier design matrix from eq 11 of Lentati et al, 2013 :param t: vector of time series in seconds :param nmodes: number of fourier coefficients to use ...
[ "def", "create_fourier_design_matrix", "(", "t", ",", "nmodes", ",", "freq", "=", "False", ",", "Tspan", "=", "None", ",", "logf", "=", "False", ",", "fmin", "=", "None", ",", "fmax", "=", "None", ")", ":", "N", "=", "len", "(", "t", ")", "F", "=...
Construct fourier design matrix from eq 11 of Lentati et al, 2013 :param t: vector of time series in seconds :param nmodes: number of fourier coefficients to use :param freq: option to output frequencies :param Tspan: option to some other Tspan :param logf: use log frequency spacing :param fmin...
[ "Construct", "fourier", "design", "matrix", "from", "eq", "11", "of", "Lentati", "et", "al", "2013" ]
train
https://github.com/vallis/libstempo/blob/0b19300a9b24d64c9ddc25cd6ddbfd12b6231990/libstempo/utils.py#L31-L74
vallis/libstempo
libstempo/utils.py
powerlaw
def powerlaw(f, log10_A=-16, gamma=5): """Power-law PSD. :param f: Sampling frequencies :param log10_A: log10 of red noise Amplitude [GW units] :param gamma: Spectral index of red noise process """ fyr = 1 / 3.16e7 return (10**log10_A)**2 / 12.0 / np.pi**2 * fyr**(gamma-3) * f**(-gamma)
python
def powerlaw(f, log10_A=-16, gamma=5): """Power-law PSD. :param f: Sampling frequencies :param log10_A: log10 of red noise Amplitude [GW units] :param gamma: Spectral index of red noise process """ fyr = 1 / 3.16e7 return (10**log10_A)**2 / 12.0 / np.pi**2 * fyr**(gamma-3) * f**(-gamma)
[ "def", "powerlaw", "(", "f", ",", "log10_A", "=", "-", "16", ",", "gamma", "=", "5", ")", ":", "fyr", "=", "1", "/", "3.16e7", "return", "(", "10", "**", "log10_A", ")", "**", "2", "/", "12.0", "/", "np", ".", "pi", "**", "2", "*", "fyr", "...
Power-law PSD. :param f: Sampling frequencies :param log10_A: log10 of red noise Amplitude [GW units] :param gamma: Spectral index of red noise process
[ "Power", "-", "law", "PSD", "." ]
train
https://github.com/vallis/libstempo/blob/0b19300a9b24d64c9ddc25cd6ddbfd12b6231990/libstempo/utils.py#L77-L86
vallis/libstempo
libstempo/toasim.py
add_gwb
def add_gwb(psr, dist=1, ngw=1000, seed=None, flow=1e-8, fhigh=1e-5, gwAmp=1e-20, alpha=-0.66, logspacing=True): """Add a stochastic background from inspiraling binaries, using the tempo2 code that underlies the GWbkgrd plugin. Here 'dist' is the pulsar distance [in kpc]; 'ngw' is the number of...
python
def add_gwb(psr, dist=1, ngw=1000, seed=None, flow=1e-8, fhigh=1e-5, gwAmp=1e-20, alpha=-0.66, logspacing=True): """Add a stochastic background from inspiraling binaries, using the tempo2 code that underlies the GWbkgrd plugin. Here 'dist' is the pulsar distance [in kpc]; 'ngw' is the number of...
[ "def", "add_gwb", "(", "psr", ",", "dist", "=", "1", ",", "ngw", "=", "1000", ",", "seed", "=", "None", ",", "flow", "=", "1e-8", ",", "fhigh", "=", "1e-5", ",", "gwAmp", "=", "1e-20", ",", "alpha", "=", "-", "0.66", ",", "logspacing", "=", "Tr...
Add a stochastic background from inspiraling binaries, using the tempo2 code that underlies the GWbkgrd plugin. Here 'dist' is the pulsar distance [in kpc]; 'ngw' is the number of binaries, 'seed' (a negative integer) reseeds the GWbkgrd pseudorandom-number-generator, 'flow' and 'fhigh' [Hz] determine ...
[ "Add", "a", "stochastic", "background", "from", "inspiraling", "binaries", "using", "the", "tempo2", "code", "that", "underlies", "the", "GWbkgrd", "plugin", "." ]
train
https://github.com/vallis/libstempo/blob/0b19300a9b24d64c9ddc25cd6ddbfd12b6231990/libstempo/toasim.py#L32-L56
vallis/libstempo
libstempo/toasim.py
add_dipole_gwb
def add_dipole_gwb(psr, dist=1, ngw=1000, seed=None, flow=1e-8, fhigh=1e-5, gwAmp=1e-20, alpha=-0.66, logspacing=True, dipoleamps=None, dipoledir=None, dipolemag=None): """Add a stochastic background from inspiraling binaries distributed accord...
python
def add_dipole_gwb(psr, dist=1, ngw=1000, seed=None, flow=1e-8, fhigh=1e-5, gwAmp=1e-20, alpha=-0.66, logspacing=True, dipoleamps=None, dipoledir=None, dipolemag=None): """Add a stochastic background from inspiraling binaries distributed accord...
[ "def", "add_dipole_gwb", "(", "psr", ",", "dist", "=", "1", ",", "ngw", "=", "1000", ",", "seed", "=", "None", ",", "flow", "=", "1e-8", ",", "fhigh", "=", "1e-5", ",", "gwAmp", "=", "1e-20", ",", "alpha", "=", "-", "0.66", ",", "logspacing", "="...
Add a stochastic background from inspiraling binaries distributed according to a pure dipole distribution, using the tempo2 code that underlies the GWdipolebkgrd plugin. The basic use is identical to that of 'add_gwb': Here 'dist' is the pulsar distance [in kpc]; 'ngw' is the number of binaries, 's...
[ "Add", "a", "stochastic", "background", "from", "inspiraling", "binaries", "distributed", "according", "to", "a", "pure", "dipole", "distribution", "using", "the", "tempo2", "code", "that", "underlies", "the", "GWdipolebkgrd", "plugin", "." ]
train
https://github.com/vallis/libstempo/blob/0b19300a9b24d64c9ddc25cd6ddbfd12b6231990/libstempo/toasim.py#L58-L95
vallis/libstempo
libstempo/toasim.py
fakepulsar
def fakepulsar(parfile, obstimes, toaerr, freq=1440.0, observatory='AXIS', flags='', iters=3): """Returns a libstempo tempopulsar object corresponding to a noiseless set of observations for the pulsar specified in 'parfile', with observations happening at times (MJD) given in the array (or li...
python
def fakepulsar(parfile, obstimes, toaerr, freq=1440.0, observatory='AXIS', flags='', iters=3): """Returns a libstempo tempopulsar object corresponding to a noiseless set of observations for the pulsar specified in 'parfile', with observations happening at times (MJD) given in the array (or li...
[ "def", "fakepulsar", "(", "parfile", ",", "obstimes", ",", "toaerr", ",", "freq", "=", "1440.0", ",", "observatory", "=", "'AXIS'", ",", "flags", "=", "''", ",", "iters", "=", "3", ")", ":", "import", "tempfile", "outfile", "=", "tempfile", ".", "Named...
Returns a libstempo tempopulsar object corresponding to a noiseless set of observations for the pulsar specified in 'parfile', with observations happening at times (MJD) given in the array (or list) 'obstimes', with measurement errors given by toaerr (us). A new timfile can then be saved with pulsar.sa...
[ "Returns", "a", "libstempo", "tempopulsar", "object", "corresponding", "to", "a", "noiseless", "set", "of", "observations", "for", "the", "pulsar", "specified", "in", "parfile", "with", "observations", "happening", "at", "times", "(", "MJD", ")", "given", "in", ...
train
https://github.com/vallis/libstempo/blob/0b19300a9b24d64c9ddc25cd6ddbfd12b6231990/libstempo/toasim.py#L100-L145
vallis/libstempo
libstempo/toasim.py
add_efac
def add_efac(psr, efac=1.0, flagid=None, flags=None, seed=None): """Add nominal TOA errors, multiplied by `efac` factor. Optionally take a pseudorandom-number-generator seed.""" if seed is not None: N.random.seed(seed) # default efacvec efacvec = N.ones(psr.nobs) # check that efac...
python
def add_efac(psr, efac=1.0, flagid=None, flags=None, seed=None): """Add nominal TOA errors, multiplied by `efac` factor. Optionally take a pseudorandom-number-generator seed.""" if seed is not None: N.random.seed(seed) # default efacvec efacvec = N.ones(psr.nobs) # check that efac...
[ "def", "add_efac", "(", "psr", ",", "efac", "=", "1.0", ",", "flagid", "=", "None", ",", "flags", "=", "None", ",", "seed", "=", "None", ")", ":", "if", "seed", "is", "not", "None", ":", "N", ".", "random", ".", "seed", "(", "seed", ")", "# def...
Add nominal TOA errors, multiplied by `efac` factor. Optionally take a pseudorandom-number-generator seed.
[ "Add", "nominal", "TOA", "errors", "multiplied", "by", "efac", "factor", ".", "Optionally", "take", "a", "pseudorandom", "-", "number", "-", "generator", "seed", "." ]
train
https://github.com/vallis/libstempo/blob/0b19300a9b24d64c9ddc25cd6ddbfd12b6231990/libstempo/toasim.py#L153-L176
vallis/libstempo
libstempo/toasim.py
add_equad
def add_equad(psr, equad, flagid=None, flags=None, seed=None): """Add quadrature noise of rms `equad` [s]. Optionally take a pseudorandom-number-generator seed.""" if seed is not None: N.random.seed(seed) # default equadvec equadvec = N.zeros(psr.nobs) # check that equad is scalar...
python
def add_equad(psr, equad, flagid=None, flags=None, seed=None): """Add quadrature noise of rms `equad` [s]. Optionally take a pseudorandom-number-generator seed.""" if seed is not None: N.random.seed(seed) # default equadvec equadvec = N.zeros(psr.nobs) # check that equad is scalar...
[ "def", "add_equad", "(", "psr", ",", "equad", ",", "flagid", "=", "None", ",", "flags", "=", "None", ",", "seed", "=", "None", ")", ":", "if", "seed", "is", "not", "None", ":", "N", ".", "random", ".", "seed", "(", "seed", ")", "# default equadvec"...
Add quadrature noise of rms `equad` [s]. Optionally take a pseudorandom-number-generator seed.
[ "Add", "quadrature", "noise", "of", "rms", "equad", "[", "s", "]", ".", "Optionally", "take", "a", "pseudorandom", "-", "number", "-", "generator", "seed", "." ]
train
https://github.com/vallis/libstempo/blob/0b19300a9b24d64c9ddc25cd6ddbfd12b6231990/libstempo/toasim.py#L178-L201
vallis/libstempo
libstempo/toasim.py
add_jitter
def add_jitter(psr, ecorr ,flagid=None, flags=None, coarsegrain=0.1, seed=None): """Add correlated quadrature noise of rms `ecorr` [s], with coarse-graining time `coarsegrain` [days]. Optionally take a pseudorandom-number-generator seed.""" if seed is not None: N.random.seed(...
python
def add_jitter(psr, ecorr ,flagid=None, flags=None, coarsegrain=0.1, seed=None): """Add correlated quadrature noise of rms `ecorr` [s], with coarse-graining time `coarsegrain` [days]. Optionally take a pseudorandom-number-generator seed.""" if seed is not None: N.random.seed(...
[ "def", "add_jitter", "(", "psr", ",", "ecorr", ",", "flagid", "=", "None", ",", "flags", "=", "None", ",", "coarsegrain", "=", "0.1", ",", "seed", "=", "None", ")", ":", "if", "seed", "is", "not", "None", ":", "N", ".", "random", ".", "seed", "("...
Add correlated quadrature noise of rms `ecorr` [s], with coarse-graining time `coarsegrain` [days]. Optionally take a pseudorandom-number-generator seed.
[ "Add", "correlated", "quadrature", "noise", "of", "rms", "ecorr", "[", "s", "]", "with", "coarse", "-", "graining", "time", "coarsegrain", "[", "days", "]", ".", "Optionally", "take", "a", "pseudorandom", "-", "number", "-", "generator", "seed", "." ]
train
https://github.com/vallis/libstempo/blob/0b19300a9b24d64c9ddc25cd6ddbfd12b6231990/libstempo/toasim.py#L255-L287
vallis/libstempo
libstempo/toasim.py
add_rednoise
def add_rednoise(psr,A,gamma,components=10,seed=None): """Add red noise with P(f) = A^2 / (12 pi^2) (f year)^-gamma, using `components` Fourier bases. Optionally take a pseudorandom-number-generator seed.""" if seed is not None: N.random.seed(seed) t = psr.toas() minx, maxx = N.min...
python
def add_rednoise(psr,A,gamma,components=10,seed=None): """Add red noise with P(f) = A^2 / (12 pi^2) (f year)^-gamma, using `components` Fourier bases. Optionally take a pseudorandom-number-generator seed.""" if seed is not None: N.random.seed(seed) t = psr.toas() minx, maxx = N.min...
[ "def", "add_rednoise", "(", "psr", ",", "A", ",", "gamma", ",", "components", "=", "10", ",", "seed", "=", "None", ")", ":", "if", "seed", "is", "not", "None", ":", "N", ".", "random", ".", "seed", "(", "seed", ")", "t", "=", "psr", ".", "toas"...
Add red noise with P(f) = A^2 / (12 pi^2) (f year)^-gamma, using `components` Fourier bases. Optionally take a pseudorandom-number-generator seed.
[ "Add", "red", "noise", "with", "P", "(", "f", ")", "=", "A^2", "/", "(", "12", "pi^2", ")", "(", "f", "year", ")", "^", "-", "gamma", "using", "components", "Fourier", "bases", ".", "Optionally", "take", "a", "pseudorandom", "-", "number", "-", "ge...
train
https://github.com/vallis/libstempo/blob/0b19300a9b24d64c9ddc25cd6ddbfd12b6231990/libstempo/toasim.py#L290-L317
vallis/libstempo
libstempo/toasim.py
add_line
def add_line(psr,f,A,offset=0.5): """ Add a line of frequency `f` [Hz] and amplitude `A` [s], with origin at a fraction `offset` through the dataset. """ t = psr.toas() t0 = offset * (N.max(t) - N.min(t)) sine = A * N.cos(2 * math.pi * f * day * (t - t0)) psr.stoas[:] += sine / day
python
def add_line(psr,f,A,offset=0.5): """ Add a line of frequency `f` [Hz] and amplitude `A` [s], with origin at a fraction `offset` through the dataset. """ t = psr.toas() t0 = offset * (N.max(t) - N.min(t)) sine = A * N.cos(2 * math.pi * f * day * (t - t0)) psr.stoas[:] += sine / day
[ "def", "add_line", "(", "psr", ",", "f", ",", "A", ",", "offset", "=", "0.5", ")", ":", "t", "=", "psr", ".", "toas", "(", ")", "t0", "=", "offset", "*", "(", "N", ".", "max", "(", "t", ")", "-", "N", ".", "min", "(", "t", ")", ")", "si...
Add a line of frequency `f` [Hz] and amplitude `A` [s], with origin at a fraction `offset` through the dataset.
[ "Add", "a", "line", "of", "frequency", "f", "[", "Hz", "]", "and", "amplitude", "A", "[", "s", "]", "with", "origin", "at", "a", "fraction", "offset", "through", "the", "dataset", "." ]
train
https://github.com/vallis/libstempo/blob/0b19300a9b24d64c9ddc25cd6ddbfd12b6231990/libstempo/toasim.py#L350-L360
vallis/libstempo
libstempo/toasim.py
add_glitch
def add_glitch(psr, epoch, amp): """ Like pulsar term BWM event, but now differently parameterized: just an amplitude (not log-amp) parameter, and an epoch. [source: piccard] :param psr: pulsar object :param epoch: TOA time (MJD) the burst hits the earth :param amp: amplitude of the glitch ...
python
def add_glitch(psr, epoch, amp): """ Like pulsar term BWM event, but now differently parameterized: just an amplitude (not log-amp) parameter, and an epoch. [source: piccard] :param psr: pulsar object :param epoch: TOA time (MJD) the burst hits the earth :param amp: amplitude of the glitch ...
[ "def", "add_glitch", "(", "psr", ",", "epoch", ",", "amp", ")", ":", "# Define the heaviside function", "heaviside", "=", "lambda", "x", ":", "0.5", "*", "(", "N", ".", "sign", "(", "x", ")", "+", "1", ")", "# Glitches are spontaneous spin-up events.", "# Th...
Like pulsar term BWM event, but now differently parameterized: just an amplitude (not log-amp) parameter, and an epoch. [source: piccard] :param psr: pulsar object :param epoch: TOA time (MJD) the burst hits the earth :param amp: amplitude of the glitch
[ "Like", "pulsar", "term", "BWM", "event", "but", "now", "differently", "parameterized", ":", "just", "an", "amplitude", "(", "not", "log", "-", "amp", ")", "parameter", "and", "an", "epoch", ".", "[", "source", ":", "piccard", "]", ":", "param", "psr", ...
train
https://github.com/vallis/libstempo/blob/0b19300a9b24d64c9ddc25cd6ddbfd12b6231990/libstempo/toasim.py#L362-L379
vallis/libstempo
libstempo/toasim.py
add_cgw
def add_cgw(psr, gwtheta, gwphi, mc, dist, fgw, phase0, psi, inc, pdist=1.0, \ pphase=None, psrTerm=True, evolve=True, \ phase_approx=False, tref=0): """ Function to create GW-induced residuals from a SMBMB as defined in Ellis et. al 2012,2013. Tries to be sm...
python
def add_cgw(psr, gwtheta, gwphi, mc, dist, fgw, phase0, psi, inc, pdist=1.0, \ pphase=None, psrTerm=True, evolve=True, \ phase_approx=False, tref=0): """ Function to create GW-induced residuals from a SMBMB as defined in Ellis et. al 2012,2013. Tries to be sm...
[ "def", "add_cgw", "(", "psr", ",", "gwtheta", ",", "gwphi", ",", "mc", ",", "dist", ",", "fgw", ",", "phase0", ",", "psi", ",", "inc", ",", "pdist", "=", "1.0", ",", "pphase", "=", "None", ",", "psrTerm", "=", "True", ",", "evolve", "=", "True", ...
Function to create GW-induced residuals from a SMBMB as defined in Ellis et. al 2012,2013. Tries to be smart about it... :param psr: pulsar object :param gwtheta: Polar angle of GW source in celestial coords [radians] :param gwphi: Azimuthal angle of GW source in celestial coords [radians] :param ...
[ "Function", "to", "create", "GW", "-", "induced", "residuals", "from", "a", "SMBMB", "as", "defined", "in", "Ellis", "et", ".", "al", "2012", "2013", ".", "Tries", "to", "be", "smart", "about", "it", "..." ]
train
https://github.com/vallis/libstempo/blob/0b19300a9b24d64c9ddc25cd6ddbfd12b6231990/libstempo/toasim.py#L381-L521
vallis/libstempo
libstempo/toasim.py
add_ecc_cgw
def add_ecc_cgw(psr, gwtheta, gwphi, mc, dist, F, inc, psi, gamma0, e0, l0, q, nmax=100, nset=None, pd=None, periEv=True, psrTerm=True, tref=0, check=True, useFile=True): """ Simulate GW from eccentric SMBHB. Waveform models from Taylor et al. (2015) and Barack and Cutler (20...
python
def add_ecc_cgw(psr, gwtheta, gwphi, mc, dist, F, inc, psi, gamma0, e0, l0, q, nmax=100, nset=None, pd=None, periEv=True, psrTerm=True, tref=0, check=True, useFile=True): """ Simulate GW from eccentric SMBHB. Waveform models from Taylor et al. (2015) and Barack and Cutler (20...
[ "def", "add_ecc_cgw", "(", "psr", ",", "gwtheta", ",", "gwphi", ",", "mc", ",", "dist", ",", "F", ",", "inc", ",", "psi", ",", "gamma0", ",", "e0", ",", "l0", ",", "q", ",", "nmax", "=", "100", ",", "nset", "=", "None", ",", "pd", "=", "None"...
Simulate GW from eccentric SMBHB. Waveform models from Taylor et al. (2015) and Barack and Cutler (2004). WARNING: This residual waveform is only accurate if the GW frequency is not significantly evolving over the observation time of the pulsar. :param psr: pulsar object :param gwtheta: Polar...
[ "Simulate", "GW", "from", "eccentric", "SMBHB", ".", "Waveform", "models", "from", "Taylor", "et", "al", ".", "(", "2015", ")", "and", "Barack", "and", "Cutler", "(", "2004", ")", "." ]
train
https://github.com/vallis/libstempo/blob/0b19300a9b24d64c9ddc25cd6ddbfd12b6231990/libstempo/toasim.py#L523-L674
vallis/libstempo
libstempo/toasim.py
extrap1d
def extrap1d(interpolator): """ Function to extend an interpolation function to an extrapolation function. :param interpolator: scipy interp1d object :returns ufunclike: extension of function to extrapolation """ xs = interpolator.x ys = interpolator.y def pointwise(x): ...
python
def extrap1d(interpolator): """ Function to extend an interpolation function to an extrapolation function. :param interpolator: scipy interp1d object :returns ufunclike: extension of function to extrapolation """ xs = interpolator.x ys = interpolator.y def pointwise(x): ...
[ "def", "extrap1d", "(", "interpolator", ")", ":", "xs", "=", "interpolator", ".", "x", "ys", "=", "interpolator", ".", "y", "def", "pointwise", "(", "x", ")", ":", "if", "x", "<", "xs", "[", "0", "]", ":", "return", "ys", "[", "0", "]", "# +(x-xs...
Function to extend an interpolation function to an extrapolation function. :param interpolator: scipy interp1d object :returns ufunclike: extension of function to extrapolation
[ "Function", "to", "extend", "an", "interpolation", "function", "to", "an", "extrapolation", "function", "." ]
train
https://github.com/vallis/libstempo/blob/0b19300a9b24d64c9ddc25cd6ddbfd12b6231990/libstempo/toasim.py#L677-L701
vallis/libstempo
libstempo/toasim.py
createGWB
def createGWB(psr, Amp, gam, noCorr=False, seed=None, turnover=False, clm=[N.sqrt(4.0*N.pi)], lmax=0, f0=1e-9, beta=1, power=1, userSpec=None, npts=600, howml=10): """ Function to create GW-induced residuals from a stochastic GWB as defined in Chamberlin, Creighton, Demorest, et ...
python
def createGWB(psr, Amp, gam, noCorr=False, seed=None, turnover=False, clm=[N.sqrt(4.0*N.pi)], lmax=0, f0=1e-9, beta=1, power=1, userSpec=None, npts=600, howml=10): """ Function to create GW-induced residuals from a stochastic GWB as defined in Chamberlin, Creighton, Demorest, et ...
[ "def", "createGWB", "(", "psr", ",", "Amp", ",", "gam", ",", "noCorr", "=", "False", ",", "seed", "=", "None", ",", "turnover", "=", "False", ",", "clm", "=", "[", "N", ".", "sqrt", "(", "4.0", "*", "N", ".", "pi", ")", "]", ",", "lmax", "=",...
Function to create GW-induced residuals from a stochastic GWB as defined in Chamberlin, Creighton, Demorest, et al. (2014). :param psr: pulsar object for single pulsar :param Amp: Amplitude of red noise in GW units :param gam: Red noise power law spectral index :param noCorr: Add red noise wit...
[ "Function", "to", "create", "GW", "-", "induced", "residuals", "from", "a", "stochastic", "GWB", "as", "defined", "in", "Chamberlin", "Creighton", "Demorest", "et", "al", ".", "(", "2014", ")", ".", ":", "param", "psr", ":", "pulsar", "object", "for", "s...
train
https://github.com/vallis/libstempo/blob/0b19300a9b24d64c9ddc25cd6ddbfd12b6231990/libstempo/toasim.py#L704-L842
vallis/libstempo
libstempo/toasim.py
computeORFMatrix
def computeORFMatrix(psr): """ Compute ORF matrix. :param psr: List of pulsar object instances :returns: Matrix that has the ORF values for every pulsar pair with 2 on the diagonals to account for the pulsar term. """ # begin loop over all pulsar pairs and calculat...
python
def computeORFMatrix(psr): """ Compute ORF matrix. :param psr: List of pulsar object instances :returns: Matrix that has the ORF values for every pulsar pair with 2 on the diagonals to account for the pulsar term. """ # begin loop over all pulsar pairs and calculat...
[ "def", "computeORFMatrix", "(", "psr", ")", ":", "# begin loop over all pulsar pairs and calculate ORF", "npsr", "=", "len", "(", "psr", ")", "ORF", "=", "N", ".", "zeros", "(", "(", "npsr", ",", "npsr", ")", ")", "phati", "=", "N", ".", "zeros", "(", "3...
Compute ORF matrix. :param psr: List of pulsar object instances :returns: Matrix that has the ORF values for every pulsar pair with 2 on the diagonals to account for the pulsar term.
[ "Compute", "ORF", "matrix", "." ]
train
https://github.com/vallis/libstempo/blob/0b19300a9b24d64c9ddc25cd6ddbfd12b6231990/libstempo/toasim.py#L844-L879
vallis/libstempo
libstempo/plot.py
plotres
def plotres(psr,deleted=False,group=None,**kwargs): """Plot residuals, compute unweighted rms residual.""" res, t, errs = psr.residuals(), psr.toas(), psr.toaerrs if (not deleted) and N.any(psr.deleted != 0): res, t, errs = res[psr.deleted == 0], t[psr.deleted == 0], errs[psr.deleted == 0] ...
python
def plotres(psr,deleted=False,group=None,**kwargs): """Plot residuals, compute unweighted rms residual.""" res, t, errs = psr.residuals(), psr.toas(), psr.toaerrs if (not deleted) and N.any(psr.deleted != 0): res, t, errs = res[psr.deleted == 0], t[psr.deleted == 0], errs[psr.deleted == 0] ...
[ "def", "plotres", "(", "psr", ",", "deleted", "=", "False", ",", "group", "=", "None", ",", "*", "*", "kwargs", ")", ":", "res", ",", "t", ",", "errs", "=", "psr", ".", "residuals", "(", ")", ",", "psr", ".", "toas", "(", ")", ",", "psr", "."...
Plot residuals, compute unweighted rms residual.
[ "Plot", "residuals", "compute", "unweighted", "rms", "residual", "." ]
train
https://github.com/vallis/libstempo/blob/0b19300a9b24d64c9ddc25cd6ddbfd12b6231990/libstempo/plot.py#L7-L38
vallis/libstempo
libstempo/plot.py
plotgwsrc
def plotgwsrc(gwb): """ Plot a GWB source population as a mollweide projection. """ theta, phi, omega, polarization = gwb.gw_dist() rho = phi-N.pi eta = 0.5*N.pi - theta # I don't know how to get rid of the RuntimeWarning -- RvH, Oct 10, 2014: # /Users/vhaaster/env/dev/lib/python2....
python
def plotgwsrc(gwb): """ Plot a GWB source population as a mollweide projection. """ theta, phi, omega, polarization = gwb.gw_dist() rho = phi-N.pi eta = 0.5*N.pi - theta # I don't know how to get rid of the RuntimeWarning -- RvH, Oct 10, 2014: # /Users/vhaaster/env/dev/lib/python2....
[ "def", "plotgwsrc", "(", "gwb", ")", ":", "theta", ",", "phi", ",", "omega", ",", "polarization", "=", "gwb", ".", "gw_dist", "(", ")", "rho", "=", "phi", "-", "N", ".", "pi", "eta", "=", "0.5", "*", "N", ".", "pi", "-", "theta", "# I don't know ...
Plot a GWB source population as a mollweide projection.
[ "Plot", "a", "GWB", "source", "population", "as", "a", "mollweide", "projection", "." ]
train
https://github.com/vallis/libstempo/blob/0b19300a9b24d64c9ddc25cd6ddbfd12b6231990/libstempo/plot.py#L304-L324
vallis/libstempo
libstempo/like.py
loglike
def loglike(pulsar,efac=1.0,equad=None,jitter=None,Ared=None,gammared=None,marginalize=True,normalize=True,redcomponents=10,usedeleted=True): """Returns the Gaussian-process likelihood for 'pulsar'. The likelihood is evaluated at the current value of the pulsar parameters, as given by pulsar[parname].val. ...
python
def loglike(pulsar,efac=1.0,equad=None,jitter=None,Ared=None,gammared=None,marginalize=True,normalize=True,redcomponents=10,usedeleted=True): """Returns the Gaussian-process likelihood for 'pulsar'. The likelihood is evaluated at the current value of the pulsar parameters, as given by pulsar[parname].val. ...
[ "def", "loglike", "(", "pulsar", ",", "efac", "=", "1.0", ",", "equad", "=", "None", ",", "jitter", "=", "None", ",", "Ared", "=", "None", ",", "gammared", "=", "None", ",", "marginalize", "=", "True", ",", "normalize", "=", "True", ",", "redcomponen...
Returns the Gaussian-process likelihood for 'pulsar'. The likelihood is evaluated at the current value of the pulsar parameters, as given by pulsar[parname].val. If efac, equad, and/or Ared are set, will compute the likelihood assuming the corresponding noise model. EFAC multiplies measurement noise; ...
[ "Returns", "the", "Gaussian", "-", "process", "likelihood", "for", "pulsar", "." ]
train
https://github.com/vallis/libstempo/blob/0b19300a9b24d64c9ddc25cd6ddbfd12b6231990/libstempo/like.py#L74-L148
vallis/libstempo
libstempo/like.py
expandranges
def expandranges(parlist): """Rewrite a list of parameters by expanding ranges (e.g., log10_efac{1-10}) into individual parameters.""" ret = [] for par in parlist: # match anything of the form XXX{number1-number2} m = re.match('(.*)\{([0-9]+)\-([0-9]+)\}',par) if m is None: ...
python
def expandranges(parlist): """Rewrite a list of parameters by expanding ranges (e.g., log10_efac{1-10}) into individual parameters.""" ret = [] for par in parlist: # match anything of the form XXX{number1-number2} m = re.match('(.*)\{([0-9]+)\-([0-9]+)\}',par) if m is None: ...
[ "def", "expandranges", "(", "parlist", ")", ":", "ret", "=", "[", "]", "for", "par", "in", "parlist", ":", "# match anything of the form XXX{number1-number2}", "m", "=", "re", ".", "match", "(", "'(.*)\\{([0-9]+)\\-([0-9]+)\\}'", ",", "par", ")", "if", "m", "i...
Rewrite a list of parameters by expanding ranges (e.g., log10_efac{1-10}) into individual parameters.
[ "Rewrite", "a", "list", "of", "parameters", "by", "expanding", "ranges", "(", "e", ".", "g", ".", "log10_efac", "{", "1", "-", "10", "}", ")", "into", "individual", "parameters", "." ]
train
https://github.com/vallis/libstempo/blob/0b19300a9b24d64c9ddc25cd6ddbfd12b6231990/libstempo/like.py#L242-L264
vallis/libstempo
libstempo/like.py
_findrange
def _findrange(parlist,roots=['JUMP','DMXR1_','DMXR2_','DMX_','efac','log10_efac']): """Rewrite a list of parameters name by detecting ranges (e.g., JUMP1, JUMP2, ...) and compressing them.""" rootdict = {root: [] for root in roots} res = [] for par in parlist: found = False for ro...
python
def _findrange(parlist,roots=['JUMP','DMXR1_','DMXR2_','DMX_','efac','log10_efac']): """Rewrite a list of parameters name by detecting ranges (e.g., JUMP1, JUMP2, ...) and compressing them.""" rootdict = {root: [] for root in roots} res = [] for par in parlist: found = False for ro...
[ "def", "_findrange", "(", "parlist", ",", "roots", "=", "[", "'JUMP'", ",", "'DMXR1_'", ",", "'DMXR2_'", ",", "'DMX_'", ",", "'efac'", ",", "'log10_efac'", "]", ")", ":", "rootdict", "=", "{", "root", ":", "[", "]", "for", "root", "in", "roots", "}",...
Rewrite a list of parameters name by detecting ranges (e.g., JUMP1, JUMP2, ...) and compressing them.
[ "Rewrite", "a", "list", "of", "parameters", "name", "by", "detecting", "ranges", "(", "e", ".", "g", ".", "JUMP1", "JUMP2", "...", ")", "and", "compressing", "them", "." ]
train
https://github.com/vallis/libstempo/blob/0b19300a9b24d64c9ddc25cd6ddbfd12b6231990/libstempo/like.py#L267-L291
vallis/libstempo
libstempo/emcee.py
merge
def merge(data,skip=50,fraction=1.0): """Merge one every 'skip' clouds into a single emcee population, using the later 'fraction' of the run.""" w,s,d = data.chains.shape start = int((1.0 - fraction) * s) total = int((s - start) / skip) return data.chains[:,start::skip,:].reshape(...
python
def merge(data,skip=50,fraction=1.0): """Merge one every 'skip' clouds into a single emcee population, using the later 'fraction' of the run.""" w,s,d = data.chains.shape start = int((1.0 - fraction) * s) total = int((s - start) / skip) return data.chains[:,start::skip,:].reshape(...
[ "def", "merge", "(", "data", ",", "skip", "=", "50", ",", "fraction", "=", "1.0", ")", ":", "w", ",", "s", ",", "d", "=", "data", ".", "chains", ".", "shape", "start", "=", "int", "(", "(", "1.0", "-", "fraction", ")", "*", "s", ")", "total",...
Merge one every 'skip' clouds into a single emcee population, using the later 'fraction' of the run.
[ "Merge", "one", "every", "skip", "clouds", "into", "a", "single", "emcee", "population", "using", "the", "later", "fraction", "of", "the", "run", "." ]
train
https://github.com/vallis/libstempo/blob/0b19300a9b24d64c9ddc25cd6ddbfd12b6231990/libstempo/emcee.py#L46-L55
vallis/libstempo
libstempo/emcee.py
cull
def cull(data,index,min=None,max=None): """Sieve an emcee clouds by excluding walkers with search variable 'index' smaller than 'min' or larger than 'max'.""" ret = data if min is not None: ret = ret[ret[:,index] > min,:] if max is not None: ret = ret[ret[:,index] < max,:] ...
python
def cull(data,index,min=None,max=None): """Sieve an emcee clouds by excluding walkers with search variable 'index' smaller than 'min' or larger than 'max'.""" ret = data if min is not None: ret = ret[ret[:,index] > min,:] if max is not None: ret = ret[ret[:,index] < max,:] ...
[ "def", "cull", "(", "data", ",", "index", ",", "min", "=", "None", ",", "max", "=", "None", ")", ":", "ret", "=", "data", "if", "min", "is", "not", "None", ":", "ret", "=", "ret", "[", "ret", "[", ":", ",", "index", "]", ">", "min", ",", ":...
Sieve an emcee clouds by excluding walkers with search variable 'index' smaller than 'min' or larger than 'max'.
[ "Sieve", "an", "emcee", "clouds", "by", "excluding", "walkers", "with", "search", "variable", "index", "smaller", "than", "min", "or", "larger", "than", "max", "." ]
train
https://github.com/vallis/libstempo/blob/0b19300a9b24d64c9ddc25cd6ddbfd12b6231990/libstempo/emcee.py#L57-L69
vallis/libstempo
libstempo/eccUtils.py
make_ecc_interpolant
def make_ecc_interpolant(): """ Make interpolation function from eccentricity file to determine number of harmonics to use for a given eccentricity. :returns: interpolant """ pth = resource_filename(Requirement.parse('libstempo'), 'libstempo/ecc_vs_nharm.txt') ...
python
def make_ecc_interpolant(): """ Make interpolation function from eccentricity file to determine number of harmonics to use for a given eccentricity. :returns: interpolant """ pth = resource_filename(Requirement.parse('libstempo'), 'libstempo/ecc_vs_nharm.txt') ...
[ "def", "make_ecc_interpolant", "(", ")", ":", "pth", "=", "resource_filename", "(", "Requirement", ".", "parse", "(", "'libstempo'", ")", ",", "'libstempo/ecc_vs_nharm.txt'", ")", "fil", "=", "np", ".", "loadtxt", "(", "pth", ")", "return", "interp1d", "(", ...
Make interpolation function from eccentricity file to determine number of harmonics to use for a given eccentricity. :returns: interpolant
[ "Make", "interpolation", "function", "from", "eccentricity", "file", "to", "determine", "number", "of", "harmonics", "to", "use", "for", "a", "given", "eccentricity", "." ]
train
https://github.com/vallis/libstempo/blob/0b19300a9b24d64c9ddc25cd6ddbfd12b6231990/libstempo/eccUtils.py#L28-L41
vallis/libstempo
libstempo/eccUtils.py
get_edot
def get_edot(F, mc, e): """ Compute eccentricity derivative from Taylor et al. (2015) :param F: Orbital frequency [Hz] :param mc: Chirp mass of binary [Solar Mass] :param e: Eccentricity of binary :returns: de/dt """ # chirp mass mc *= SOLAR2S dedt = -304/(15*mc) * (2*np.pi*...
python
def get_edot(F, mc, e): """ Compute eccentricity derivative from Taylor et al. (2015) :param F: Orbital frequency [Hz] :param mc: Chirp mass of binary [Solar Mass] :param e: Eccentricity of binary :returns: de/dt """ # chirp mass mc *= SOLAR2S dedt = -304/(15*mc) * (2*np.pi*...
[ "def", "get_edot", "(", "F", ",", "mc", ",", "e", ")", ":", "# chirp mass", "mc", "*=", "SOLAR2S", "dedt", "=", "-", "304", "/", "(", "15", "*", "mc", ")", "*", "(", "2", "*", "np", ".", "pi", "*", "mc", "*", "F", ")", "**", "(", "8", "/"...
Compute eccentricity derivative from Taylor et al. (2015) :param F: Orbital frequency [Hz] :param mc: Chirp mass of binary [Solar Mass] :param e: Eccentricity of binary :returns: de/dt
[ "Compute", "eccentricity", "derivative", "from", "Taylor", "et", "al", ".", "(", "2015", ")" ]
train
https://github.com/vallis/libstempo/blob/0b19300a9b24d64c9ddc25cd6ddbfd12b6231990/libstempo/eccUtils.py#L45-L63
vallis/libstempo
libstempo/eccUtils.py
get_Fdot
def get_Fdot(F, mc, e): """ Compute frequency derivative from Taylor et al. (2015) :param F: Orbital frequency [Hz] :param mc: Chirp mass of binary [Solar Mass] :param e: Eccentricity of binary :returns: dF/dt """ # chirp mass mc *= SOLAR2S dFdt = 48 / (5*np.pi*mc**2) * (2*n...
python
def get_Fdot(F, mc, e): """ Compute frequency derivative from Taylor et al. (2015) :param F: Orbital frequency [Hz] :param mc: Chirp mass of binary [Solar Mass] :param e: Eccentricity of binary :returns: dF/dt """ # chirp mass mc *= SOLAR2S dFdt = 48 / (5*np.pi*mc**2) * (2*n...
[ "def", "get_Fdot", "(", "F", ",", "mc", ",", "e", ")", ":", "# chirp mass", "mc", "*=", "SOLAR2S", "dFdt", "=", "48", "/", "(", "5", "*", "np", ".", "pi", "*", "mc", "**", "2", ")", "*", "(", "2", "*", "np", ".", "pi", "*", "mc", "*", "F"...
Compute frequency derivative from Taylor et al. (2015) :param F: Orbital frequency [Hz] :param mc: Chirp mass of binary [Solar Mass] :param e: Eccentricity of binary :returns: dF/dt
[ "Compute", "frequency", "derivative", "from", "Taylor", "et", "al", ".", "(", "2015", ")" ]
train
https://github.com/vallis/libstempo/blob/0b19300a9b24d64c9ddc25cd6ddbfd12b6231990/libstempo/eccUtils.py#L65-L83
vallis/libstempo
libstempo/eccUtils.py
get_gammadot
def get_gammadot(F, mc, q, e): """ Compute gamma dot from Barack and Cutler (2004) :param F: Orbital frequency [Hz] :param mc: Chirp mass of binary [Solar Mass] :param q: Mass ratio of binary :param e: Eccentricity of binary :returns: dgamma/dt """ # chirp mass mc *= SOLAR2S ...
python
def get_gammadot(F, mc, q, e): """ Compute gamma dot from Barack and Cutler (2004) :param F: Orbital frequency [Hz] :param mc: Chirp mass of binary [Solar Mass] :param q: Mass ratio of binary :param e: Eccentricity of binary :returns: dgamma/dt """ # chirp mass mc *= SOLAR2S ...
[ "def", "get_gammadot", "(", "F", ",", "mc", ",", "q", ",", "e", ")", ":", "# chirp mass", "mc", "*=", "SOLAR2S", "#total mass", "m", "=", "(", "(", "(", "1", "+", "q", ")", "**", "2", ")", "/", "q", ")", "**", "(", "3", "/", "5", ")", "*", ...
Compute gamma dot from Barack and Cutler (2004) :param F: Orbital frequency [Hz] :param mc: Chirp mass of binary [Solar Mass] :param q: Mass ratio of binary :param e: Eccentricity of binary :returns: dgamma/dt
[ "Compute", "gamma", "dot", "from", "Barack", "and", "Cutler", "(", "2004", ")" ]
train
https://github.com/vallis/libstempo/blob/0b19300a9b24d64c9ddc25cd6ddbfd12b6231990/libstempo/eccUtils.py#L85-L107
vallis/libstempo
libstempo/eccUtils.py
get_coupled_ecc_eqns
def get_coupled_ecc_eqns(y, t, mc, q): """ Computes the coupled system of differential equations from Peters (1964) and Barack & Cutler (2004). This is a system of three variables: F: Orbital frequency [Hz] e: Orbital eccentricity gamma: Angle of precession of periastron [rad] phase...
python
def get_coupled_ecc_eqns(y, t, mc, q): """ Computes the coupled system of differential equations from Peters (1964) and Barack & Cutler (2004). This is a system of three variables: F: Orbital frequency [Hz] e: Orbital eccentricity gamma: Angle of precession of periastron [rad] phase...
[ "def", "get_coupled_ecc_eqns", "(", "y", ",", "t", ",", "mc", ",", "q", ")", ":", "F", "=", "y", "[", "0", "]", "e", "=", "y", "[", "1", "]", "gamma", "=", "y", "[", "2", "]", "phase", "=", "y", "[", "3", "]", "#total mass", "m", "=", "("...
Computes the coupled system of differential equations from Peters (1964) and Barack & Cutler (2004). This is a system of three variables: F: Orbital frequency [Hz] e: Orbital eccentricity gamma: Angle of precession of periastron [rad] phase0: Orbital phase [rad] :param y: Vector of...
[ "Computes", "the", "coupled", "system", "of", "differential", "equations", "from", "Peters", "(", "1964", ")", "and", "Barack", "&", "Cutler", "(", "2004", ")", ".", "This", "is", "a", "system", "of", "three", "variables", ":", "F", ":", "Orbital", "freq...
train
https://github.com/vallis/libstempo/blob/0b19300a9b24d64c9ddc25cd6ddbfd12b6231990/libstempo/eccUtils.py#L109-L141
vallis/libstempo
libstempo/eccUtils.py
solve_coupled_ecc_solution
def solve_coupled_ecc_solution(F0, e0, gamma0, phase0, mc, q, t): """ Compute the solution to the coupled system of equations from from Peters (1964) and Barack & Cutler (2004) at a given time. :param F0: Initial orbital frequency [Hz] :param e0: Initial orbital eccentricity :param gam...
python
def solve_coupled_ecc_solution(F0, e0, gamma0, phase0, mc, q, t): """ Compute the solution to the coupled system of equations from from Peters (1964) and Barack & Cutler (2004) at a given time. :param F0: Initial orbital frequency [Hz] :param e0: Initial orbital eccentricity :param gam...
[ "def", "solve_coupled_ecc_solution", "(", "F0", ",", "e0", ",", "gamma0", ",", "phase0", ",", "mc", ",", "q", ",", "t", ")", ":", "y0", "=", "np", ".", "array", "(", "[", "F0", ",", "e0", ",", "gamma0", ",", "phase0", "]", ")", "y", ",", "infod...
Compute the solution to the coupled system of equations from from Peters (1964) and Barack & Cutler (2004) at a given time. :param F0: Initial orbital frequency [Hz] :param e0: Initial orbital eccentricity :param gamma0: Initial angle of precession of periastron [rad] :param mc: Chirp mass...
[ "Compute", "the", "solution", "to", "the", "coupled", "system", "of", "equations", "from", "from", "Peters", "(", "1964", ")", "and", "Barack", "&", "Cutler", "(", "2004", ")", "at", "a", "given", "time", ".", ":", "param", "F0", ":", "Initial", "orbit...
train
https://github.com/vallis/libstempo/blob/0b19300a9b24d64c9ddc25cd6ddbfd12b6231990/libstempo/eccUtils.py#L143-L169
vallis/libstempo
libstempo/eccUtils.py
get_an
def get_an(n, mc, dl, F, e): """ Compute a_n from Eq. 22 of Taylor et al. (2015). :param n: Harmonic number :param mc: Chirp mass of binary [Solar Mass] :param dl: Luminosity distance [Mpc] :param F: Orbital frequency of binary [Hz] :param e: Orbital Eccentricity :returns: a_n ...
python
def get_an(n, mc, dl, F, e): """ Compute a_n from Eq. 22 of Taylor et al. (2015). :param n: Harmonic number :param mc: Chirp mass of binary [Solar Mass] :param dl: Luminosity distance [Mpc] :param F: Orbital frequency of binary [Hz] :param e: Orbital Eccentricity :returns: a_n ...
[ "def", "get_an", "(", "n", ",", "mc", ",", "dl", ",", "F", ",", "e", ")", ":", "# convert to seconds", "mc", "*=", "SOLAR2S", "dl", "*=", "MPC2S", "omega", "=", "2", "*", "np", ".", "pi", "*", "F", "amp", "=", "n", "*", "mc", "**", "(", "5", ...
Compute a_n from Eq. 22 of Taylor et al. (2015). :param n: Harmonic number :param mc: Chirp mass of binary [Solar Mass] :param dl: Luminosity distance [Mpc] :param F: Orbital frequency of binary [Hz] :param e: Orbital Eccentricity :returns: a_n
[ "Compute", "a_n", "from", "Eq", ".", "22", "of", "Taylor", "et", "al", ".", "(", "2015", ")", ".", ":", "param", "n", ":", "Harmonic", "number", ":", "param", "mc", ":", "Chirp", "mass", "of", "binary", "[", "Solar", "Mass", "]", ":", "param", "d...
train
https://github.com/vallis/libstempo/blob/0b19300a9b24d64c9ddc25cd6ddbfd12b6231990/libstempo/eccUtils.py#L171-L197
vallis/libstempo
libstempo/eccUtils.py
get_bn
def get_bn(n, mc, dl, F, e): """ Compute b_n from Eq. 22 of Taylor et al. (2015). :param n: Harmonic number :param mc: Chirp mass of binary [Solar Mass] :param dl: Luminosity distance [Mpc] :param F: Orbital frequency of binary [Hz] :param e: Orbital Eccentricity :returns: b_n ...
python
def get_bn(n, mc, dl, F, e): """ Compute b_n from Eq. 22 of Taylor et al. (2015). :param n: Harmonic number :param mc: Chirp mass of binary [Solar Mass] :param dl: Luminosity distance [Mpc] :param F: Orbital frequency of binary [Hz] :param e: Orbital Eccentricity :returns: b_n ...
[ "def", "get_bn", "(", "n", ",", "mc", ",", "dl", ",", "F", ",", "e", ")", ":", "# convert to seconds", "mc", "*=", "SOLAR2S", "dl", "*=", "MPC2S", "omega", "=", "2", "*", "np", ".", "pi", "*", "F", "amp", "=", "n", "*", "mc", "**", "(", "5", ...
Compute b_n from Eq. 22 of Taylor et al. (2015). :param n: Harmonic number :param mc: Chirp mass of binary [Solar Mass] :param dl: Luminosity distance [Mpc] :param F: Orbital frequency of binary [Hz] :param e: Orbital Eccentricity :returns: b_n
[ "Compute", "b_n", "from", "Eq", ".", "22", "of", "Taylor", "et", "al", ".", "(", "2015", ")", ".", ":", "param", "n", ":", "Harmonic", "number", ":", "param", "mc", ":", "Chirp", "mass", "of", "binary", "[", "Solar", "Mass", "]", ":", "param", "d...
train
https://github.com/vallis/libstempo/blob/0b19300a9b24d64c9ddc25cd6ddbfd12b6231990/libstempo/eccUtils.py#L199-L224
vallis/libstempo
libstempo/eccUtils.py
get_cn
def get_cn(n, mc, dl, F, e): """ Compute c_n from Eq. 22 of Taylor et al. (2015). :param n: Harmonic number :param mc: Chirp mass of binary [Solar Mass] :param dl: Luminosity distance [Mpc] :param F: Orbital frequency of binary [Hz] :param e: Orbital Eccentricity :returns: c_n ...
python
def get_cn(n, mc, dl, F, e): """ Compute c_n from Eq. 22 of Taylor et al. (2015). :param n: Harmonic number :param mc: Chirp mass of binary [Solar Mass] :param dl: Luminosity distance [Mpc] :param F: Orbital frequency of binary [Hz] :param e: Orbital Eccentricity :returns: c_n ...
[ "def", "get_cn", "(", "n", ",", "mc", ",", "dl", ",", "F", ",", "e", ")", ":", "# convert to seconds", "mc", "*=", "SOLAR2S", "dl", "*=", "MPC2S", "omega", "=", "2", "*", "np", ".", "pi", "*", "F", "amp", "=", "2", "*", "mc", "**", "(", "5", ...
Compute c_n from Eq. 22 of Taylor et al. (2015). :param n: Harmonic number :param mc: Chirp mass of binary [Solar Mass] :param dl: Luminosity distance [Mpc] :param F: Orbital frequency of binary [Hz] :param e: Orbital Eccentricity :returns: c_n
[ "Compute", "c_n", "from", "Eq", ".", "22", "of", "Taylor", "et", "al", ".", "(", "2015", ")", ".", ":", "param", "n", ":", "Harmonic", "number", ":", "param", "mc", ":", "Chirp", "mass", "of", "binary", "[", "Solar", "Mass", "]", ":", "param", "d...
train
https://github.com/vallis/libstempo/blob/0b19300a9b24d64c9ddc25cd6ddbfd12b6231990/libstempo/eccUtils.py#L226-L250
vallis/libstempo
libstempo/eccUtils.py
calculate_splus_scross
def calculate_splus_scross(nmax, mc, dl, F, e, t, l0, gamma, gammadot, inc): """ Calculate splus and scross summed over all harmonics. This waveform differs slightly from that in Taylor et al (2015) in that it includes the time dependence of the advance of periastron. :param nmax: Total numbe...
python
def calculate_splus_scross(nmax, mc, dl, F, e, t, l0, gamma, gammadot, inc): """ Calculate splus and scross summed over all harmonics. This waveform differs slightly from that in Taylor et al (2015) in that it includes the time dependence of the advance of periastron. :param nmax: Total numbe...
[ "def", "calculate_splus_scross", "(", "nmax", ",", "mc", ",", "dl", ",", "F", ",", "e", ",", "t", ",", "l0", ",", "gamma", ",", "gammadot", ",", "inc", ")", ":", "n", "=", "np", ".", "arange", "(", "1", ",", "nmax", ")", "# time dependent amplitude...
Calculate splus and scross summed over all harmonics. This waveform differs slightly from that in Taylor et al (2015) in that it includes the time dependence of the advance of periastron. :param nmax: Total number of harmonics to use :param mc: Chirp mass of binary [Solar Mass] :param dl: Lum...
[ "Calculate", "splus", "and", "scross", "summed", "over", "all", "harmonics", ".", "This", "waveform", "differs", "slightly", "from", "that", "in", "Taylor", "et", "al", "(", "2015", ")", "in", "that", "it", "includes", "the", "time", "dependence", "of", "t...
train
https://github.com/vallis/libstempo/blob/0b19300a9b24d64c9ddc25cd6ddbfd12b6231990/libstempo/eccUtils.py#L252-L305
vallis/libstempo
libstempo/multinest.py
run
def run(LogLikelihood, Prior, n_dims, n_params = None, n_clustering_params = None, wrapped_params = None, importance_nested_sampling = True, multimodal = True, const_efficiency_mode = False, n_live_points = 400, evidence_tolerance = 0.5, sampling_efficiency = 0.8, n_iter_before_update = ...
python
def run(LogLikelihood, Prior, n_dims, n_params = None, n_clustering_params = None, wrapped_params = None, importance_nested_sampling = True, multimodal = True, const_efficiency_mode = False, n_live_points = 400, evidence_tolerance = 0.5, sampling_efficiency = 0.8, n_iter_before_update = ...
[ "def", "run", "(", "LogLikelihood", ",", "Prior", ",", "n_dims", ",", "n_params", "=", "None", ",", "n_clustering_params", "=", "None", ",", "wrapped_params", "=", "None", ",", "importance_nested_sampling", "=", "True", ",", "multimodal", "=", "True", ",", "...
Runs MultiNest The most important parameters are the two log-probability functions Prior and LogLikelihood. They are called by MultiNest. Prior should transform the unit cube into the parameter cube. Here is an example for a uniform prior:: def Prior(cube, ndim, nparams): for i in...
[ "Runs", "MultiNest" ]
train
https://github.com/vallis/libstempo/blob/0b19300a9b24d64c9ddc25cd6ddbfd12b6231990/libstempo/multinest.py#L22-L208
gagneurlab/concise
concise/legacy/kmer.py
best_kmers
def best_kmers(dt, response, sequence, k=6, consider_shift=True, n_cores=1, seq_align="start", trim_seq_len=None): """ Find best k-mers for CONCISE initialization. Args: dt (pd.DataFrame): Table containing response variable and sequence. response (str): Name of the column use...
python
def best_kmers(dt, response, sequence, k=6, consider_shift=True, n_cores=1, seq_align="start", trim_seq_len=None): """ Find best k-mers for CONCISE initialization. Args: dt (pd.DataFrame): Table containing response variable and sequence. response (str): Name of the column use...
[ "def", "best_kmers", "(", "dt", ",", "response", ",", "sequence", ",", "k", "=", "6", ",", "consider_shift", "=", "True", ",", "n_cores", "=", "1", ",", "seq_align", "=", "\"start\"", ",", "trim_seq_len", "=", "None", ")", ":", "y", "=", "dt", "[", ...
Find best k-mers for CONCISE initialization. Args: dt (pd.DataFrame): Table containing response variable and sequence. response (str): Name of the column used as the reponse variable. sequence (str): Name of the column storing the DNA/RNA sequences. k (int): Desired k-mer length. ...
[ "Find", "best", "k", "-", "mers", "for", "CONCISE", "initialization", "." ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/legacy/kmer.py#L28-L102
gagneurlab/concise
concise/legacy/kmer.py
kmer_count
def kmer_count(seq_list, k): """ Generate k-mer counts from a set of sequences Args: seq_list (iterable): List of DNA sequences (with letters from {A, C, G, T}) k (int): K in k-mer. Returns: pandas.DataFrame: Count matrix for seach sequence in seq_list Example: >>> kmer...
python
def kmer_count(seq_list, k): """ Generate k-mer counts from a set of sequences Args: seq_list (iterable): List of DNA sequences (with letters from {A, C, G, T}) k (int): K in k-mer. Returns: pandas.DataFrame: Count matrix for seach sequence in seq_list Example: >>> kmer...
[ "def", "kmer_count", "(", "seq_list", ",", "k", ")", ":", "# generate all k-mers", "all_kmers", "=", "generate_all_kmers", "(", "k", ")", "kmer_count_list", "=", "[", "]", "for", "seq", "in", "seq_list", ":", "kmer_count_list", ".", "append", "(", "[", "seq"...
Generate k-mer counts from a set of sequences Args: seq_list (iterable): List of DNA sequences (with letters from {A, C, G, T}) k (int): K in k-mer. Returns: pandas.DataFrame: Count matrix for seach sequence in seq_list Example: >>> kmer_count(["ACGTTAT", "GACGCGA"], 2) ...
[ "Generate", "k", "-", "mer", "counts", "from", "a", "set", "of", "sequences" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/legacy/kmer.py#L107-L128
gagneurlab/concise
concise/legacy/kmer.py
generate_all_kmers
def generate_all_kmers(k): """ Generate all possible k-mers Example: >>> generate_all_kmers(2) ['AA', 'AC', 'AG', 'AT', 'CA', 'CC', 'CG', 'CT', 'GA', 'GC', 'GG', 'GT', 'TA', 'TC', 'TG', 'TT'] """ bases = ['A', 'C', 'G', 'T'] return [''.join(p) for p in itertools.product(bases, repeat=k)...
python
def generate_all_kmers(k): """ Generate all possible k-mers Example: >>> generate_all_kmers(2) ['AA', 'AC', 'AG', 'AT', 'CA', 'CC', 'CG', 'CT', 'GA', 'GC', 'GG', 'GT', 'TA', 'TC', 'TG', 'TT'] """ bases = ['A', 'C', 'G', 'T'] return [''.join(p) for p in itertools.product(bases, repeat=k)...
[ "def", "generate_all_kmers", "(", "k", ")", ":", "bases", "=", "[", "'A'", ",", "'C'", ",", "'G'", ",", "'T'", "]", "return", "[", "''", ".", "join", "(", "p", ")", "for", "p", "in", "itertools", ".", "product", "(", "bases", ",", "repeat", "=", ...
Generate all possible k-mers Example: >>> generate_all_kmers(2) ['AA', 'AC', 'AG', 'AT', 'CA', 'CC', 'CG', 'CT', 'GA', 'GC', 'GG', 'GT', 'TA', 'TC', 'TG', 'TT']
[ "Generate", "all", "possible", "k", "-", "mers" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/legacy/kmer.py#L130-L139
gagneurlab/concise
concise/utils/helper.py
dict_to_numpy_dict
def dict_to_numpy_dict(obj_dict): """ Convert a dictionary of lists into a dictionary of numpy arrays """ return {key: np.asarray(value) if value is not None else None for key, value in obj_dict.items()}
python
def dict_to_numpy_dict(obj_dict): """ Convert a dictionary of lists into a dictionary of numpy arrays """ return {key: np.asarray(value) if value is not None else None for key, value in obj_dict.items()}
[ "def", "dict_to_numpy_dict", "(", "obj_dict", ")", ":", "return", "{", "key", ":", "np", ".", "asarray", "(", "value", ")", "if", "value", "is", "not", "None", "else", "None", "for", "key", ",", "value", "in", "obj_dict", ".", "items", "(", ")", "}" ...
Convert a dictionary of lists into a dictionary of numpy arrays
[ "Convert", "a", "dictionary", "of", "lists", "into", "a", "dictionary", "of", "numpy", "arrays" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/utils/helper.py#L65-L69
gagneurlab/concise
concise/utils/helper.py
rec_dict_to_numpy_dict
def rec_dict_to_numpy_dict(obj_dict): """ Same as dict_to_numpy_dict, but recursive """ if type(obj_dict) == dict: return {key: rec_dict_to_numpy_dict(value) if value is not None else None for key, value in obj_dict.items()} elif obj_dict is None: return None else: return...
python
def rec_dict_to_numpy_dict(obj_dict): """ Same as dict_to_numpy_dict, but recursive """ if type(obj_dict) == dict: return {key: rec_dict_to_numpy_dict(value) if value is not None else None for key, value in obj_dict.items()} elif obj_dict is None: return None else: return...
[ "def", "rec_dict_to_numpy_dict", "(", "obj_dict", ")", ":", "if", "type", "(", "obj_dict", ")", "==", "dict", ":", "return", "{", "key", ":", "rec_dict_to_numpy_dict", "(", "value", ")", "if", "value", "is", "not", "None", "else", "None", "for", "key", "...
Same as dict_to_numpy_dict, but recursive
[ "Same", "as", "dict_to_numpy_dict", "but", "recursive" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/utils/helper.py#L72-L81
gagneurlab/concise
concise/utils/helper.py
compare_numpy_dict
def compare_numpy_dict(a, b, exact=True): """ Compare two recursive numpy dictionaries """ if type(a) != type(b) and type(a) != np.ndarray and type(b) != np.ndarray: return False # go through a dictionary if type(a) == dict and type(b) == dict: if not a.keys() == b.keys(): ...
python
def compare_numpy_dict(a, b, exact=True): """ Compare two recursive numpy dictionaries """ if type(a) != type(b) and type(a) != np.ndarray and type(b) != np.ndarray: return False # go through a dictionary if type(a) == dict and type(b) == dict: if not a.keys() == b.keys(): ...
[ "def", "compare_numpy_dict", "(", "a", ",", "b", ",", "exact", "=", "True", ")", ":", "if", "type", "(", "a", ")", "!=", "type", "(", "b", ")", "and", "type", "(", "a", ")", "!=", "np", ".", "ndarray", "and", "type", "(", "b", ")", "!=", "np"...
Compare two recursive numpy dictionaries
[ "Compare", "two", "recursive", "numpy", "dictionaries" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/utils/helper.py#L84-L111
gagneurlab/concise
concise/utils/splines.py
get_gam_splines
def get_gam_splines(start=0, end=100, n_bases=10, spline_order=3, add_intercept=True): """Main function required by (TF)Concise class """ # make sure n_bases is an int assert type(n_bases) == int x = np.arange(start, end + 1) knots = get_knots(start, end, n_bases, spline_order) X_splines =...
python
def get_gam_splines(start=0, end=100, n_bases=10, spline_order=3, add_intercept=True): """Main function required by (TF)Concise class """ # make sure n_bases is an int assert type(n_bases) == int x = np.arange(start, end + 1) knots = get_knots(start, end, n_bases, spline_order) X_splines =...
[ "def", "get_gam_splines", "(", "start", "=", "0", ",", "end", "=", "100", ",", "n_bases", "=", "10", ",", "spline_order", "=", "3", ",", "add_intercept", "=", "True", ")", ":", "# make sure n_bases is an int", "assert", "type", "(", "n_bases", ")", "==", ...
Main function required by (TF)Concise class
[ "Main", "function", "required", "by", "(", "TF", ")", "Concise", "class" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/utils/splines.py#L102-L116
gagneurlab/concise
concise/utils/splines.py
get_knots
def get_knots(start, end, n_bases=10, spline_order=3): """ Arguments: x; np.array of dim 1 """ x_range = end - start start = start - x_range * 0.001 end = end + x_range * 0.001 # mgcv annotation m = spline_order - 1 nk = n_bases - m # number of interior knots ...
python
def get_knots(start, end, n_bases=10, spline_order=3): """ Arguments: x; np.array of dim 1 """ x_range = end - start start = start - x_range * 0.001 end = end + x_range * 0.001 # mgcv annotation m = spline_order - 1 nk = n_bases - m # number of interior knots ...
[ "def", "get_knots", "(", "start", ",", "end", ",", "n_bases", "=", "10", ",", "spline_order", "=", "3", ")", ":", "x_range", "=", "end", "-", "start", "start", "=", "start", "-", "x_range", "*", "0.001", "end", "=", "end", "+", "x_range", "*", "0.0...
Arguments: x; np.array of dim 1
[ "Arguments", ":", "x", ";", "np", ".", "array", "of", "dim", "1" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/utils/splines.py#L123-L140
gagneurlab/concise
concise/utils/splines.py
get_X_spline
def get_X_spline(x, knots, n_bases=10, spline_order=3, add_intercept=True): """ Returns: np.array of shape [len(x), n_bases + (add_intercept)] # BSpline formula https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.BSpline.html#scipy.interpolate.BSpline Fortran code: h...
python
def get_X_spline(x, knots, n_bases=10, spline_order=3, add_intercept=True): """ Returns: np.array of shape [len(x), n_bases + (add_intercept)] # BSpline formula https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.BSpline.html#scipy.interpolate.BSpline Fortran code: h...
[ "def", "get_X_spline", "(", "x", ",", "knots", ",", "n_bases", "=", "10", ",", "spline_order", "=", "3", ",", "add_intercept", "=", "True", ")", ":", "if", "len", "(", "x", ".", "shape", ")", "is", "not", "1", ":", "raise", "ValueError", "(", "\"x ...
Returns: np.array of shape [len(x), n_bases + (add_intercept)] # BSpline formula https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.BSpline.html#scipy.interpolate.BSpline Fortran code: https://github.com/scipy/scipy/blob/v0.19.0/scipy/interpolate/fitpack/splev.f
[ "Returns", ":", "np", ".", "array", "of", "shape", "[", "len", "(", "x", ")", "n_bases", "+", "(", "add_intercept", ")", "]" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/utils/splines.py#L144-L173
gagneurlab/concise
concise/utils/splines.py
BSpline.getS
def getS(self, add_intercept=False): """Get the penalty matrix S Returns np.array, of shape (n_bases + add_intercept, n_bases + add_intercept) """ S = self.S if add_intercept is True: # S <- cbind(0, rbind(0, S)) # in R zeros = np.zeros_like(S...
python
def getS(self, add_intercept=False): """Get the penalty matrix S Returns np.array, of shape (n_bases + add_intercept, n_bases + add_intercept) """ S = self.S if add_intercept is True: # S <- cbind(0, rbind(0, S)) # in R zeros = np.zeros_like(S...
[ "def", "getS", "(", "self", ",", "add_intercept", "=", "False", ")", ":", "S", "=", "self", ".", "S", "if", "add_intercept", "is", "True", ":", "# S <- cbind(0, rbind(0, S)) # in R", "zeros", "=", "np", ".", "zeros_like", "(", "S", "[", ":", "1", ",", ...
Get the penalty matrix S Returns np.array, of shape (n_bases + add_intercept, n_bases + add_intercept)
[ "Get", "the", "penalty", "matrix", "S" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/utils/splines.py#L49-L63
gagneurlab/concise
concise/utils/splines.py
BSpline.predict
def predict(self, x, add_intercept=False): """For some x, predict the bn(x) for each base Arguments: x: np.array; Vector of dimension 1 add_intercept: bool; should we add the intercept to the final array Returns: np.array, of shape (len(x), n_bases + (add_in...
python
def predict(self, x, add_intercept=False): """For some x, predict the bn(x) for each base Arguments: x: np.array; Vector of dimension 1 add_intercept: bool; should we add the intercept to the final array Returns: np.array, of shape (len(x), n_bases + (add_in...
[ "def", "predict", "(", "self", ",", "x", ",", "add_intercept", "=", "False", ")", ":", "# sanity check", "if", "x", ".", "min", "(", ")", "<", "self", ".", "start", ":", "raise", "Warning", "(", "\"x.min() < self.start\"", ")", "if", "x", ".", "max", ...
For some x, predict the bn(x) for each base Arguments: x: np.array; Vector of dimension 1 add_intercept: bool; should we add the intercept to the final array Returns: np.array, of shape (len(x), n_bases + (add_intercept))
[ "For", "some", "x", "predict", "the", "bn", "(", "x", ")", "for", "each", "base" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/utils/splines.py#L65-L85
gagneurlab/concise
concise/data/encode.py
get_metadata
def get_metadata(): """Get pandas.DataFrame with metadata about the PWM's. Columns: - PWM_id (id of the PWM - pass to get_pwm_list() for getting the pwm - info1 - additional information about the motifs - info2 - consensus: PWM consensus sequence """ motifs = _load_motifs() motif_names...
python
def get_metadata(): """Get pandas.DataFrame with metadata about the PWM's. Columns: - PWM_id (id of the PWM - pass to get_pwm_list() for getting the pwm - info1 - additional information about the motifs - info2 - consensus: PWM consensus sequence """ motifs = _load_motifs() motif_names...
[ "def", "get_metadata", "(", ")", ":", "motifs", "=", "_load_motifs", "(", ")", "motif_names", "=", "sorted", "(", "list", "(", "motifs", ".", "keys", "(", ")", ")", ")", "df", "=", "pd", ".", "Series", "(", "motif_names", ")", ".", "str", ".", "spl...
Get pandas.DataFrame with metadata about the PWM's. Columns: - PWM_id (id of the PWM - pass to get_pwm_list() for getting the pwm - info1 - additional information about the motifs - info2 - consensus: PWM consensus sequence
[ "Get", "pandas", ".", "DataFrame", "with", "metadata", "about", "the", "PWM", "s", ".", "Columns", ":" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/data/encode.py#L14-L31
gagneurlab/concise
concise/data/encode.py
get_pwm_list
def get_pwm_list(motif_name_list, pseudocountProb=0.0001): """Get a list of ENCODE PWM's. # Arguments pwm_id_list: List of id's from the `PWM_id` column in `get_metadata()` table pseudocountProb: Added pseudocount probabilities to the PWM # Returns List of `concise.utils.pwm.PWM` i...
python
def get_pwm_list(motif_name_list, pseudocountProb=0.0001): """Get a list of ENCODE PWM's. # Arguments pwm_id_list: List of id's from the `PWM_id` column in `get_metadata()` table pseudocountProb: Added pseudocount probabilities to the PWM # Returns List of `concise.utils.pwm.PWM` i...
[ "def", "get_pwm_list", "(", "motif_name_list", ",", "pseudocountProb", "=", "0.0001", ")", ":", "l", "=", "_load_motifs", "(", ")", "l", "=", "{", "k", ".", "split", "(", ")", "[", "0", "]", ":", "v", "for", "k", ",", "v", "in", "l", ".", "items"...
Get a list of ENCODE PWM's. # Arguments pwm_id_list: List of id's from the `PWM_id` column in `get_metadata()` table pseudocountProb: Added pseudocount probabilities to the PWM # Returns List of `concise.utils.pwm.PWM` instances.
[ "Get", "a", "list", "of", "ENCODE", "PWM", "s", "." ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/data/encode.py#L34-L47
gagneurlab/concise
concise/eval_metrics.py
auc
def auc(y_true, y_pred, round=True): """Area under the ROC curve """ y_true, y_pred = _mask_value_nan(y_true, y_pred) if round: y_true = y_true.round() if len(y_true) == 0 or len(np.unique(y_true)) < 2: return np.nan return skm.roc_auc_score(y_true, y_pred)
python
def auc(y_true, y_pred, round=True): """Area under the ROC curve """ y_true, y_pred = _mask_value_nan(y_true, y_pred) if round: y_true = y_true.round() if len(y_true) == 0 or len(np.unique(y_true)) < 2: return np.nan return skm.roc_auc_score(y_true, y_pred)
[ "def", "auc", "(", "y_true", ",", "y_pred", ",", "round", "=", "True", ")", ":", "y_true", ",", "y_pred", "=", "_mask_value_nan", "(", "y_true", ",", "y_pred", ")", "if", "round", ":", "y_true", "=", "y_true", ".", "round", "(", ")", "if", "len", "...
Area under the ROC curve
[ "Area", "under", "the", "ROC", "curve" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/eval_metrics.py#L37-L46
gagneurlab/concise
concise/eval_metrics.py
auprc
def auprc(y_true, y_pred): """Area under the precision-recall curve """ y_true, y_pred = _mask_value_nan(y_true, y_pred) precision, recall, _ = skm.precision_recall_curve(y_true, y_pred) return skm.auc(recall, precision)
python
def auprc(y_true, y_pred): """Area under the precision-recall curve """ y_true, y_pred = _mask_value_nan(y_true, y_pred) precision, recall, _ = skm.precision_recall_curve(y_true, y_pred) return skm.auc(recall, precision)
[ "def", "auprc", "(", "y_true", ",", "y_pred", ")", ":", "y_true", ",", "y_pred", "=", "_mask_value_nan", "(", "y_true", ",", "y_pred", ")", "precision", ",", "recall", ",", "_", "=", "skm", ".", "precision_recall_curve", "(", "y_true", ",", "y_pred", ")"...
Area under the precision-recall curve
[ "Area", "under", "the", "precision", "-", "recall", "curve" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/eval_metrics.py#L49-L54
gagneurlab/concise
concise/eval_metrics.py
recall_at_precision
def recall_at_precision(y_true, y_pred, precision): """Recall at a certain precision threshold Args: y_true: true labels y_pred: predicted labels precision: resired precision level at which where to compute the recall """ y_true, y_pred = _mask_value_nan(y_true, y_pred) precision,...
python
def recall_at_precision(y_true, y_pred, precision): """Recall at a certain precision threshold Args: y_true: true labels y_pred: predicted labels precision: resired precision level at which where to compute the recall """ y_true, y_pred = _mask_value_nan(y_true, y_pred) precision,...
[ "def", "recall_at_precision", "(", "y_true", ",", "y_pred", ",", "precision", ")", ":", "y_true", ",", "y_pred", "=", "_mask_value_nan", "(", "y_true", ",", "y_pred", ")", "precision", ",", "recall", ",", "_", "=", "skm", ".", "precision_recall_curve", "(", ...
Recall at a certain precision threshold Args: y_true: true labels y_pred: predicted labels precision: resired precision level at which where to compute the recall
[ "Recall", "at", "a", "certain", "precision", "threshold" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/eval_metrics.py#L57-L67
gagneurlab/concise
concise/eval_metrics.py
accuracy
def accuracy(y_true, y_pred, round=True): """Classification accuracy """ y_true, y_pred = _mask_value_nan(y_true, y_pred) if round: y_true = np.round(y_true) y_pred = np.round(y_pred) return skm.accuracy_score(y_true, y_pred)
python
def accuracy(y_true, y_pred, round=True): """Classification accuracy """ y_true, y_pred = _mask_value_nan(y_true, y_pred) if round: y_true = np.round(y_true) y_pred = np.round(y_pred) return skm.accuracy_score(y_true, y_pred)
[ "def", "accuracy", "(", "y_true", ",", "y_pred", ",", "round", "=", "True", ")", ":", "y_true", ",", "y_pred", "=", "_mask_value_nan", "(", "y_true", ",", "y_pred", ")", "if", "round", ":", "y_true", "=", "np", ".", "round", "(", "y_true", ")", "y_pr...
Classification accuracy
[ "Classification", "accuracy" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/eval_metrics.py#L70-L77
gagneurlab/concise
concise/eval_metrics.py
tpr
def tpr(y_true, y_pred, round=True): """True positive rate `tp / (tp + fn)` """ y_true, y_pred = _mask_value_nan(y_true, y_pred) if round: y_true = np.round(y_true) y_pred = np.round(y_pred) return skm.recall_score(y_true, y_pred)
python
def tpr(y_true, y_pred, round=True): """True positive rate `tp / (tp + fn)` """ y_true, y_pred = _mask_value_nan(y_true, y_pred) if round: y_true = np.round(y_true) y_pred = np.round(y_pred) return skm.recall_score(y_true, y_pred)
[ "def", "tpr", "(", "y_true", ",", "y_pred", ",", "round", "=", "True", ")", ":", "y_true", ",", "y_pred", "=", "_mask_value_nan", "(", "y_true", ",", "y_pred", ")", "if", "round", ":", "y_true", "=", "np", ".", "round", "(", "y_true", ")", "y_pred", ...
True positive rate `tp / (tp + fn)`
[ "True", "positive", "rate", "tp", "/", "(", "tp", "+", "fn", ")" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/eval_metrics.py#L80-L87
gagneurlab/concise
concise/eval_metrics.py
tnr
def tnr(y_true, y_pred, round=True): """True negative rate `tn / (tn + fp)` """ y_true, y_pred = _mask_value_nan(y_true, y_pred) if round: y_true = np.round(y_true) y_pred = np.round(y_pred) c = skm.confusion_matrix(y_true, y_pred) return c[0, 0] / c[0].sum()
python
def tnr(y_true, y_pred, round=True): """True negative rate `tn / (tn + fp)` """ y_true, y_pred = _mask_value_nan(y_true, y_pred) if round: y_true = np.round(y_true) y_pred = np.round(y_pred) c = skm.confusion_matrix(y_true, y_pred) return c[0, 0] / c[0].sum()
[ "def", "tnr", "(", "y_true", ",", "y_pred", ",", "round", "=", "True", ")", ":", "y_true", ",", "y_pred", "=", "_mask_value_nan", "(", "y_true", ",", "y_pred", ")", "if", "round", ":", "y_true", "=", "np", ".", "round", "(", "y_true", ")", "y_pred", ...
True negative rate `tn / (tn + fp)`
[ "True", "negative", "rate", "tn", "/", "(", "tn", "+", "fp", ")" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/eval_metrics.py#L90-L98
gagneurlab/concise
concise/eval_metrics.py
mcc
def mcc(y_true, y_pred, round=True): """Matthews correlation coefficient """ y_true, y_pred = _mask_value_nan(y_true, y_pred) if round: y_true = np.round(y_true) y_pred = np.round(y_pred) return skm.matthews_corrcoef(y_true, y_pred)
python
def mcc(y_true, y_pred, round=True): """Matthews correlation coefficient """ y_true, y_pred = _mask_value_nan(y_true, y_pred) if round: y_true = np.round(y_true) y_pred = np.round(y_pred) return skm.matthews_corrcoef(y_true, y_pred)
[ "def", "mcc", "(", "y_true", ",", "y_pred", ",", "round", "=", "True", ")", ":", "y_true", ",", "y_pred", "=", "_mask_value_nan", "(", "y_true", ",", "y_pred", ")", "if", "round", ":", "y_true", "=", "np", ".", "round", "(", "y_true", ")", "y_pred", ...
Matthews correlation coefficient
[ "Matthews", "correlation", "coefficient" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/eval_metrics.py#L101-L108
gagneurlab/concise
concise/eval_metrics.py
f1
def f1(y_true, y_pred, round=True): """F1 score: `2 * (p * r) / (p + r)`, where p=precision and r=recall. """ y_true, y_pred = _mask_value_nan(y_true, y_pred) if round: y_true = np.round(y_true) y_pred = np.round(y_pred) return skm.f1_score(y_true, y_pred)
python
def f1(y_true, y_pred, round=True): """F1 score: `2 * (p * r) / (p + r)`, where p=precision and r=recall. """ y_true, y_pred = _mask_value_nan(y_true, y_pred) if round: y_true = np.round(y_true) y_pred = np.round(y_pred) return skm.f1_score(y_true, y_pred)
[ "def", "f1", "(", "y_true", ",", "y_pred", ",", "round", "=", "True", ")", ":", "y_true", ",", "y_pred", "=", "_mask_value_nan", "(", "y_true", ",", "y_pred", ")", "if", "round", ":", "y_true", "=", "np", ".", "round", "(", "y_true", ")", "y_pred", ...
F1 score: `2 * (p * r) / (p + r)`, where p=precision and r=recall.
[ "F1", "score", ":", "2", "*", "(", "p", "*", "r", ")", "/", "(", "p", "+", "r", ")", "where", "p", "=", "precision", "and", "r", "=", "recall", "." ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/eval_metrics.py#L111-L118
gagneurlab/concise
concise/eval_metrics.py
cat_acc
def cat_acc(y_true, y_pred): """Categorical accuracy """ return np.mean(y_true.argmax(axis=1) == y_pred.argmax(axis=1))
python
def cat_acc(y_true, y_pred): """Categorical accuracy """ return np.mean(y_true.argmax(axis=1) == y_pred.argmax(axis=1))
[ "def", "cat_acc", "(", "y_true", ",", "y_pred", ")", ":", "return", "np", ".", "mean", "(", "y_true", ".", "argmax", "(", "axis", "=", "1", ")", "==", "y_pred", ".", "argmax", "(", "axis", "=", "1", ")", ")" ]
Categorical accuracy
[ "Categorical", "accuracy" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/eval_metrics.py#L123-L126
gagneurlab/concise
concise/eval_metrics.py
cor
def cor(y_true, y_pred): """Compute Pearson correlation coefficient. """ y_true, y_pred = _mask_nan(y_true, y_pred) return np.corrcoef(y_true, y_pred)[0, 1]
python
def cor(y_true, y_pred): """Compute Pearson correlation coefficient. """ y_true, y_pred = _mask_nan(y_true, y_pred) return np.corrcoef(y_true, y_pred)[0, 1]
[ "def", "cor", "(", "y_true", ",", "y_pred", ")", ":", "y_true", ",", "y_pred", "=", "_mask_nan", "(", "y_true", ",", "y_pred", ")", "return", "np", ".", "corrcoef", "(", "y_true", ",", "y_pred", ")", "[", "0", ",", "1", "]" ]
Compute Pearson correlation coefficient.
[ "Compute", "Pearson", "correlation", "coefficient", "." ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/eval_metrics.py#L131-L135
gagneurlab/concise
concise/eval_metrics.py
kendall
def kendall(y_true, y_pred, nb_sample=100000): """Kendall's tau coefficient, Kendall rank correlation coefficient """ y_true, y_pred = _mask_nan(y_true, y_pred) if len(y_true) > nb_sample: idx = np.arange(len(y_true)) np.random.shuffle(idx) idx = idx[:nb_sample] y_true = ...
python
def kendall(y_true, y_pred, nb_sample=100000): """Kendall's tau coefficient, Kendall rank correlation coefficient """ y_true, y_pred = _mask_nan(y_true, y_pred) if len(y_true) > nb_sample: idx = np.arange(len(y_true)) np.random.shuffle(idx) idx = idx[:nb_sample] y_true = ...
[ "def", "kendall", "(", "y_true", ",", "y_pred", ",", "nb_sample", "=", "100000", ")", ":", "y_true", ",", "y_pred", "=", "_mask_nan", "(", "y_true", ",", "y_pred", ")", "if", "len", "(", "y_true", ")", ">", "nb_sample", ":", "idx", "=", "np", ".", ...
Kendall's tau coefficient, Kendall rank correlation coefficient
[ "Kendall", "s", "tau", "coefficient", "Kendall", "rank", "correlation", "coefficient" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/eval_metrics.py#L138-L148
gagneurlab/concise
concise/eval_metrics.py
mad
def mad(y_true, y_pred): """Median absolute deviation """ y_true, y_pred = _mask_nan(y_true, y_pred) return np.mean(np.abs(y_true - y_pred))
python
def mad(y_true, y_pred): """Median absolute deviation """ y_true, y_pred = _mask_nan(y_true, y_pred) return np.mean(np.abs(y_true - y_pred))
[ "def", "mad", "(", "y_true", ",", "y_pred", ")", ":", "y_true", ",", "y_pred", "=", "_mask_nan", "(", "y_true", ",", "y_pred", ")", "return", "np", ".", "mean", "(", "np", ".", "abs", "(", "y_true", "-", "y_pred", ")", ")" ]
Median absolute deviation
[ "Median", "absolute", "deviation" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/eval_metrics.py#L151-L155
gagneurlab/concise
concise/eval_metrics.py
mse
def mse(y_true, y_pred): """Mean squared error """ y_true, y_pred = _mask_nan(y_true, y_pred) return ((y_true - y_pred) ** 2).mean(axis=None)
python
def mse(y_true, y_pred): """Mean squared error """ y_true, y_pred = _mask_nan(y_true, y_pred) return ((y_true - y_pred) ** 2).mean(axis=None)
[ "def", "mse", "(", "y_true", ",", "y_pred", ")", ":", "y_true", ",", "y_pred", "=", "_mask_nan", "(", "y_true", ",", "y_pred", ")", "return", "(", "(", "y_true", "-", "y_pred", ")", "**", "2", ")", ".", "mean", "(", "axis", "=", "None", ")" ]
Mean squared error
[ "Mean", "squared", "error" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/eval_metrics.py#L170-L174
gagneurlab/concise
concise/eval_metrics.py
var_explained
def var_explained(y_true, y_pred): """Fraction of variance explained. """ y_true, y_pred = _mask_nan(y_true, y_pred) var_resid = np.var(y_true - y_pred) var_y_true = np.var(y_true) return 1 - var_resid / var_y_true
python
def var_explained(y_true, y_pred): """Fraction of variance explained. """ y_true, y_pred = _mask_nan(y_true, y_pred) var_resid = np.var(y_true - y_pred) var_y_true = np.var(y_true) return 1 - var_resid / var_y_true
[ "def", "var_explained", "(", "y_true", ",", "y_pred", ")", ":", "y_true", ",", "y_pred", "=", "_mask_nan", "(", "y_true", ",", "y_pred", ")", "var_resid", "=", "np", ".", "var", "(", "y_true", "-", "y_pred", ")", "var_y_true", "=", "np", ".", "var", ...
Fraction of variance explained.
[ "Fraction", "of", "variance", "explained", "." ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/eval_metrics.py#L183-L189
gagneurlab/concise
concise/legacy/args_sampler.py
sample_params
def sample_params(params): """Randomly sample hyper-parameters stored in a dictionary on a predefined range and scale. Useful for hyper-parameter random search. Args: params (dict): hyper-parameters to sample. Dictionary value-type parsing: - :python:`[1e3, 1e7]` - uniformly ...
python
def sample_params(params): """Randomly sample hyper-parameters stored in a dictionary on a predefined range and scale. Useful for hyper-parameter random search. Args: params (dict): hyper-parameters to sample. Dictionary value-type parsing: - :python:`[1e3, 1e7]` - uniformly ...
[ "def", "sample_params", "(", "params", ")", ":", "def", "sample_log", "(", "myrange", ")", ":", "x", "=", "np", ".", "random", ".", "uniform", "(", "np", ".", "log10", "(", "myrange", "[", "0", "]", ")", ",", "np", ".", "log10", "(", "myrange", "...
Randomly sample hyper-parameters stored in a dictionary on a predefined range and scale. Useful for hyper-parameter random search. Args: params (dict): hyper-parameters to sample. Dictionary value-type parsing: - :python:`[1e3, 1e7]` - uniformly sample on a **log10** scale from t...
[ "Randomly", "sample", "hyper", "-", "parameters", "stored", "in", "a", "dictionary", "on", "a", "predefined", "range", "and", "scale", "." ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/legacy/args_sampler.py#L8-L68
gagneurlab/concise
concise/metrics.py
contingency_table
def contingency_table(y, z): """Note: if y and z are not rounded to 0 or 1, they are ignored """ y = K.cast(K.round(y), K.floatx()) z = K.cast(K.round(z), K.floatx()) def count_matches(y, z): return K.sum(K.cast(y, K.floatx()) * K.cast(z, K.floatx())) ones = K.ones_like(y) zeros =...
python
def contingency_table(y, z): """Note: if y and z are not rounded to 0 or 1, they are ignored """ y = K.cast(K.round(y), K.floatx()) z = K.cast(K.round(z), K.floatx()) def count_matches(y, z): return K.sum(K.cast(y, K.floatx()) * K.cast(z, K.floatx())) ones = K.ones_like(y) zeros =...
[ "def", "contingency_table", "(", "y", ",", "z", ")", ":", "y", "=", "K", ".", "cast", "(", "K", ".", "round", "(", "y", ")", ",", "K", ".", "floatx", "(", ")", ")", "z", "=", "K", ".", "cast", "(", "K", ".", "round", "(", "z", ")", ",", ...
Note: if y and z are not rounded to 0 or 1, they are ignored
[ "Note", ":", "if", "y", "and", "z", "are", "not", "rounded", "to", "0", "or", "1", "they", "are", "ignored" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/metrics.py#L17-L38
gagneurlab/concise
concise/metrics.py
tpr
def tpr(y, z): """True positive rate `tp / (tp + fn)` """ tp, tn, fp, fn = contingency_table(y, z) return tp / (tp + fn)
python
def tpr(y, z): """True positive rate `tp / (tp + fn)` """ tp, tn, fp, fn = contingency_table(y, z) return tp / (tp + fn)
[ "def", "tpr", "(", "y", ",", "z", ")", ":", "tp", ",", "tn", ",", "fp", ",", "fn", "=", "contingency_table", "(", "y", ",", "z", ")", "return", "tp", "/", "(", "tp", "+", "fn", ")" ]
True positive rate `tp / (tp + fn)`
[ "True", "positive", "rate", "tp", "/", "(", "tp", "+", "fn", ")" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/metrics.py#L41-L45
gagneurlab/concise
concise/metrics.py
tnr
def tnr(y, z): """True negative rate `tn / (tn + fp)` """ tp, tn, fp, fn = contingency_table(y, z) return tn / (tn + fp)
python
def tnr(y, z): """True negative rate `tn / (tn + fp)` """ tp, tn, fp, fn = contingency_table(y, z) return tn / (tn + fp)
[ "def", "tnr", "(", "y", ",", "z", ")", ":", "tp", ",", "tn", ",", "fp", ",", "fn", "=", "contingency_table", "(", "y", ",", "z", ")", "return", "tn", "/", "(", "tn", "+", "fp", ")" ]
True negative rate `tn / (tn + fp)`
[ "True", "negative", "rate", "tn", "/", "(", "tn", "+", "fp", ")" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/metrics.py#L48-L52
gagneurlab/concise
concise/metrics.py
fpr
def fpr(y, z): """False positive rate `fp / (fp + tn)` """ tp, tn, fp, fn = contingency_table(y, z) return fp / (fp + tn)
python
def fpr(y, z): """False positive rate `fp / (fp + tn)` """ tp, tn, fp, fn = contingency_table(y, z) return fp / (fp + tn)
[ "def", "fpr", "(", "y", ",", "z", ")", ":", "tp", ",", "tn", ",", "fp", ",", "fn", "=", "contingency_table", "(", "y", ",", "z", ")", "return", "fp", "/", "(", "fp", "+", "tn", ")" ]
False positive rate `fp / (fp + tn)`
[ "False", "positive", "rate", "fp", "/", "(", "fp", "+", "tn", ")" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/metrics.py#L55-L59
gagneurlab/concise
concise/metrics.py
fnr
def fnr(y, z): """False negative rate `fn / (fn + tp)` """ tp, tn, fp, fn = contingency_table(y, z) return fn / (fn + tp)
python
def fnr(y, z): """False negative rate `fn / (fn + tp)` """ tp, tn, fp, fn = contingency_table(y, z) return fn / (fn + tp)
[ "def", "fnr", "(", "y", ",", "z", ")", ":", "tp", ",", "tn", ",", "fp", ",", "fn", "=", "contingency_table", "(", "y", ",", "z", ")", "return", "fn", "/", "(", "fn", "+", "tp", ")" ]
False negative rate `fn / (fn + tp)`
[ "False", "negative", "rate", "fn", "/", "(", "fn", "+", "tp", ")" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/metrics.py#L62-L66
gagneurlab/concise
concise/metrics.py
precision
def precision(y, z): """Precision `tp / (tp + fp)` """ tp, tn, fp, fn = contingency_table(y, z) return tp / (tp + fp)
python
def precision(y, z): """Precision `tp / (tp + fp)` """ tp, tn, fp, fn = contingency_table(y, z) return tp / (tp + fp)
[ "def", "precision", "(", "y", ",", "z", ")", ":", "tp", ",", "tn", ",", "fp", ",", "fn", "=", "contingency_table", "(", "y", ",", "z", ")", "return", "tp", "/", "(", "tp", "+", "fp", ")" ]
Precision `tp / (tp + fp)`
[ "Precision", "tp", "/", "(", "tp", "+", "fp", ")" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/metrics.py#L69-L73
gagneurlab/concise
concise/metrics.py
fdr
def fdr(y, z): """False discovery rate `fp / (tp + fp)` """ tp, tn, fp, fn = contingency_table(y, z) return fp / (tp + fp)
python
def fdr(y, z): """False discovery rate `fp / (tp + fp)` """ tp, tn, fp, fn = contingency_table(y, z) return fp / (tp + fp)
[ "def", "fdr", "(", "y", ",", "z", ")", ":", "tp", ",", "tn", ",", "fp", ",", "fn", "=", "contingency_table", "(", "y", ",", "z", ")", "return", "fp", "/", "(", "tp", "+", "fp", ")" ]
False discovery rate `fp / (tp + fp)`
[ "False", "discovery", "rate", "fp", "/", "(", "tp", "+", "fp", ")" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/metrics.py#L76-L80
gagneurlab/concise
concise/metrics.py
accuracy
def accuracy(y, z): """Classification accuracy `(tp + tn) / (tp + tn + fp + fn)` """ tp, tn, fp, fn = contingency_table(y, z) return (tp + tn) / (tp + tn + fp + fn)
python
def accuracy(y, z): """Classification accuracy `(tp + tn) / (tp + tn + fp + fn)` """ tp, tn, fp, fn = contingency_table(y, z) return (tp + tn) / (tp + tn + fp + fn)
[ "def", "accuracy", "(", "y", ",", "z", ")", ":", "tp", ",", "tn", ",", "fp", ",", "fn", "=", "contingency_table", "(", "y", ",", "z", ")", "return", "(", "tp", "+", "tn", ")", "/", "(", "tp", "+", "tn", "+", "fp", "+", "fn", ")" ]
Classification accuracy `(tp + tn) / (tp + tn + fp + fn)`
[ "Classification", "accuracy", "(", "tp", "+", "tn", ")", "/", "(", "tp", "+", "tn", "+", "fp", "+", "fn", ")" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/metrics.py#L83-L87
gagneurlab/concise
concise/metrics.py
f1
def f1(y, z): """F1 score: `2 * (p * r) / (p + r)`, where p=precision and r=recall. """ _recall = recall(y, z) _prec = precision(y, z) return 2 * (_prec * _recall) / (_prec + _recall)
python
def f1(y, z): """F1 score: `2 * (p * r) / (p + r)`, where p=precision and r=recall. """ _recall = recall(y, z) _prec = precision(y, z) return 2 * (_prec * _recall) / (_prec + _recall)
[ "def", "f1", "(", "y", ",", "z", ")", ":", "_recall", "=", "recall", "(", "y", ",", "z", ")", "_prec", "=", "precision", "(", "y", ",", "z", ")", "return", "2", "*", "(", "_prec", "*", "_recall", ")", "/", "(", "_prec", "+", "_recall", ")" ]
F1 score: `2 * (p * r) / (p + r)`, where p=precision and r=recall.
[ "F1", "score", ":", "2", "*", "(", "p", "*", "r", ")", "/", "(", "p", "+", "r", ")", "where", "p", "=", "precision", "and", "r", "=", "recall", "." ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/metrics.py#L94-L99
gagneurlab/concise
concise/metrics.py
mcc
def mcc(y, z): """Matthews correlation coefficient """ tp, tn, fp, fn = contingency_table(y, z) return (tp * tn - fp * fn) / K.sqrt((tp + fp) * (tp + fn) * (tn + fp) * (tn + fn))
python
def mcc(y, z): """Matthews correlation coefficient """ tp, tn, fp, fn = contingency_table(y, z) return (tp * tn - fp * fn) / K.sqrt((tp + fp) * (tp + fn) * (tn + fp) * (tn + fn))
[ "def", "mcc", "(", "y", ",", "z", ")", ":", "tp", ",", "tn", ",", "fp", ",", "fn", "=", "contingency_table", "(", "y", ",", "z", ")", "return", "(", "tp", "*", "tn", "-", "fp", "*", "fn", ")", "/", "K", ".", "sqrt", "(", "(", "tp", "+", ...
Matthews correlation coefficient
[ "Matthews", "correlation", "coefficient" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/metrics.py#L102-L106
gagneurlab/concise
concise/metrics.py
cat_acc
def cat_acc(y, z): """Classification accuracy for multi-categorical case """ weights = _cat_sample_weights(y) _acc = K.cast(K.equal(K.argmax(y, axis=-1), K.argmax(z, axis=-1)), K.floatx()) _acc = K.sum(_acc * weights) / K.sum(weights) return _acc
python
def cat_acc(y, z): """Classification accuracy for multi-categorical case """ weights = _cat_sample_weights(y) _acc = K.cast(K.equal(K.argmax(y, axis=-1), K.argmax(z, axis=-1)), K.floatx()) _acc = K.sum(_acc * weights) / K.sum(weights) return _acc
[ "def", "cat_acc", "(", "y", ",", "z", ")", ":", "weights", "=", "_cat_sample_weights", "(", "y", ")", "_acc", "=", "K", ".", "cast", "(", "K", ".", "equal", "(", "K", ".", "argmax", "(", "y", ",", "axis", "=", "-", "1", ")", ",", "K", ".", ...
Classification accuracy for multi-categorical case
[ "Classification", "accuracy", "for", "multi", "-", "categorical", "case" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/metrics.py#L126-L134
gagneurlab/concise
concise/metrics.py
var_explained
def var_explained(y_true, y_pred): """Fraction of variance explained. """ var_resid = K.var(y_true - y_pred) var_y_true = K.var(y_true) return 1 - var_resid / var_y_true
python
def var_explained(y_true, y_pred): """Fraction of variance explained. """ var_resid = K.var(y_true - y_pred) var_y_true = K.var(y_true) return 1 - var_resid / var_y_true
[ "def", "var_explained", "(", "y_true", ",", "y_pred", ")", ":", "var_resid", "=", "K", ".", "var", "(", "y_true", "-", "y_pred", ")", "var_y_true", "=", "K", ".", "var", "(", "y_true", ")", "return", "1", "-", "var_resid", "/", "var_y_true" ]
Fraction of variance explained.
[ "Fraction", "of", "variance", "explained", "." ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/metrics.py#L152-L157
gagneurlab/concise
concise/utils/model_data.py
split_KFold_idx
def split_KFold_idx(train, cv_n_folds=5, stratified=False, random_state=None): """Get k-fold indices generator """ test_len(train) y = train[1] n_rows = y.shape[0] if stratified: if len(y.shape) > 1: if y.shape[1] > 1: raise ValueError("Can't use stratified K-...
python
def split_KFold_idx(train, cv_n_folds=5, stratified=False, random_state=None): """Get k-fold indices generator """ test_len(train) y = train[1] n_rows = y.shape[0] if stratified: if len(y.shape) > 1: if y.shape[1] > 1: raise ValueError("Can't use stratified K-...
[ "def", "split_KFold_idx", "(", "train", ",", "cv_n_folds", "=", "5", ",", "stratified", "=", "False", ",", "random_state", "=", "None", ")", ":", "test_len", "(", "train", ")", "y", "=", "train", "[", "1", "]", "n_rows", "=", "y", ".", "shape", "[", ...
Get k-fold indices generator
[ "Get", "k", "-", "fold", "indices", "generator" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/utils/model_data.py#L38-L55
gagneurlab/concise
concise/utils/model_data.py
subset
def subset(train, idx, keep_other=True): """Subset the `train=(x, y)` data tuple, each of the form: - list, np.ndarray - tuple, np.ndarray - dictionary, np.ndarray - np.ndarray, np.ndarray # Note In case there are other data present in the tuple: `(x, y, other1, other2, ...)`, ...
python
def subset(train, idx, keep_other=True): """Subset the `train=(x, y)` data tuple, each of the form: - list, np.ndarray - tuple, np.ndarray - dictionary, np.ndarray - np.ndarray, np.ndarray # Note In case there are other data present in the tuple: `(x, y, other1, other2, ...)`, ...
[ "def", "subset", "(", "train", ",", "idx", ",", "keep_other", "=", "True", ")", ":", "test_len", "(", "train", ")", "y", "=", "train", "[", "1", "]", "[", "idx", "]", "# x split", "if", "isinstance", "(", "train", "[", "0", "]", ",", "(", "list",...
Subset the `train=(x, y)` data tuple, each of the form: - list, np.ndarray - tuple, np.ndarray - dictionary, np.ndarray - np.ndarray, np.ndarray # Note In case there are other data present in the tuple: `(x, y, other1, other2, ...)`, these get passed on as: `(x_sub, y_sub, ...
[ "Subset", "the", "train", "=", "(", "x", "y", ")", "data", "tuple", "each", "of", "the", "form", ":" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/utils/model_data.py#L58-L92
gagneurlab/concise
concise/legacy/get_data.py
prepare_data
def prepare_data(dt, features, response, sequence, id_column=None, seq_align="end", trim_seq_len=None): """ Prepare data for Concise.train or ConciseCV.train. Args: dt: A pandas DataFrame containing all the required data. features (List of strings): Column names of `dt` used to produce the ...
python
def prepare_data(dt, features, response, sequence, id_column=None, seq_align="end", trim_seq_len=None): """ Prepare data for Concise.train or ConciseCV.train. Args: dt: A pandas DataFrame containing all the required data. features (List of strings): Column names of `dt` used to produce the ...
[ "def", "prepare_data", "(", "dt", ",", "features", ",", "response", ",", "sequence", ",", "id_column", "=", "None", ",", "seq_align", "=", "\"end\"", ",", "trim_seq_len", "=", "None", ")", ":", "if", "type", "(", "response", ")", "is", "str", ":", "res...
Prepare data for Concise.train or ConciseCV.train. Args: dt: A pandas DataFrame containing all the required data. features (List of strings): Column names of `dt` used to produce the features design matrix. These columns should be numeric. response (str or list of strings): Name(s) of colum...
[ "Prepare", "data", "for", "Concise", ".", "train", "or", "ConciseCV", ".", "train", "." ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/legacy/get_data.py#L10-L59
gagneurlab/concise
concise/preprocessing/splines.py
_trunc
def _trunc(x, minval=None, maxval=None): """Truncate vector values to have values on range [minval, maxval] """ x = np.copy(x) if minval is not None: x[x < minval] = minval if maxval is not None: x[x > maxval] = maxval return x
python
def _trunc(x, minval=None, maxval=None): """Truncate vector values to have values on range [minval, maxval] """ x = np.copy(x) if minval is not None: x[x < minval] = minval if maxval is not None: x[x > maxval] = maxval return x
[ "def", "_trunc", "(", "x", ",", "minval", "=", "None", ",", "maxval", "=", "None", ")", ":", "x", "=", "np", ".", "copy", "(", "x", ")", "if", "minval", "is", "not", "None", ":", "x", "[", "x", "<", "minval", "]", "=", "minval", "if", "maxval...
Truncate vector values to have values on range [minval, maxval]
[ "Truncate", "vector", "values", "to", "have", "values", "on", "range", "[", "minval", "maxval", "]" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/preprocessing/splines.py#L8-L16
gagneurlab/concise
concise/preprocessing/splines.py
encodeSplines
def encodeSplines(x, n_bases=10, spline_order=3, start=None, end=None, warn=True): """**Deprecated**. Function version of the transformer class `EncodeSplines`. Get B-spline base-function expansion # Details First, the knots for B-spline basis functions are placed equidistantly on the [star...
python
def encodeSplines(x, n_bases=10, spline_order=3, start=None, end=None, warn=True): """**Deprecated**. Function version of the transformer class `EncodeSplines`. Get B-spline base-function expansion # Details First, the knots for B-spline basis functions are placed equidistantly on the [star...
[ "def", "encodeSplines", "(", "x", ",", "n_bases", "=", "10", ",", "spline_order", "=", "3", ",", "start", "=", "None", ",", "end", "=", "None", ",", "warn", "=", "True", ")", ":", "# TODO - make it general...", "if", "len", "(", "x", ".", "shape", ")...
**Deprecated**. Function version of the transformer class `EncodeSplines`. Get B-spline base-function expansion # Details First, the knots for B-spline basis functions are placed equidistantly on the [start, end] range. (inferred from the data if None). Next, b_n(x) value is is ...
[ "**", "Deprecated", "**", ".", "Function", "version", "of", "the", "transformer", "class", "EncodeSplines", ".", "Get", "B", "-", "spline", "base", "-", "function", "expansion" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/preprocessing/splines.py#L93-L149
gagneurlab/concise
concise/preprocessing/splines.py
EncodeSplines.fit
def fit(self, x): """Calculate the knot placement from the values ranges. # Arguments x: numpy array, either N x D or N x L x D dimensional. """ assert x.ndim > 1 self.data_min_ = np.min(x, axis=tuple(range(x.ndim - 1))) self.data_max_ = np.max(x, axis=tuple(...
python
def fit(self, x): """Calculate the knot placement from the values ranges. # Arguments x: numpy array, either N x D or N x L x D dimensional. """ assert x.ndim > 1 self.data_min_ = np.min(x, axis=tuple(range(x.ndim - 1))) self.data_max_ = np.max(x, axis=tuple(...
[ "def", "fit", "(", "self", ",", "x", ")", ":", "assert", "x", ".", "ndim", ">", "1", "self", ".", "data_min_", "=", "np", ".", "min", "(", "x", ",", "axis", "=", "tuple", "(", "range", "(", "x", ".", "ndim", "-", "1", ")", ")", ")", "self",...
Calculate the knot placement from the values ranges. # Arguments x: numpy array, either N x D or N x L x D dimensional.
[ "Calculate", "the", "knot", "placement", "from", "the", "values", "ranges", "." ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/preprocessing/splines.py#L52-L64
gagneurlab/concise
concise/preprocessing/splines.py
EncodeSplines.transform
def transform(self, x, warn=True): """Obtain the transformed values """ # 1. split across last dimension # 2. re-use ranges # 3. Merge array_list = [encodeSplines(x[..., i].reshape((-1, 1)), n_bases=self.n_bases, ...
python
def transform(self, x, warn=True): """Obtain the transformed values """ # 1. split across last dimension # 2. re-use ranges # 3. Merge array_list = [encodeSplines(x[..., i].reshape((-1, 1)), n_bases=self.n_bases, ...
[ "def", "transform", "(", "self", ",", "x", ",", "warn", "=", "True", ")", ":", "# 1. split across last dimension", "# 2. re-use ranges", "# 3. Merge", "array_list", "=", "[", "encodeSplines", "(", "x", "[", "...", ",", "i", "]", ".", "reshape", "(", "(", "...
Obtain the transformed values
[ "Obtain", "the", "transformed", "values" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/preprocessing/splines.py#L66-L79
gagneurlab/concise
concise/layers.py
InputCodon
def InputCodon(seq_length, ignore_stop_codons=True, name=None, **kwargs): """Input placeholder for array returned by `encodeCodon` Note: The seq_length is divided by 3 Wrapper for: `keras.layers.Input((seq_length / 3, 61 or 61), name=name, **kwargs)` """ if ignore_stop_codons: vocab = CODO...
python
def InputCodon(seq_length, ignore_stop_codons=True, name=None, **kwargs): """Input placeholder for array returned by `encodeCodon` Note: The seq_length is divided by 3 Wrapper for: `keras.layers.Input((seq_length / 3, 61 or 61), name=name, **kwargs)` """ if ignore_stop_codons: vocab = CODO...
[ "def", "InputCodon", "(", "seq_length", ",", "ignore_stop_codons", "=", "True", ",", "name", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "ignore_stop_codons", ":", "vocab", "=", "CODONS", "else", ":", "vocab", "=", "CODONS", "+", "STOP_CODONS", ...
Input placeholder for array returned by `encodeCodon` Note: The seq_length is divided by 3 Wrapper for: `keras.layers.Input((seq_length / 3, 61 or 61), name=name, **kwargs)`
[ "Input", "placeholder", "for", "array", "returned", "by", "encodeCodon" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/layers.py#L40-L53
gagneurlab/concise
concise/layers.py
InputAA
def InputAA(seq_length, name=None, **kwargs): """Input placeholder for array returned by `encodeAA` Wrapper for: `keras.layers.Input((seq_length, 22), name=name, **kwargs)` """ return Input((seq_length, len(AMINO_ACIDS)), name=name, **kwargs)
python
def InputAA(seq_length, name=None, **kwargs): """Input placeholder for array returned by `encodeAA` Wrapper for: `keras.layers.Input((seq_length, 22), name=name, **kwargs)` """ return Input((seq_length, len(AMINO_ACIDS)), name=name, **kwargs)
[ "def", "InputAA", "(", "seq_length", ",", "name", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "Input", "(", "(", "seq_length", ",", "len", "(", "AMINO_ACIDS", ")", ")", ",", "name", "=", "name", ",", "*", "*", "kwargs", ")" ]
Input placeholder for array returned by `encodeAA` Wrapper for: `keras.layers.Input((seq_length, 22), name=name, **kwargs)`
[ "Input", "placeholder", "for", "array", "returned", "by", "encodeAA" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/layers.py#L56-L61
gagneurlab/concise
concise/layers.py
InputRNAStructure
def InputRNAStructure(seq_length, name=None, **kwargs): """Input placeholder for array returned by `encodeRNAStructure` Wrapper for: `keras.layers.Input((seq_length, 5), name=name, **kwargs)` """ return Input((seq_length, len(RNAplfold_PROFILES)), name=name, **kwargs)
python
def InputRNAStructure(seq_length, name=None, **kwargs): """Input placeholder for array returned by `encodeRNAStructure` Wrapper for: `keras.layers.Input((seq_length, 5), name=name, **kwargs)` """ return Input((seq_length, len(RNAplfold_PROFILES)), name=name, **kwargs)
[ "def", "InputRNAStructure", "(", "seq_length", ",", "name", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "Input", "(", "(", "seq_length", ",", "len", "(", "RNAplfold_PROFILES", ")", ")", ",", "name", "=", "name", ",", "*", "*", "kwargs", ...
Input placeholder for array returned by `encodeRNAStructure` Wrapper for: `keras.layers.Input((seq_length, 5), name=name, **kwargs)`
[ "Input", "placeholder", "for", "array", "returned", "by", "encodeRNAStructure" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/layers.py#L64-L69
gagneurlab/concise
concise/layers.py
InputSplines
def InputSplines(seq_length, n_bases=10, name=None, **kwargs): """Input placeholder for array returned by `encodeSplines` Wrapper for: `keras.layers.Input((seq_length, n_bases), name=name, **kwargs)` """ return Input((seq_length, n_bases), name=name, **kwargs)
python
def InputSplines(seq_length, n_bases=10, name=None, **kwargs): """Input placeholder for array returned by `encodeSplines` Wrapper for: `keras.layers.Input((seq_length, n_bases), name=name, **kwargs)` """ return Input((seq_length, n_bases), name=name, **kwargs)
[ "def", "InputSplines", "(", "seq_length", ",", "n_bases", "=", "10", ",", "name", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "Input", "(", "(", "seq_length", ",", "n_bases", ")", ",", "name", "=", "name", ",", "*", "*", "kwargs", ")"...
Input placeholder for array returned by `encodeSplines` Wrapper for: `keras.layers.Input((seq_length, n_bases), name=name, **kwargs)`
[ "Input", "placeholder", "for", "array", "returned", "by", "encodeSplines" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/layers.py#L73-L78
gagneurlab/concise
concise/layers.py
InputSplines1D
def InputSplines1D(seq_length, n_bases=10, name=None, **kwargs): """Input placeholder for array returned by `encodeSplines` Wrapper for: `keras.layers.Input((seq_length, n_bases), name=name, **kwargs)` """ return Input((seq_length, n_bases), name=name, **kwargs)
python
def InputSplines1D(seq_length, n_bases=10, name=None, **kwargs): """Input placeholder for array returned by `encodeSplines` Wrapper for: `keras.layers.Input((seq_length, n_bases), name=name, **kwargs)` """ return Input((seq_length, n_bases), name=name, **kwargs)
[ "def", "InputSplines1D", "(", "seq_length", ",", "n_bases", "=", "10", ",", "name", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "Input", "(", "(", "seq_length", ",", "n_bases", ")", ",", "name", "=", "name", ",", "*", "*", "kwargs", "...
Input placeholder for array returned by `encodeSplines` Wrapper for: `keras.layers.Input((seq_length, n_bases), name=name, **kwargs)`
[ "Input", "placeholder", "for", "array", "returned", "by", "encodeSplines" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/layers.py#L81-L86
gagneurlab/concise
concise/layers.py
InputDNAQuantity
def InputDNAQuantity(seq_length, n_features=1, name=None, **kwargs): """Convenience wrapper around `keras.layers.Input`: `Input((seq_length, n_features), name=name, **kwargs)` """ return Input((seq_length, n_features), name=name, **kwargs)
python
def InputDNAQuantity(seq_length, n_features=1, name=None, **kwargs): """Convenience wrapper around `keras.layers.Input`: `Input((seq_length, n_features), name=name, **kwargs)` """ return Input((seq_length, n_features), name=name, **kwargs)
[ "def", "InputDNAQuantity", "(", "seq_length", ",", "n_features", "=", "1", ",", "name", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "Input", "(", "(", "seq_length", ",", "n_features", ")", ",", "name", "=", "name", ",", "*", "*", "kwarg...
Convenience wrapper around `keras.layers.Input`: `Input((seq_length, n_features), name=name, **kwargs)`
[ "Convenience", "wrapper", "around", "keras", ".", "layers", ".", "Input", ":" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/layers.py#L90-L95
gagneurlab/concise
concise/layers.py
InputDNAQuantitySplines
def InputDNAQuantitySplines(seq_length, n_bases=10, name="DNASmoothPosition", **kwargs): """Convenience wrapper around keras.layers.Input: `Input((seq_length, n_bases), name=name, **kwargs)` """ return Input((seq_length, n_bases), name=name, **kwargs)
python
def InputDNAQuantitySplines(seq_length, n_bases=10, name="DNASmoothPosition", **kwargs): """Convenience wrapper around keras.layers.Input: `Input((seq_length, n_bases), name=name, **kwargs)` """ return Input((seq_length, n_bases), name=name, **kwargs)
[ "def", "InputDNAQuantitySplines", "(", "seq_length", ",", "n_bases", "=", "10", ",", "name", "=", "\"DNASmoothPosition\"", ",", "*", "*", "kwargs", ")", ":", "return", "Input", "(", "(", "seq_length", ",", "n_bases", ")", ",", "name", "=", "name", ",", "...
Convenience wrapper around keras.layers.Input: `Input((seq_length, n_bases), name=name, **kwargs)`
[ "Convenience", "wrapper", "around", "keras", ".", "layers", ".", "Input", ":" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/layers.py#L99-L104
gagneurlab/concise
concise/layers.py
ConvSequence._plot_weights_heatmap
def _plot_weights_heatmap(self, index=None, figsize=None, **kwargs): """Plot weights as a heatmap index = can be a particular index or a list of indicies **kwargs - additional arguments to concise.utils.plot.heatmap """ W = self.get_weights()[0] if index is None: ...
python
def _plot_weights_heatmap(self, index=None, figsize=None, **kwargs): """Plot weights as a heatmap index = can be a particular index or a list of indicies **kwargs - additional arguments to concise.utils.plot.heatmap """ W = self.get_weights()[0] if index is None: ...
[ "def", "_plot_weights_heatmap", "(", "self", ",", "index", "=", "None", ",", "figsize", "=", "None", ",", "*", "*", "kwargs", ")", ":", "W", "=", "self", ".", "get_weights", "(", ")", "[", "0", "]", "if", "index", "is", "None", ":", "index", "=", ...
Plot weights as a heatmap index = can be a particular index or a list of indicies **kwargs - additional arguments to concise.utils.plot.heatmap
[ "Plot", "weights", "as", "a", "heatmap" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/layers.py#L197-L210
gagneurlab/concise
concise/layers.py
ConvSequence._plot_weights_motif
def _plot_weights_motif(self, index, plot_type="motif_raw", background_probs=DEFAULT_BASE_BACKGROUND, ncol=1, figsize=None): """Index can only be a single int """ w_all = self.get_weights() if len(w_all...
python
def _plot_weights_motif(self, index, plot_type="motif_raw", background_probs=DEFAULT_BASE_BACKGROUND, ncol=1, figsize=None): """Index can only be a single int """ w_all = self.get_weights() if len(w_all...
[ "def", "_plot_weights_motif", "(", "self", ",", "index", ",", "plot_type", "=", "\"motif_raw\"", ",", "background_probs", "=", "DEFAULT_BASE_BACKGROUND", ",", "ncol", "=", "1", ",", "figsize", "=", "None", ")", ":", "w_all", "=", "self", ".", "get_weights", ...
Index can only be a single int
[ "Index", "can", "only", "be", "a", "single", "int" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/layers.py#L212-L243
gagneurlab/concise
concise/layers.py
ConvSequence.plot_weights
def plot_weights(self, index=None, plot_type="motif_raw", figsize=None, ncol=1, **kwargs): """Plot filters as heatmap or motifs index = can be a particular index or a list of indicies **kwargs - additional arguments to concise.utils.plot.heatmap """ if "heatmap" in self.AVAILAB...
python
def plot_weights(self, index=None, plot_type="motif_raw", figsize=None, ncol=1, **kwargs): """Plot filters as heatmap or motifs index = can be a particular index or a list of indicies **kwargs - additional arguments to concise.utils.plot.heatmap """ if "heatmap" in self.AVAILAB...
[ "def", "plot_weights", "(", "self", ",", "index", "=", "None", ",", "plot_type", "=", "\"motif_raw\"", ",", "figsize", "=", "None", ",", "ncol", "=", "1", ",", "*", "*", "kwargs", ")", ":", "if", "\"heatmap\"", "in", "self", ".", "AVAILABLE_PLOTS", "an...
Plot filters as heatmap or motifs index = can be a particular index or a list of indicies **kwargs - additional arguments to concise.utils.plot.heatmap
[ "Plot", "filters", "as", "heatmap", "or", "motifs" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/layers.py#L245-L257
gagneurlab/concise
concise/initializers.py
_check_pwm_list
def _check_pwm_list(pwm_list): """Check the input validity """ for pwm in pwm_list: if not isinstance(pwm, PWM): raise TypeError("element {0} of pwm_list is not of type PWM".format(pwm)) return True
python
def _check_pwm_list(pwm_list): """Check the input validity """ for pwm in pwm_list: if not isinstance(pwm, PWM): raise TypeError("element {0} of pwm_list is not of type PWM".format(pwm)) return True
[ "def", "_check_pwm_list", "(", "pwm_list", ")", ":", "for", "pwm", "in", "pwm_list", ":", "if", "not", "isinstance", "(", "pwm", ",", "PWM", ")", ":", "raise", "TypeError", "(", "\"element {0} of pwm_list is not of type PWM\"", ".", "format", "(", "pwm", ")", ...
Check the input validity
[ "Check", "the", "input", "validity" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/initializers.py#L22-L28
gagneurlab/concise
concise/initializers.py
_truncated_normal
def _truncated_normal(mean, stddev, seed=None, normalize=True, alpha=0.01): ''' Add noise with truncnorm from numpy. Bounded (0.001,0.999) ''' # within range () # provide entry to chose which adding noise way to ...
python
def _truncated_normal(mean, stddev, seed=None, normalize=True, alpha=0.01): ''' Add noise with truncnorm from numpy. Bounded (0.001,0.999) ''' # within range () # provide entry to chose which adding noise way to ...
[ "def", "_truncated_normal", "(", "mean", ",", "stddev", ",", "seed", "=", "None", ",", "normalize", "=", "True", ",", "alpha", "=", "0.01", ")", ":", "# within range ()", "# provide entry to chose which adding noise way to use", "if", "seed", "is", "not", "None", ...
Add noise with truncnorm from numpy. Bounded (0.001,0.999)
[ "Add", "noise", "with", "truncnorm", "from", "numpy", ".", "Bounded", "(", "0", ".", "001", "0", ".", "999", ")" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/initializers.py#L31-L54
gagneurlab/concise
concise/utils/plot.py
heatmap
def heatmap(w, vmin=None, vmax=None, diverge_color=False, ncol=1, plot_name=None, vocab=["A", "C", "G", "T"], figsize=(6, 2)): """Plot a heatmap from weight matrix w vmin, vmax = z axis range diverge_color = Should we use diverging colors? plot_name = plot_title vocab = voca...
python
def heatmap(w, vmin=None, vmax=None, diverge_color=False, ncol=1, plot_name=None, vocab=["A", "C", "G", "T"], figsize=(6, 2)): """Plot a heatmap from weight matrix w vmin, vmax = z axis range diverge_color = Should we use diverging colors? plot_name = plot_title vocab = voca...
[ "def", "heatmap", "(", "w", ",", "vmin", "=", "None", ",", "vmax", "=", "None", ",", "diverge_color", "=", "False", ",", "ncol", "=", "1", ",", "plot_name", "=", "None", ",", "vocab", "=", "[", "\"A\"", ",", "\"C\"", ",", "\"G\"", ",", "\"T\"", "...
Plot a heatmap from weight matrix w vmin, vmax = z axis range diverge_color = Should we use diverging colors? plot_name = plot_title vocab = vocabulary (corresponds to the first axis)
[ "Plot", "a", "heatmap", "from", "weight", "matrix", "w" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/utils/plot.py#L22-L89
gagneurlab/concise
concise/utils/plot.py
standardize_polygons_str
def standardize_polygons_str(data_str): """Given a POLYGON string, standardize the coordinates to a 1x1 grid. Input : data_str (taken from above) Output: tuple of polygon objects """ # find all of the polygons in the letter (for instance an A # needs to be constructed from 2 polygons) path_s...
python
def standardize_polygons_str(data_str): """Given a POLYGON string, standardize the coordinates to a 1x1 grid. Input : data_str (taken from above) Output: tuple of polygon objects """ # find all of the polygons in the letter (for instance an A # needs to be constructed from 2 polygons) path_s...
[ "def", "standardize_polygons_str", "(", "data_str", ")", ":", "# find all of the polygons in the letter (for instance an A", "# needs to be constructed from 2 polygons)", "path_strs", "=", "re", ".", "findall", "(", "\"\\(\\(([^\\)]+?)\\)\\)\"", ",", "data_str", ".", "strip", "...
Given a POLYGON string, standardize the coordinates to a 1x1 grid. Input : data_str (taken from above) Output: tuple of polygon objects
[ "Given", "a", "POLYGON", "string", "standardize", "the", "coordinates", "to", "a", "1x1", "grid", ".", "Input", ":", "data_str", "(", "taken", "from", "above", ")", "Output", ":", "tuple", "of", "polygon", "objects" ]
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/utils/plot.py#L98-L126