repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
sdispater/eloquent
eloquent/orm/relations/has_many_through.py
HasManyThrough._set_join
def _set_join(self, query=None): """ Set the join clause for the query. """ if not query: query = self._query foreign_key = '%s.%s' % (self._related.get_table(), self._second_key) query.join(self._parent.get_table(), self.get_qualified_parent_key_name(), '='...
python
def _set_join(self, query=None): """ Set the join clause for the query. """ if not query: query = self._query foreign_key = '%s.%s' % (self._related.get_table(), self._second_key) query.join(self._parent.get_table(), self.get_qualified_parent_key_name(), '='...
[ "def", "_set_join", "(", "self", ",", "query", "=", "None", ")", ":", "if", "not", "query", ":", "query", "=", "self", ".", "_query", "foreign_key", "=", "'%s.%s'", "%", "(", "self", ".", "_related", ".", "get_table", "(", ")", ",", "self", ".", "_...
Set the join clause for the query.
[ "Set", "the", "join", "clause", "for", "the", "query", "." ]
0638b688d5fd0c1a46b7471dd465eeb4c2f84666
https://github.com/sdispater/eloquent/blob/0638b688d5fd0c1a46b7471dd465eeb4c2f84666/eloquent/orm/relations/has_many_through.py#L61-L70
train
YeoLab/anchor
anchor/simulate.py
plot_best_worst_fits
def plot_best_worst_fits(assignments_df, data, modality_col='Modality', score='$\log_2 K$'): """Violinplots of the highest and lowest scoring of each modality""" ncols = 2 nrows = len(assignments_df.groupby(modality_col).groups.keys()) fig, axes = plt.subplots(nrows=nrows, ncol...
python
def plot_best_worst_fits(assignments_df, data, modality_col='Modality', score='$\log_2 K$'): """Violinplots of the highest and lowest scoring of each modality""" ncols = 2 nrows = len(assignments_df.groupby(modality_col).groups.keys()) fig, axes = plt.subplots(nrows=nrows, ncol...
[ "def", "plot_best_worst_fits", "(", "assignments_df", ",", "data", ",", "modality_col", "=", "'Modality'", ",", "score", "=", "'$\\log_2 K$'", ")", ":", "ncols", "=", "2", "nrows", "=", "len", "(", "assignments_df", ".", "groupby", "(", "modality_col", ")", ...
Violinplots of the highest and lowest scoring of each modality
[ "Violinplots", "of", "the", "highest", "and", "lowest", "scoring", "of", "each", "modality" ]
1f9c9d6d30235b1e77b945e6ef01db5a0e55d53a
https://github.com/YeoLab/anchor/blob/1f9c9d6d30235b1e77b945e6ef01db5a0e55d53a/anchor/simulate.py#L158-L194
train
YeoLab/anchor
anchor/visualize.py
violinplot
def violinplot(x=None, y=None, data=None, bw=0.2, scale='width', inner=None, ax=None, **kwargs): """Wrapper around Seaborn's Violinplot specifically for [0, 1] ranged data What's different: - bw = 0.2: Sets bandwidth to be small and the same between datasets - scale = 'width': Sets the w...
python
def violinplot(x=None, y=None, data=None, bw=0.2, scale='width', inner=None, ax=None, **kwargs): """Wrapper around Seaborn's Violinplot specifically for [0, 1] ranged data What's different: - bw = 0.2: Sets bandwidth to be small and the same between datasets - scale = 'width': Sets the w...
[ "def", "violinplot", "(", "x", "=", "None", ",", "y", "=", "None", ",", "data", "=", "None", ",", "bw", "=", "0.2", ",", "scale", "=", "'width'", ",", "inner", "=", "None", ",", "ax", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "ax"...
Wrapper around Seaborn's Violinplot specifically for [0, 1] ranged data What's different: - bw = 0.2: Sets bandwidth to be small and the same between datasets - scale = 'width': Sets the width of all violinplots to be the same - inner = None: Don't plot a boxplot or points inside the violinplot
[ "Wrapper", "around", "Seaborn", "s", "Violinplot", "specifically", "for", "[", "0", "1", "]", "ranged", "data" ]
1f9c9d6d30235b1e77b945e6ef01db5a0e55d53a
https://github.com/YeoLab/anchor/blob/1f9c9d6d30235b1e77b945e6ef01db5a0e55d53a/anchor/visualize.py#L33-L48
train
YeoLab/anchor
anchor/visualize.py
ModalitiesViz.bar
def bar(self, counts, phenotype_to_color=None, ax=None, percentages=True): """Draw barplots grouped by modality of modality percentage per group Parameters ---------- Returns ------- Raises ------ """ if percentages: counts = 100 ...
python
def bar(self, counts, phenotype_to_color=None, ax=None, percentages=True): """Draw barplots grouped by modality of modality percentage per group Parameters ---------- Returns ------- Raises ------ """ if percentages: counts = 100 ...
[ "def", "bar", "(", "self", ",", "counts", ",", "phenotype_to_color", "=", "None", ",", "ax", "=", "None", ",", "percentages", "=", "True", ")", ":", "if", "percentages", ":", "counts", "=", "100", "*", "(", "counts", ".", "T", "/", "counts", ".", "...
Draw barplots grouped by modality of modality percentage per group Parameters ---------- Returns ------- Raises ------
[ "Draw", "barplots", "grouped", "by", "modality", "of", "modality", "percentage", "per", "group" ]
1f9c9d6d30235b1e77b945e6ef01db5a0e55d53a
https://github.com/YeoLab/anchor/blob/1f9c9d6d30235b1e77b945e6ef01db5a0e55d53a/anchor/visualize.py#L110-L149
train
YeoLab/anchor
anchor/visualize.py
ModalitiesViz.event_estimation
def event_estimation(self, event, logliks, logsumexps, renamed=''): """Show the values underlying bayesian modality estimations of an event Parameters ---------- Returns ------- Raises ------ """ plotter = _ModelLoglikPlotter() plotter...
python
def event_estimation(self, event, logliks, logsumexps, renamed=''): """Show the values underlying bayesian modality estimations of an event Parameters ---------- Returns ------- Raises ------ """ plotter = _ModelLoglikPlotter() plotter...
[ "def", "event_estimation", "(", "self", ",", "event", ",", "logliks", ",", "logsumexps", ",", "renamed", "=", "''", ")", ":", "plotter", "=", "_ModelLoglikPlotter", "(", ")", "plotter", ".", "plot", "(", "event", ",", "logliks", ",", "logsumexps", ",", "...
Show the values underlying bayesian modality estimations of an event Parameters ---------- Returns ------- Raises ------
[ "Show", "the", "values", "underlying", "bayesian", "modality", "estimations", "of", "an", "event" ]
1f9c9d6d30235b1e77b945e6ef01db5a0e55d53a
https://github.com/YeoLab/anchor/blob/1f9c9d6d30235b1e77b945e6ef01db5a0e55d53a/anchor/visualize.py#L151-L168
train
YeoLab/anchor
anchor/binning.py
BinnedModalities.predict
def predict(self, fitted): """Assign the most likely modality given the fitted data Parameters ---------- fitted : pandas.DataFrame or pandas.Series Either a (n_modalities, features) DatFrame or (n_modalities,) Series, either of which will return the best modalit...
python
def predict(self, fitted): """Assign the most likely modality given the fitted data Parameters ---------- fitted : pandas.DataFrame or pandas.Series Either a (n_modalities, features) DatFrame or (n_modalities,) Series, either of which will return the best modalit...
[ "def", "predict", "(", "self", ",", "fitted", ")", ":", "if", "fitted", ".", "shape", "[", "0", "]", "!=", "len", "(", "self", ".", "modalities", ")", ":", "raise", "ValueError", "(", "\"This data doesn't look like it had the distance \"", "\"between it and the ...
Assign the most likely modality given the fitted data Parameters ---------- fitted : pandas.DataFrame or pandas.Series Either a (n_modalities, features) DatFrame or (n_modalities,) Series, either of which will return the best modality for each feature.
[ "Assign", "the", "most", "likely", "modality", "given", "the", "fitted", "data" ]
1f9c9d6d30235b1e77b945e6ef01db5a0e55d53a
https://github.com/YeoLab/anchor/blob/1f9c9d6d30235b1e77b945e6ef01db5a0e55d53a/anchor/binning.py#L37-L50
train
YeoLab/anchor
anchor/model.py
ModalityModel.logliks
def logliks(self, x): """Calculate log-likelihood of a feature x for each model Converts all values that are exactly 1 or exactly 0 to 0.999 and 0.001 because they are out of range of the beta distribution. Parameters ---------- x : numpy.array-like A single...
python
def logliks(self, x): """Calculate log-likelihood of a feature x for each model Converts all values that are exactly 1 or exactly 0 to 0.999 and 0.001 because they are out of range of the beta distribution. Parameters ---------- x : numpy.array-like A single...
[ "def", "logliks", "(", "self", ",", "x", ")", ":", "x", "=", "x", ".", "copy", "(", ")", "# Replace exactly 0 and exactly 1 values with a very small number", "# (machine epsilon, the smallest number that this computer is capable", "# of storing) because 0 and 1 are not in the Beta ...
Calculate log-likelihood of a feature x for each model Converts all values that are exactly 1 or exactly 0 to 0.999 and 0.001 because they are out of range of the beta distribution. Parameters ---------- x : numpy.array-like A single vector to estimate the log-likel...
[ "Calculate", "log", "-", "likelihood", "of", "a", "feature", "x", "for", "each", "model" ]
1f9c9d6d30235b1e77b945e6ef01db5a0e55d53a
https://github.com/YeoLab/anchor/blob/1f9c9d6d30235b1e77b945e6ef01db5a0e55d53a/anchor/model.py#L71-L97
train
YeoLab/anchor
anchor/model.py
ModalityModel.nice_number_string
def nice_number_string(number, decimal_places=2): """Convert floats to either integers or a nice looking fraction""" if number == np.round(number): return str(int(number)) elif number < 1 and number > 0: inverse = 1 / number if int(inverse) == np.round(inverse...
python
def nice_number_string(number, decimal_places=2): """Convert floats to either integers or a nice looking fraction""" if number == np.round(number): return str(int(number)) elif number < 1 and number > 0: inverse = 1 / number if int(inverse) == np.round(inverse...
[ "def", "nice_number_string", "(", "number", ",", "decimal_places", "=", "2", ")", ":", "if", "number", "==", "np", ".", "round", "(", "number", ")", ":", "return", "str", "(", "int", "(", "number", ")", ")", "elif", "number", "<", "1", "and", "number...
Convert floats to either integers or a nice looking fraction
[ "Convert", "floats", "to", "either", "integers", "or", "a", "nice", "looking", "fraction" ]
1f9c9d6d30235b1e77b945e6ef01db5a0e55d53a
https://github.com/YeoLab/anchor/blob/1f9c9d6d30235b1e77b945e6ef01db5a0e55d53a/anchor/model.py#L119-L129
train
YeoLab/anchor
anchor/model.py
ModalityModel.violinplot
def violinplot(self, n=1000, **kwargs): """Plot violins of each distribution in the model family Parameters ---------- n : int Number of random variables to generate kwargs : dict or keywords Any keyword arguments to seaborn.violinplot Returns ...
python
def violinplot(self, n=1000, **kwargs): """Plot violins of each distribution in the model family Parameters ---------- n : int Number of random variables to generate kwargs : dict or keywords Any keyword arguments to seaborn.violinplot Returns ...
[ "def", "violinplot", "(", "self", ",", "n", "=", "1000", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "setdefault", "(", "'palette'", ",", "'Purples'", ")", "dfs", "=", "[", "]", "for", "rv", "in", "self", ".", "rvs", ":", "psi", "=", "rv", ...
Plot violins of each distribution in the model family Parameters ---------- n : int Number of random variables to generate kwargs : dict or keywords Any keyword arguments to seaborn.violinplot Returns ------- ax : matplotlib.Axes object ...
[ "Plot", "violins", "of", "each", "distribution", "in", "the", "model", "family" ]
1f9c9d6d30235b1e77b945e6ef01db5a0e55d53a
https://github.com/YeoLab/anchor/blob/1f9c9d6d30235b1e77b945e6ef01db5a0e55d53a/anchor/model.py#L131-L169
train
YeoLab/anchor
anchor/bayesian.py
BayesianModalities._single_feature_logliks_one_step
def _single_feature_logliks_one_step(self, feature, models): """Get log-likelihood of models at each parameterization for given data Parameters ---------- feature : pandas.Series Percent-based values of a single feature. May contain NAs, but only non-NA values ar...
python
def _single_feature_logliks_one_step(self, feature, models): """Get log-likelihood of models at each parameterization for given data Parameters ---------- feature : pandas.Series Percent-based values of a single feature. May contain NAs, but only non-NA values ar...
[ "def", "_single_feature_logliks_one_step", "(", "self", ",", "feature", ",", "models", ")", ":", "x_non_na", "=", "feature", "[", "~", "feature", ".", "isnull", "(", ")", "]", "if", "x_non_na", ".", "empty", ":", "return", "pd", ".", "DataFrame", "(", ")...
Get log-likelihood of models at each parameterization for given data Parameters ---------- feature : pandas.Series Percent-based values of a single feature. May contain NAs, but only non-NA values are used. Returns ------- logliks : pandas.DataFr...
[ "Get", "log", "-", "likelihood", "of", "models", "at", "each", "parameterization", "for", "given", "data" ]
1f9c9d6d30235b1e77b945e6ef01db5a0e55d53a
https://github.com/YeoLab/anchor/blob/1f9c9d6d30235b1e77b945e6ef01db5a0e55d53a/anchor/bayesian.py#L54-L77
train
YeoLab/anchor
anchor/bayesian.py
BayesianModalities.fit
def fit(self, data): """Get the modality assignments of each splicing event in the data Parameters ---------- data : pandas.DataFrame A (n_samples, n_events) dataframe of splicing events' PSI scores. Must be psi scores which range from 0 to 1 Returns ...
python
def fit(self, data): """Get the modality assignments of each splicing event in the data Parameters ---------- data : pandas.DataFrame A (n_samples, n_events) dataframe of splicing events' PSI scores. Must be psi scores which range from 0 to 1 Returns ...
[ "def", "fit", "(", "self", ",", "data", ")", ":", "self", ".", "assert_less_than_or_equal_1", "(", "data", ".", "values", ".", "flat", ")", "self", ".", "assert_non_negative", "(", "data", ".", "values", ".", "flat", ")", "if", "isinstance", "(", "data",...
Get the modality assignments of each splicing event in the data Parameters ---------- data : pandas.DataFrame A (n_samples, n_events) dataframe of splicing events' PSI scores. Must be psi scores which range from 0 to 1 Returns ------- log2_bayes_...
[ "Get", "the", "modality", "assignments", "of", "each", "splicing", "event", "in", "the", "data" ]
1f9c9d6d30235b1e77b945e6ef01db5a0e55d53a
https://github.com/YeoLab/anchor/blob/1f9c9d6d30235b1e77b945e6ef01db5a0e55d53a/anchor/bayesian.py#L111-L139
train
YeoLab/anchor
anchor/bayesian.py
BayesianModalities.predict
def predict(self, log2_bayes_factors, reset_index=False): """Guess the most likely modality for each event For each event that has at least one non-NA value, if no modalilites have logsumexp'd logliks greater than the log Bayes factor threshold, then they are assigned the 'multimodal' m...
python
def predict(self, log2_bayes_factors, reset_index=False): """Guess the most likely modality for each event For each event that has at least one non-NA value, if no modalilites have logsumexp'd logliks greater than the log Bayes factor threshold, then they are assigned the 'multimodal' m...
[ "def", "predict", "(", "self", ",", "log2_bayes_factors", ",", "reset_index", "=", "False", ")", ":", "if", "reset_index", ":", "x", "=", "log2_bayes_factors", ".", "reset_index", "(", "level", "=", "0", ",", "drop", "=", "True", ")", "else", ":", "x", ...
Guess the most likely modality for each event For each event that has at least one non-NA value, if no modalilites have logsumexp'd logliks greater than the log Bayes factor threshold, then they are assigned the 'multimodal' modality, because we cannot reject the null hypothesis that th...
[ "Guess", "the", "most", "likely", "modality", "for", "each", "event" ]
1f9c9d6d30235b1e77b945e6ef01db5a0e55d53a
https://github.com/YeoLab/anchor/blob/1f9c9d6d30235b1e77b945e6ef01db5a0e55d53a/anchor/bayesian.py#L141-L178
train
YeoLab/anchor
anchor/bayesian.py
BayesianModalities.single_feature_logliks
def single_feature_logliks(self, feature): """Calculate log-likelihoods of each modality's parameterization Used for plotting the estimates of a single feature Parameters ---------- featre : pandas.Series A single feature's values. All values must range from 0 to 1....
python
def single_feature_logliks(self, feature): """Calculate log-likelihoods of each modality's parameterization Used for plotting the estimates of a single feature Parameters ---------- featre : pandas.Series A single feature's values. All values must range from 0 to 1....
[ "def", "single_feature_logliks", "(", "self", ",", "feature", ")", ":", "self", ".", "assert_less_than_or_equal_1", "(", "feature", ".", "values", ")", "self", ".", "assert_non_negative", "(", "feature", ".", "values", ")", "logliks", "=", "self", ".", "_singl...
Calculate log-likelihoods of each modality's parameterization Used for plotting the estimates of a single feature Parameters ---------- featre : pandas.Series A single feature's values. All values must range from 0 to 1. Returns ------- logliks : pa...
[ "Calculate", "log", "-", "likelihoods", "of", "each", "modality", "s", "parameterization" ]
1f9c9d6d30235b1e77b945e6ef01db5a0e55d53a
https://github.com/YeoLab/anchor/blob/1f9c9d6d30235b1e77b945e6ef01db5a0e55d53a/anchor/bayesian.py#L184-L218
train
YeoLab/anchor
anchor/bayesian.py
BayesianModalities.single_feature_fit
def single_feature_fit(self, feature): """Get the log2 bayes factor of the fit for each modality""" if np.isfinite(feature).sum() == 0: series = pd.Series(index=MODALITY_ORDER) else: logbf_one_param = pd.Series( {k: v.logsumexp_logliks(feature) for ...
python
def single_feature_fit(self, feature): """Get the log2 bayes factor of the fit for each modality""" if np.isfinite(feature).sum() == 0: series = pd.Series(index=MODALITY_ORDER) else: logbf_one_param = pd.Series( {k: v.logsumexp_logliks(feature) for ...
[ "def", "single_feature_fit", "(", "self", ",", "feature", ")", ":", "if", "np", ".", "isfinite", "(", "feature", ")", ".", "sum", "(", ")", "==", "0", ":", "series", "=", "pd", ".", "Series", "(", "index", "=", "MODALITY_ORDER", ")", "else", ":", "...
Get the log2 bayes factor of the fit for each modality
[ "Get", "the", "log2", "bayes", "factor", "of", "the", "fit", "for", "each", "modality" ]
1f9c9d6d30235b1e77b945e6ef01db5a0e55d53a
https://github.com/YeoLab/anchor/blob/1f9c9d6d30235b1e77b945e6ef01db5a0e55d53a/anchor/bayesian.py#L225-L245
train
YeoLab/anchor
anchor/bayesian.py
BayesianModalities.violinplot
def violinplot(self, n=1000, figsize=None, **kwargs): r"""Visualize all modality family members with parameters Use violinplots to visualize distributions of modality family members Parameters ---------- n : int Number of random variables to generate kwargs ...
python
def violinplot(self, n=1000, figsize=None, **kwargs): r"""Visualize all modality family members with parameters Use violinplots to visualize distributions of modality family members Parameters ---------- n : int Number of random variables to generate kwargs ...
[ "def", "violinplot", "(", "self", ",", "n", "=", "1000", ",", "figsize", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "figsize", "is", "None", ":", "nrows", "=", "len", "(", "self", ".", "models", ")", "width", "=", "max", "(", "len", ...
r"""Visualize all modality family members with parameters Use violinplots to visualize distributions of modality family members Parameters ---------- n : int Number of random variables to generate kwargs : dict or keywords Any keyword arguments to seabor...
[ "r", "Visualize", "all", "modality", "family", "members", "with", "parameters" ]
1f9c9d6d30235b1e77b945e6ef01db5a0e55d53a
https://github.com/YeoLab/anchor/blob/1f9c9d6d30235b1e77b945e6ef01db5a0e55d53a/anchor/bayesian.py#L258-L291
train
YeoLab/anchor
anchor/infotheory.py
bin_range_strings
def bin_range_strings(bins, fmt=':g'): """Given a list of bins, make a list of strings of those bin ranges Parameters ---------- bins : list_like List of anything, usually values of bin edges Returns ------- bin_ranges : list List of bin ranges >>> bin_range_strings((0...
python
def bin_range_strings(bins, fmt=':g'): """Given a list of bins, make a list of strings of those bin ranges Parameters ---------- bins : list_like List of anything, usually values of bin edges Returns ------- bin_ranges : list List of bin ranges >>> bin_range_strings((0...
[ "def", "bin_range_strings", "(", "bins", ",", "fmt", "=", "':g'", ")", ":", "return", "[", "(", "'{'", "+", "fmt", "+", "'}-{'", "+", "fmt", "+", "'}'", ")", ".", "format", "(", "i", ",", "j", ")", "for", "i", ",", "j", "in", "zip", "(", "bin...
Given a list of bins, make a list of strings of those bin ranges Parameters ---------- bins : list_like List of anything, usually values of bin edges Returns ------- bin_ranges : list List of bin ranges >>> bin_range_strings((0, 0.5, 1)) ['0-0.5', '0.5-1']
[ "Given", "a", "list", "of", "bins", "make", "a", "list", "of", "strings", "of", "those", "bin", "ranges" ]
1f9c9d6d30235b1e77b945e6ef01db5a0e55d53a
https://github.com/YeoLab/anchor/blob/1f9c9d6d30235b1e77b945e6ef01db5a0e55d53a/anchor/infotheory.py#L12-L29
train
YeoLab/anchor
anchor/infotheory.py
binify
def binify(data, bins): """Makes a histogram of each column the provided binsize Parameters ---------- data : pandas.DataFrame A samples x features dataframe. Each feature (column) will be binned into the provided bins bins : iterable Bins you would like to use for this data...
python
def binify(data, bins): """Makes a histogram of each column the provided binsize Parameters ---------- data : pandas.DataFrame A samples x features dataframe. Each feature (column) will be binned into the provided bins bins : iterable Bins you would like to use for this data...
[ "def", "binify", "(", "data", ",", "bins", ")", ":", "if", "bins", "is", "None", ":", "raise", "ValueError", "(", "'Must specify \"bins\"'", ")", "if", "isinstance", "(", "data", ",", "pd", ".", "DataFrame", ")", ":", "binned", "=", "data", ".", "apply...
Makes a histogram of each column the provided binsize Parameters ---------- data : pandas.DataFrame A samples x features dataframe. Each feature (column) will be binned into the provided bins bins : iterable Bins you would like to use for this data. Must include the final bin ...
[ "Makes", "a", "histogram", "of", "each", "column", "the", "provided", "binsize" ]
1f9c9d6d30235b1e77b945e6ef01db5a0e55d53a
https://github.com/YeoLab/anchor/blob/1f9c9d6d30235b1e77b945e6ef01db5a0e55d53a/anchor/infotheory.py#L46-L77
train
YeoLab/anchor
anchor/infotheory.py
kld
def kld(p, q): """Kullback-Leiber divergence of two probability distributions pandas dataframes, p and q Parameters ---------- p : pandas.DataFrame An nbins x features DataFrame, or (nbins,) Series q : pandas.DataFrame An nbins x features DataFrame, or (nbins,) Series Retur...
python
def kld(p, q): """Kullback-Leiber divergence of two probability distributions pandas dataframes, p and q Parameters ---------- p : pandas.DataFrame An nbins x features DataFrame, or (nbins,) Series q : pandas.DataFrame An nbins x features DataFrame, or (nbins,) Series Retur...
[ "def", "kld", "(", "p", ",", "q", ")", ":", "try", ":", "_check_prob_dist", "(", "p", ")", "_check_prob_dist", "(", "q", ")", "except", "ValueError", ":", "return", "np", ".", "nan", "# If one of them is zero, then the other should be considered to be 0.", "# In t...
Kullback-Leiber divergence of two probability distributions pandas dataframes, p and q Parameters ---------- p : pandas.DataFrame An nbins x features DataFrame, or (nbins,) Series q : pandas.DataFrame An nbins x features DataFrame, or (nbins,) Series Returns ------- kld...
[ "Kullback", "-", "Leiber", "divergence", "of", "two", "probability", "distributions", "pandas", "dataframes", "p", "and", "q" ]
1f9c9d6d30235b1e77b945e6ef01db5a0e55d53a
https://github.com/YeoLab/anchor/blob/1f9c9d6d30235b1e77b945e6ef01db5a0e55d53a/anchor/infotheory.py#L80-L119
train
YeoLab/anchor
anchor/infotheory.py
jsd
def jsd(p, q): """Finds the per-column JSD between dataframes p and q Jensen-Shannon divergence of two probability distrubutions pandas dataframes, p and q. These distributions are usually created by running binify() on the dataframe. Parameters ---------- p : pandas.DataFrame An n...
python
def jsd(p, q): """Finds the per-column JSD between dataframes p and q Jensen-Shannon divergence of two probability distrubutions pandas dataframes, p and q. These distributions are usually created by running binify() on the dataframe. Parameters ---------- p : pandas.DataFrame An n...
[ "def", "jsd", "(", "p", ",", "q", ")", ":", "try", ":", "_check_prob_dist", "(", "p", ")", "_check_prob_dist", "(", "q", ")", "except", "ValueError", ":", "return", "np", ".", "nan", "weight", "=", "0.5", "m", "=", "weight", "*", "(", "p", "+", "...
Finds the per-column JSD between dataframes p and q Jensen-Shannon divergence of two probability distrubutions pandas dataframes, p and q. These distributions are usually created by running binify() on the dataframe. Parameters ---------- p : pandas.DataFrame An nbins x features DataFr...
[ "Finds", "the", "per", "-", "column", "JSD", "between", "dataframes", "p", "and", "q" ]
1f9c9d6d30235b1e77b945e6ef01db5a0e55d53a
https://github.com/YeoLab/anchor/blob/1f9c9d6d30235b1e77b945e6ef01db5a0e55d53a/anchor/infotheory.py#L122-L157
train
YeoLab/anchor
anchor/infotheory.py
entropy
def entropy(binned, base=2): """Find the entropy of each column of a dataframe Parameters ---------- binned : pandas.DataFrame A nbins x features DataFrame of probability distributions, where each column sums to 1 base : numeric The log-base of the entropy. Default is 2, so ...
python
def entropy(binned, base=2): """Find the entropy of each column of a dataframe Parameters ---------- binned : pandas.DataFrame A nbins x features DataFrame of probability distributions, where each column sums to 1 base : numeric The log-base of the entropy. Default is 2, so ...
[ "def", "entropy", "(", "binned", ",", "base", "=", "2", ")", ":", "try", ":", "_check_prob_dist", "(", "binned", ")", "except", "ValueError", ":", "np", ".", "nan", "return", "-", "(", "(", "np", ".", "log", "(", "binned", ")", "/", "np", ".", "l...
Find the entropy of each column of a dataframe Parameters ---------- binned : pandas.DataFrame A nbins x features DataFrame of probability distributions, where each column sums to 1 base : numeric The log-base of the entropy. Default is 2, so the resulting entropy is in ...
[ "Find", "the", "entropy", "of", "each", "column", "of", "a", "dataframe" ]
1f9c9d6d30235b1e77b945e6ef01db5a0e55d53a
https://github.com/YeoLab/anchor/blob/1f9c9d6d30235b1e77b945e6ef01db5a0e55d53a/anchor/infotheory.py#L160-L187
train
YeoLab/anchor
anchor/infotheory.py
binify_and_jsd
def binify_and_jsd(df1, df2, bins, pair=None): """Binify and calculate jensen-shannon divergence between two dataframes Parameters ---------- df1, df2 : pandas.DataFrames Dataframes to calculate JSD between columns of. Must have overlapping column names bins : array-like Bin...
python
def binify_and_jsd(df1, df2, bins, pair=None): """Binify and calculate jensen-shannon divergence between two dataframes Parameters ---------- df1, df2 : pandas.DataFrames Dataframes to calculate JSD between columns of. Must have overlapping column names bins : array-like Bin...
[ "def", "binify_and_jsd", "(", "df1", ",", "df2", ",", "bins", ",", "pair", "=", "None", ")", ":", "binned1", "=", "binify", "(", "df1", ",", "bins", "=", "bins", ")", ".", "dropna", "(", "how", "=", "'all'", ",", "axis", "=", "1", ")", "binned2",...
Binify and calculate jensen-shannon divergence between two dataframes Parameters ---------- df1, df2 : pandas.DataFrames Dataframes to calculate JSD between columns of. Must have overlapping column names bins : array-like Bins to use for transforming df{1,2} into probability dis...
[ "Binify", "and", "calculate", "jensen", "-", "shannon", "divergence", "between", "two", "dataframes" ]
1f9c9d6d30235b1e77b945e6ef01db5a0e55d53a
https://github.com/YeoLab/anchor/blob/1f9c9d6d30235b1e77b945e6ef01db5a0e55d53a/anchor/infotheory.py#L190-L215
train
YeoLab/anchor
anchor/infotheory.py
cross_phenotype_jsd
def cross_phenotype_jsd(data, groupby, bins, n_iter=100): """Jensen-Shannon divergence of features across phenotypes Parameters ---------- data : pandas.DataFrame A (n_samples, n_features) Dataframe groupby : mappable A samples to phenotypes mapping n_iter : int Number o...
python
def cross_phenotype_jsd(data, groupby, bins, n_iter=100): """Jensen-Shannon divergence of features across phenotypes Parameters ---------- data : pandas.DataFrame A (n_samples, n_features) Dataframe groupby : mappable A samples to phenotypes mapping n_iter : int Number o...
[ "def", "cross_phenotype_jsd", "(", "data", ",", "groupby", ",", "bins", ",", "n_iter", "=", "100", ")", ":", "grouped", "=", "data", ".", "groupby", "(", "groupby", ")", "jsds", "=", "[", "]", "seen", "=", "set", "(", "[", "]", ")", "for", "phenoty...
Jensen-Shannon divergence of features across phenotypes Parameters ---------- data : pandas.DataFrame A (n_samples, n_features) Dataframe groupby : mappable A samples to phenotypes mapping n_iter : int Number of bootstrap resampling iterations to perform for the with...
[ "Jensen", "-", "Shannon", "divergence", "of", "features", "across", "phenotypes" ]
1f9c9d6d30235b1e77b945e6ef01db5a0e55d53a
https://github.com/YeoLab/anchor/blob/1f9c9d6d30235b1e77b945e6ef01db5a0e55d53a/anchor/infotheory.py#L218-L266
train
YeoLab/anchor
anchor/infotheory.py
jsd_df_to_2d
def jsd_df_to_2d(jsd_df): """Transform a tall JSD dataframe to a square matrix of mean JSDs Parameters ---------- jsd_df : pandas.DataFrame A (n_features, n_phenotypes^2) dataframe of the JSD between each feature between and within phenotypes Returns ------- jsd_2d : pandas...
python
def jsd_df_to_2d(jsd_df): """Transform a tall JSD dataframe to a square matrix of mean JSDs Parameters ---------- jsd_df : pandas.DataFrame A (n_features, n_phenotypes^2) dataframe of the JSD between each feature between and within phenotypes Returns ------- jsd_2d : pandas...
[ "def", "jsd_df_to_2d", "(", "jsd_df", ")", ":", "jsd_2d", "=", "jsd_df", ".", "mean", "(", ")", ".", "reset_index", "(", ")", "jsd_2d", "=", "jsd_2d", ".", "rename", "(", "columns", "=", "{", "'level_0'", ":", "'phenotype1'", ",", "'level_1'", ":", "'p...
Transform a tall JSD dataframe to a square matrix of mean JSDs Parameters ---------- jsd_df : pandas.DataFrame A (n_features, n_phenotypes^2) dataframe of the JSD between each feature between and within phenotypes Returns ------- jsd_2d : pandas.DataFrame A (n_phenotype...
[ "Transform", "a", "tall", "JSD", "dataframe", "to", "a", "square", "matrix", "of", "mean", "JSDs" ]
1f9c9d6d30235b1e77b945e6ef01db5a0e55d53a
https://github.com/YeoLab/anchor/blob/1f9c9d6d30235b1e77b945e6ef01db5a0e55d53a/anchor/infotheory.py#L269-L289
train
orweis/winpcapy
winpcapy/winpcapy.py
WinPcap.run
def run(self, callback=None, limit=0): """ Start pcap's loop over the interface, calling the given callback for each packet :param callback: a function receiving (win_pcap, param, header, pkt_data) for each packet intercepted :param limit: how many packets to capture (A value of -1 or 0 ...
python
def run(self, callback=None, limit=0): """ Start pcap's loop over the interface, calling the given callback for each packet :param callback: a function receiving (win_pcap, param, header, pkt_data) for each packet intercepted :param limit: how many packets to capture (A value of -1 or 0 ...
[ "def", "run", "(", "self", ",", "callback", "=", "None", ",", "limit", "=", "0", ")", ":", "if", "self", ".", "_handle", "is", "None", ":", "raise", "self", ".", "DeviceIsNotOpen", "(", ")", "# Set new callback", "self", ".", "_callback", "=", "callbac...
Start pcap's loop over the interface, calling the given callback for each packet :param callback: a function receiving (win_pcap, param, header, pkt_data) for each packet intercepted :param limit: how many packets to capture (A value of -1 or 0 is equivalent to infinity)
[ "Start", "pcap", "s", "loop", "over", "the", "interface", "calling", "the", "given", "callback", "for", "each", "packet", ":", "param", "callback", ":", "a", "function", "receiving", "(", "win_pcap", "param", "header", "pkt_data", ")", "for", "each", "packet...
47ddb7f34de865c7ff6391c73b36b3af9a595158
https://github.com/orweis/winpcapy/blob/47ddb7f34de865c7ff6391c73b36b3af9a595158/winpcapy/winpcapy.py#L120-L131
train
orweis/winpcapy
winpcapy/winpcapy.py
WinPcap.send
def send(self, packet_buffer): """ send a buffer as a packet to the network interface :param packet_buffer: buffer to send (length shouldn't exceed MAX_INT) """ if self._handle is None: raise self.DeviceIsNotOpen() buffer_length = len(packet_buffer) bu...
python
def send(self, packet_buffer): """ send a buffer as a packet to the network interface :param packet_buffer: buffer to send (length shouldn't exceed MAX_INT) """ if self._handle is None: raise self.DeviceIsNotOpen() buffer_length = len(packet_buffer) bu...
[ "def", "send", "(", "self", ",", "packet_buffer", ")", ":", "if", "self", ".", "_handle", "is", "None", ":", "raise", "self", ".", "DeviceIsNotOpen", "(", ")", "buffer_length", "=", "len", "(", "packet_buffer", ")", "buf_send", "=", "ctypes", ".", "cast"...
send a buffer as a packet to the network interface :param packet_buffer: buffer to send (length shouldn't exceed MAX_INT)
[ "send", "a", "buffer", "as", "a", "packet", "to", "the", "network", "interface", ":", "param", "packet_buffer", ":", "buffer", "to", "send", "(", "length", "shouldn", "t", "exceed", "MAX_INT", ")" ]
47ddb7f34de865c7ff6391c73b36b3af9a595158
https://github.com/orweis/winpcapy/blob/47ddb7f34de865c7ff6391c73b36b3af9a595158/winpcapy/winpcapy.py#L133-L143
train
orweis/winpcapy
winpcapy/winpcapy.py
WinPcapUtils.capture_on
def capture_on(pattern, callback): """ :param pattern: a wildcard pattern to match the description of a network interface to capture packets on :param callback: a function to call with each intercepted packet """ device_name, desc = WinPcapDevices.get_matching_device(pattern) ...
python
def capture_on(pattern, callback): """ :param pattern: a wildcard pattern to match the description of a network interface to capture packets on :param callback: a function to call with each intercepted packet """ device_name, desc = WinPcapDevices.get_matching_device(pattern) ...
[ "def", "capture_on", "(", "pattern", ",", "callback", ")", ":", "device_name", ",", "desc", "=", "WinPcapDevices", ".", "get_matching_device", "(", "pattern", ")", "if", "device_name", "is", "not", "None", ":", "with", "WinPcap", "(", "device_name", ")", "as...
:param pattern: a wildcard pattern to match the description of a network interface to capture packets on :param callback: a function to call with each intercepted packet
[ ":", "param", "pattern", ":", "a", "wildcard", "pattern", "to", "match", "the", "description", "of", "a", "network", "interface", "to", "capture", "packets", "on", ":", "param", "callback", ":", "a", "function", "to", "call", "with", "each", "intercepted", ...
47ddb7f34de865c7ff6391c73b36b3af9a595158
https://github.com/orweis/winpcapy/blob/47ddb7f34de865c7ff6391c73b36b3af9a595158/winpcapy/winpcapy.py#L163-L171
train
orweis/winpcapy
winpcapy/winpcapy.py
WinPcapUtils.capture_on_device_name
def capture_on_device_name(device_name, callback): """ :param device_name: the name (guid) of a device as provided by WinPcapDevices.list_devices() :param callback: a function to call with each intercepted packet """ with WinPcap(device_name) as capture: capture.run(c...
python
def capture_on_device_name(device_name, callback): """ :param device_name: the name (guid) of a device as provided by WinPcapDevices.list_devices() :param callback: a function to call with each intercepted packet """ with WinPcap(device_name) as capture: capture.run(c...
[ "def", "capture_on_device_name", "(", "device_name", ",", "callback", ")", ":", "with", "WinPcap", "(", "device_name", ")", "as", "capture", ":", "capture", ".", "run", "(", "callback", "=", "callback", ")" ]
:param device_name: the name (guid) of a device as provided by WinPcapDevices.list_devices() :param callback: a function to call with each intercepted packet
[ ":", "param", "device_name", ":", "the", "name", "(", "guid", ")", "of", "a", "device", "as", "provided", "by", "WinPcapDevices", ".", "list_devices", "()", ":", "param", "callback", ":", "a", "function", "to", "call", "with", "each", "intercepted", "packe...
47ddb7f34de865c7ff6391c73b36b3af9a595158
https://github.com/orweis/winpcapy/blob/47ddb7f34de865c7ff6391c73b36b3af9a595158/winpcapy/winpcapy.py#L174-L180
train
orweis/winpcapy
winpcapy/winpcapy.py
WinPcapUtils.send_packet
def send_packet(self, pattern, packet_buffer, callback=None, limit=10): """ Send a buffer as a packet to a network interface and optionally capture a response :param pattern: a wildcard pattern to match the description of a network interface to capture packets on :param packet_buffer: a ...
python
def send_packet(self, pattern, packet_buffer, callback=None, limit=10): """ Send a buffer as a packet to a network interface and optionally capture a response :param pattern: a wildcard pattern to match the description of a network interface to capture packets on :param packet_buffer: a ...
[ "def", "send_packet", "(", "self", ",", "pattern", ",", "packet_buffer", ",", "callback", "=", "None", ",", "limit", "=", "10", ")", ":", "device_name", ",", "desc", "=", "WinPcapDevices", ".", "get_matching_device", "(", "pattern", ")", "if", "device_name",...
Send a buffer as a packet to a network interface and optionally capture a response :param pattern: a wildcard pattern to match the description of a network interface to capture packets on :param packet_buffer: a buffer to send (length shouldn't exceed MAX_INT) :param callback: If not None, a fun...
[ "Send", "a", "buffer", "as", "a", "packet", "to", "a", "network", "interface", "and", "optionally", "capture", "a", "response", ":", "param", "pattern", ":", "a", "wildcard", "pattern", "to", "match", "the", "description", "of", "a", "network", "interface", ...
47ddb7f34de865c7ff6391c73b36b3af9a595158
https://github.com/orweis/winpcapy/blob/47ddb7f34de865c7ff6391c73b36b3af9a595158/winpcapy/winpcapy.py#L191-L204
train
aaugustin/django-sequences
sequences/__init__.py
get_next_value
def get_next_value( sequence_name='default', initial_value=1, reset_value=None, *, nowait=False, using=None): """ Return the next value for a given sequence. """ # Inner import because models cannot be imported before their application. from .models import Sequence if reset_val...
python
def get_next_value( sequence_name='default', initial_value=1, reset_value=None, *, nowait=False, using=None): """ Return the next value for a given sequence. """ # Inner import because models cannot be imported before their application. from .models import Sequence if reset_val...
[ "def", "get_next_value", "(", "sequence_name", "=", "'default'", ",", "initial_value", "=", "1", ",", "reset_value", "=", "None", ",", "*", ",", "nowait", "=", "False", ",", "using", "=", "None", ")", ":", "# Inner import because models cannot be imported before t...
Return the next value for a given sequence.
[ "Return", "the", "next", "value", "for", "a", "given", "sequence", "." ]
0228ae003540ccb63be4a456fb8f63a2f4038de6
https://github.com/aaugustin/django-sequences/blob/0228ae003540ccb63be4a456fb8f63a2f4038de6/sequences/__init__.py#L13-L59
train
python-tap/tappy
tap/rules.py
Rules.check
def check(self, final_line_count): """Check the status of all provided data and update the suite.""" if self._lines_seen["version"]: self._process_version_lines() self._process_plan_lines(final_line_count)
python
def check(self, final_line_count): """Check the status of all provided data and update the suite.""" if self._lines_seen["version"]: self._process_version_lines() self._process_plan_lines(final_line_count)
[ "def", "check", "(", "self", ",", "final_line_count", ")", ":", "if", "self", ".", "_lines_seen", "[", "\"version\"", "]", ":", "self", ".", "_process_version_lines", "(", ")", "self", ".", "_process_plan_lines", "(", "final_line_count", ")" ]
Check the status of all provided data and update the suite.
[ "Check", "the", "status", "of", "all", "provided", "data", "and", "update", "the", "suite", "." ]
79a749313c61ea94ee49d67ba6a1534974bc03aa
https://github.com/python-tap/tappy/blob/79a749313c61ea94ee49d67ba6a1534974bc03aa/tap/rules.py#L15-L19
train
python-tap/tappy
tap/rules.py
Rules._process_version_lines
def _process_version_lines(self): """Process version line rules.""" if len(self._lines_seen["version"]) > 1: self._add_error(_("Multiple version lines appeared.")) elif self._lines_seen["version"][0] != 1: self._add_error(_("The version must be on the first line."))
python
def _process_version_lines(self): """Process version line rules.""" if len(self._lines_seen["version"]) > 1: self._add_error(_("Multiple version lines appeared.")) elif self._lines_seen["version"][0] != 1: self._add_error(_("The version must be on the first line."))
[ "def", "_process_version_lines", "(", "self", ")", ":", "if", "len", "(", "self", ".", "_lines_seen", "[", "\"version\"", "]", ")", ">", "1", ":", "self", ".", "_add_error", "(", "_", "(", "\"Multiple version lines appeared.\"", ")", ")", "elif", "self", "...
Process version line rules.
[ "Process", "version", "line", "rules", "." ]
79a749313c61ea94ee49d67ba6a1534974bc03aa
https://github.com/python-tap/tappy/blob/79a749313c61ea94ee49d67ba6a1534974bc03aa/tap/rules.py#L21-L26
train
python-tap/tappy
tap/rules.py
Rules._process_plan_lines
def _process_plan_lines(self, final_line_count): """Process plan line rules.""" if not self._lines_seen["plan"]: self._add_error(_("Missing a plan.")) return if len(self._lines_seen["plan"]) > 1: self._add_error(_("Only one plan line is permitted per file."))...
python
def _process_plan_lines(self, final_line_count): """Process plan line rules.""" if not self._lines_seen["plan"]: self._add_error(_("Missing a plan.")) return if len(self._lines_seen["plan"]) > 1: self._add_error(_("Only one plan line is permitted per file."))...
[ "def", "_process_plan_lines", "(", "self", ",", "final_line_count", ")", ":", "if", "not", "self", ".", "_lines_seen", "[", "\"plan\"", "]", ":", "self", ".", "_add_error", "(", "_", "(", "\"Missing a plan.\"", ")", ")", "return", "if", "len", "(", "self",...
Process plan line rules.
[ "Process", "plan", "line", "rules", "." ]
79a749313c61ea94ee49d67ba6a1534974bc03aa
https://github.com/python-tap/tappy/blob/79a749313c61ea94ee49d67ba6a1534974bc03aa/tap/rules.py#L28-L51
train
python-tap/tappy
tap/rules.py
Rules._plan_on_valid_line
def _plan_on_valid_line(self, at_line, final_line_count): """Check if a plan is on a valid line.""" # Put the common cases first. if at_line == 1 or at_line == final_line_count: return True # The plan may only appear on line 2 if the version is at line 1. after_versi...
python
def _plan_on_valid_line(self, at_line, final_line_count): """Check if a plan is on a valid line.""" # Put the common cases first. if at_line == 1 or at_line == final_line_count: return True # The plan may only appear on line 2 if the version is at line 1. after_versi...
[ "def", "_plan_on_valid_line", "(", "self", ",", "at_line", ",", "final_line_count", ")", ":", "# Put the common cases first.", "if", "at_line", "==", "1", "or", "at_line", "==", "final_line_count", ":", "return", "True", "# The plan may only appear on line 2 if the versio...
Check if a plan is on a valid line.
[ "Check", "if", "a", "plan", "is", "on", "a", "valid", "line", "." ]
79a749313c61ea94ee49d67ba6a1534974bc03aa
https://github.com/python-tap/tappy/blob/79a749313c61ea94ee49d67ba6a1534974bc03aa/tap/rules.py#L53-L68
train
python-tap/tappy
tap/rules.py
Rules.handle_bail
def handle_bail(self, bail): """Handle a bail line.""" self._add_error(_("Bailed: {reason}").format(reason=bail.reason))
python
def handle_bail(self, bail): """Handle a bail line.""" self._add_error(_("Bailed: {reason}").format(reason=bail.reason))
[ "def", "handle_bail", "(", "self", ",", "bail", ")", ":", "self", ".", "_add_error", "(", "_", "(", "\"Bailed: {reason}\"", ")", ".", "format", "(", "reason", "=", "bail", ".", "reason", ")", ")" ]
Handle a bail line.
[ "Handle", "a", "bail", "line", "." ]
79a749313c61ea94ee49d67ba6a1534974bc03aa
https://github.com/python-tap/tappy/blob/79a749313c61ea94ee49d67ba6a1534974bc03aa/tap/rules.py#L70-L72
train
python-tap/tappy
tap/rules.py
Rules.handle_skipping_plan
def handle_skipping_plan(self, skip_plan): """Handle a plan that contains a SKIP directive.""" skip_line = Result(True, None, skip_plan.directive.text, Directive("SKIP")) self._suite.addTest(Adapter(self._filename, skip_line))
python
def handle_skipping_plan(self, skip_plan): """Handle a plan that contains a SKIP directive.""" skip_line = Result(True, None, skip_plan.directive.text, Directive("SKIP")) self._suite.addTest(Adapter(self._filename, skip_line))
[ "def", "handle_skipping_plan", "(", "self", ",", "skip_plan", ")", ":", "skip_line", "=", "Result", "(", "True", ",", "None", ",", "skip_plan", ".", "directive", ".", "text", ",", "Directive", "(", "\"SKIP\"", ")", ")", "self", ".", "_suite", ".", "addTe...
Handle a plan that contains a SKIP directive.
[ "Handle", "a", "plan", "that", "contains", "a", "SKIP", "directive", "." ]
79a749313c61ea94ee49d67ba6a1534974bc03aa
https://github.com/python-tap/tappy/blob/79a749313c61ea94ee49d67ba6a1534974bc03aa/tap/rules.py#L78-L81
train
python-tap/tappy
tap/rules.py
Rules._add_error
def _add_error(self, message): """Add an error test to the suite.""" error_line = Result(False, None, message, Directive("")) self._suite.addTest(Adapter(self._filename, error_line))
python
def _add_error(self, message): """Add an error test to the suite.""" error_line = Result(False, None, message, Directive("")) self._suite.addTest(Adapter(self._filename, error_line))
[ "def", "_add_error", "(", "self", ",", "message", ")", ":", "error_line", "=", "Result", "(", "False", ",", "None", ",", "message", ",", "Directive", "(", "\"\"", ")", ")", "self", ".", "_suite", ".", "addTest", "(", "Adapter", "(", "self", ".", "_fi...
Add an error test to the suite.
[ "Add", "an", "error", "test", "to", "the", "suite", "." ]
79a749313c61ea94ee49d67ba6a1534974bc03aa
https://github.com/python-tap/tappy/blob/79a749313c61ea94ee49d67ba6a1534974bc03aa/tap/rules.py#L95-L98
train
python-tap/tappy
tap/formatter.py
format_exception
def format_exception(exception): """Format an exception as diagnostics output. exception is the tuple as expected from sys.exc_info. """ exception_lines = traceback.format_exception(*exception) # The lines returned from format_exception do not strictly contain # one line per element in the list...
python
def format_exception(exception): """Format an exception as diagnostics output. exception is the tuple as expected from sys.exc_info. """ exception_lines = traceback.format_exception(*exception) # The lines returned from format_exception do not strictly contain # one line per element in the list...
[ "def", "format_exception", "(", "exception", ")", ":", "exception_lines", "=", "traceback", ".", "format_exception", "(", "*", "exception", ")", "# The lines returned from format_exception do not strictly contain", "# one line per element in the list (i.e. some elements have new", ...
Format an exception as diagnostics output. exception is the tuple as expected from sys.exc_info.
[ "Format", "an", "exception", "as", "diagnostics", "output", "." ]
79a749313c61ea94ee49d67ba6a1534974bc03aa
https://github.com/python-tap/tappy/blob/79a749313c61ea94ee49d67ba6a1534974bc03aa/tap/formatter.py#L4-L14
train
python-tap/tappy
tap/parser.py
Parser.parse
def parse(self, fh): """Generate tap.line.Line objects, given a file-like object `fh`. `fh` may be any object that implements both the iterator and context management protocol (i.e. it can be used in both a "with" statement and a "for...in" statement.) Trailing whitespace and n...
python
def parse(self, fh): """Generate tap.line.Line objects, given a file-like object `fh`. `fh` may be any object that implements both the iterator and context management protocol (i.e. it can be used in both a "with" statement and a "for...in" statement.) Trailing whitespace and n...
[ "def", "parse", "(", "self", ",", "fh", ")", ":", "with", "fh", ":", "try", ":", "first_line", "=", "next", "(", "fh", ")", "except", "StopIteration", ":", "return", "first_parsed", "=", "self", ".", "parse_line", "(", "first_line", ".", "rstrip", "(",...
Generate tap.line.Line objects, given a file-like object `fh`. `fh` may be any object that implements both the iterator and context management protocol (i.e. it can be used in both a "with" statement and a "for...in" statement.) Trailing whitespace and newline characters will be automa...
[ "Generate", "tap", ".", "line", ".", "Line", "objects", "given", "a", "file", "-", "like", "object", "fh", "." ]
79a749313c61ea94ee49d67ba6a1534974bc03aa
https://github.com/python-tap/tappy/blob/79a749313c61ea94ee49d67ba6a1534974bc03aa/tap/parser.py#L86-L116
train
python-tap/tappy
tap/parser.py
Parser.parse_line
def parse_line(self, text, fh=None): """Parse a line into whatever TAP category it belongs.""" match = self.ok.match(text) if match: return self._parse_result(True, match, fh) match = self.not_ok.match(text) if match: return self._parse_result(False, matc...
python
def parse_line(self, text, fh=None): """Parse a line into whatever TAP category it belongs.""" match = self.ok.match(text) if match: return self._parse_result(True, match, fh) match = self.not_ok.match(text) if match: return self._parse_result(False, matc...
[ "def", "parse_line", "(", "self", ",", "text", ",", "fh", "=", "None", ")", ":", "match", "=", "self", ".", "ok", ".", "match", "(", "text", ")", "if", "match", ":", "return", "self", ".", "_parse_result", "(", "True", ",", "match", ",", "fh", ")...
Parse a line into whatever TAP category it belongs.
[ "Parse", "a", "line", "into", "whatever", "TAP", "category", "it", "belongs", "." ]
79a749313c61ea94ee49d67ba6a1534974bc03aa
https://github.com/python-tap/tappy/blob/79a749313c61ea94ee49d67ba6a1534974bc03aa/tap/parser.py#L118-L143
train
python-tap/tappy
tap/parser.py
Parser._parse_plan
def _parse_plan(self, match): """Parse a matching plan line.""" expected_tests = int(match.group("expected")) directive = Directive(match.group("directive")) # Only SKIP directives are allowed in the plan. if directive.text and not directive.skip: return Unknown() ...
python
def _parse_plan(self, match): """Parse a matching plan line.""" expected_tests = int(match.group("expected")) directive = Directive(match.group("directive")) # Only SKIP directives are allowed in the plan. if directive.text and not directive.skip: return Unknown() ...
[ "def", "_parse_plan", "(", "self", ",", "match", ")", ":", "expected_tests", "=", "int", "(", "match", ".", "group", "(", "\"expected\"", ")", ")", "directive", "=", "Directive", "(", "match", ".", "group", "(", "\"directive\"", ")", ")", "# Only SKIP dire...
Parse a matching plan line.
[ "Parse", "a", "matching", "plan", "line", "." ]
79a749313c61ea94ee49d67ba6a1534974bc03aa
https://github.com/python-tap/tappy/blob/79a749313c61ea94ee49d67ba6a1534974bc03aa/tap/parser.py#L145-L154
train
python-tap/tappy
tap/parser.py
Parser._parse_result
def _parse_result(self, ok, match, fh=None): """Parse a matching result line into a result instance.""" peek_match = None try: if fh is not None and self._try_peeking: peek_match = self.yaml_block_start.match(fh.peek()) except StopIteration: pass ...
python
def _parse_result(self, ok, match, fh=None): """Parse a matching result line into a result instance.""" peek_match = None try: if fh is not None and self._try_peeking: peek_match = self.yaml_block_start.match(fh.peek()) except StopIteration: pass ...
[ "def", "_parse_result", "(", "self", ",", "ok", ",", "match", ",", "fh", "=", "None", ")", ":", "peek_match", "=", "None", "try", ":", "if", "fh", "is", "not", "None", "and", "self", ".", "_try_peeking", ":", "peek_match", "=", "self", ".", "yaml_blo...
Parse a matching result line into a result instance.
[ "Parse", "a", "matching", "result", "line", "into", "a", "result", "instance", "." ]
79a749313c61ea94ee49d67ba6a1534974bc03aa
https://github.com/python-tap/tappy/blob/79a749313c61ea94ee49d67ba6a1534974bc03aa/tap/parser.py#L156-L179
train
python-tap/tappy
tap/parser.py
Parser._extract_yaml_block
def _extract_yaml_block(self, indent, fh): """Extract a raw yaml block from a file handler""" raw_yaml = [] indent_match = re.compile(r"^{}".format(indent)) try: fh.next() while indent_match.match(fh.peek()): raw_yaml.append(fh.next().replace(inden...
python
def _extract_yaml_block(self, indent, fh): """Extract a raw yaml block from a file handler""" raw_yaml = [] indent_match = re.compile(r"^{}".format(indent)) try: fh.next() while indent_match.match(fh.peek()): raw_yaml.append(fh.next().replace(inden...
[ "def", "_extract_yaml_block", "(", "self", ",", "indent", ",", "fh", ")", ":", "raw_yaml", "=", "[", "]", "indent_match", "=", "re", ".", "compile", "(", "r\"^{}\"", ".", "format", "(", "indent", ")", ")", "try", ":", "fh", ".", "next", "(", ")", "...
Extract a raw yaml block from a file handler
[ "Extract", "a", "raw", "yaml", "block", "from", "a", "file", "handler" ]
79a749313c61ea94ee49d67ba6a1534974bc03aa
https://github.com/python-tap/tappy/blob/79a749313c61ea94ee49d67ba6a1534974bc03aa/tap/parser.py#L181-L195
train
python-tap/tappy
tap/line.py
Result.yaml_block
def yaml_block(self): """Lazy load a yaml_block. If yaml support is not available, there is an error in parsing the yaml block, or no yaml is associated with this result, ``None`` will be returned. :rtype: dict """ if LOAD_YAML and self._yaml_block is no...
python
def yaml_block(self): """Lazy load a yaml_block. If yaml support is not available, there is an error in parsing the yaml block, or no yaml is associated with this result, ``None`` will be returned. :rtype: dict """ if LOAD_YAML and self._yaml_block is no...
[ "def", "yaml_block", "(", "self", ")", ":", "if", "LOAD_YAML", "and", "self", ".", "_yaml_block", "is", "not", "None", ":", "try", ":", "yaml_dict", "=", "yaml", ".", "load", "(", "self", ".", "_yaml_block", ")", "return", "yaml_dict", "except", "yaml", ...
Lazy load a yaml_block. If yaml support is not available, there is an error in parsing the yaml block, or no yaml is associated with this result, ``None`` will be returned. :rtype: dict
[ "Lazy", "load", "a", "yaml_block", "." ]
79a749313c61ea94ee49d67ba6a1534974bc03aa
https://github.com/python-tap/tappy/blob/79a749313c61ea94ee49d67ba6a1534974bc03aa/tap/line.py#L87-L103
train
python-tap/tappy
tap/loader.py
Loader.load
def load(self, files): """Load any files found into a suite. Any directories are walked and their files are added as TAP files. :returns: A ``unittest.TestSuite`` instance """ suite = unittest.TestSuite() for filepath in files: if os.path.isdir(filepath): ...
python
def load(self, files): """Load any files found into a suite. Any directories are walked and their files are added as TAP files. :returns: A ``unittest.TestSuite`` instance """ suite = unittest.TestSuite() for filepath in files: if os.path.isdir(filepath): ...
[ "def", "load", "(", "self", ",", "files", ")", ":", "suite", "=", "unittest", ".", "TestSuite", "(", ")", "for", "filepath", "in", "files", ":", "if", "os", ".", "path", ".", "isdir", "(", "filepath", ")", ":", "self", ".", "_find_tests_in_directory", ...
Load any files found into a suite. Any directories are walked and their files are added as TAP files. :returns: A ``unittest.TestSuite`` instance
[ "Load", "any", "files", "found", "into", "a", "suite", "." ]
79a749313c61ea94ee49d67ba6a1534974bc03aa
https://github.com/python-tap/tappy/blob/79a749313c61ea94ee49d67ba6a1534974bc03aa/tap/loader.py#L19-L32
train
python-tap/tappy
tap/loader.py
Loader.load_suite_from_file
def load_suite_from_file(self, filename): """Load a test suite with test lines from the provided TAP file. :returns: A ``unittest.TestSuite`` instance """ suite = unittest.TestSuite() rules = Rules(filename, suite) if not os.path.exists(filename): rules.hand...
python
def load_suite_from_file(self, filename): """Load a test suite with test lines from the provided TAP file. :returns: A ``unittest.TestSuite`` instance """ suite = unittest.TestSuite() rules = Rules(filename, suite) if not os.path.exists(filename): rules.hand...
[ "def", "load_suite_from_file", "(", "self", ",", "filename", ")", ":", "suite", "=", "unittest", ".", "TestSuite", "(", ")", "rules", "=", "Rules", "(", "filename", ",", "suite", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "filename", ")",...
Load a test suite with test lines from the provided TAP file. :returns: A ``unittest.TestSuite`` instance
[ "Load", "a", "test", "suite", "with", "test", "lines", "from", "the", "provided", "TAP", "file", "." ]
79a749313c61ea94ee49d67ba6a1534974bc03aa
https://github.com/python-tap/tappy/blob/79a749313c61ea94ee49d67ba6a1534974bc03aa/tap/loader.py#L34-L47
train
python-tap/tappy
tap/loader.py
Loader.load_suite_from_stdin
def load_suite_from_stdin(self): """Load a test suite with test lines from the TAP stream on STDIN. :returns: A ``unittest.TestSuite`` instance """ suite = unittest.TestSuite() rules = Rules("stream", suite) line_generator = self._parser.parse_stdin() return self...
python
def load_suite_from_stdin(self): """Load a test suite with test lines from the TAP stream on STDIN. :returns: A ``unittest.TestSuite`` instance """ suite = unittest.TestSuite() rules = Rules("stream", suite) line_generator = self._parser.parse_stdin() return self...
[ "def", "load_suite_from_stdin", "(", "self", ")", ":", "suite", "=", "unittest", ".", "TestSuite", "(", ")", "rules", "=", "Rules", "(", "\"stream\"", ",", "suite", ")", "line_generator", "=", "self", ".", "_parser", ".", "parse_stdin", "(", ")", "return",...
Load a test suite with test lines from the TAP stream on STDIN. :returns: A ``unittest.TestSuite`` instance
[ "Load", "a", "test", "suite", "with", "test", "lines", "from", "the", "TAP", "stream", "on", "STDIN", "." ]
79a749313c61ea94ee49d67ba6a1534974bc03aa
https://github.com/python-tap/tappy/blob/79a749313c61ea94ee49d67ba6a1534974bc03aa/tap/loader.py#L49-L57
train
python-tap/tappy
tap/loader.py
Loader._load_lines
def _load_lines(self, filename, line_generator, suite, rules): """Load a suite with lines produced by the line generator.""" line_counter = 0 for line in line_generator: line_counter += 1 if line.category in self.ignored_lines: continue if li...
python
def _load_lines(self, filename, line_generator, suite, rules): """Load a suite with lines produced by the line generator.""" line_counter = 0 for line in line_generator: line_counter += 1 if line.category in self.ignored_lines: continue if li...
[ "def", "_load_lines", "(", "self", ",", "filename", ",", "line_generator", ",", "suite", ",", "rules", ")", ":", "line_counter", "=", "0", "for", "line", "in", "line_generator", ":", "line_counter", "+=", "1", "if", "line", ".", "category", "in", "self", ...
Load a suite with lines produced by the line generator.
[ "Load", "a", "suite", "with", "lines", "produced", "by", "the", "line", "generator", "." ]
79a749313c61ea94ee49d67ba6a1534974bc03aa
https://github.com/python-tap/tappy/blob/79a749313c61ea94ee49d67ba6a1534974bc03aa/tap/loader.py#L66-L90
train
python-tap/tappy
tap/tracker.py
Tracker._track
def _track(self, class_name): """Keep track of which test cases have executed.""" if self._test_cases.get(class_name) is None: if self.streaming and self.header: self._write_test_case_header(class_name, self.stream) self._test_cases[class_name] = [] i...
python
def _track(self, class_name): """Keep track of which test cases have executed.""" if self._test_cases.get(class_name) is None: if self.streaming and self.header: self._write_test_case_header(class_name, self.stream) self._test_cases[class_name] = [] i...
[ "def", "_track", "(", "self", ",", "class_name", ")", ":", "if", "self", ".", "_test_cases", ".", "get", "(", "class_name", ")", "is", "None", ":", "if", "self", ".", "streaming", "and", "self", ".", "header", ":", "self", ".", "_write_test_case_header",...
Keep track of which test cases have executed.
[ "Keep", "track", "of", "which", "test", "cases", "have", "executed", "." ]
79a749313c61ea94ee49d67ba6a1534974bc03aa
https://github.com/python-tap/tappy/blob/79a749313c61ea94ee49d67ba6a1534974bc03aa/tap/tracker.py#L76-L84
train
python-tap/tappy
tap/tracker.py
Tracker.set_plan
def set_plan(self, total): """Notify the tracker how many total tests there will be.""" self.plan = total if self.streaming: # This will only write the plan if we haven't written it # already but we want to check if we already wrote a # test out (in which case...
python
def set_plan(self, total): """Notify the tracker how many total tests there will be.""" self.plan = total if self.streaming: # This will only write the plan if we haven't written it # already but we want to check if we already wrote a # test out (in which case...
[ "def", "set_plan", "(", "self", ",", "total", ")", ":", "self", ".", "plan", "=", "total", "if", "self", ".", "streaming", ":", "# This will only write the plan if we haven't written it", "# already but we want to check if we already wrote a", "# test out (in which case we ca...
Notify the tracker how many total tests there will be.
[ "Notify", "the", "tracker", "how", "many", "total", "tests", "there", "will", "be", "." ]
79a749313c61ea94ee49d67ba6a1534974bc03aa
https://github.com/python-tap/tappy/blob/79a749313c61ea94ee49d67ba6a1534974bc03aa/tap/tracker.py#L134-L147
train
python-tap/tappy
tap/tracker.py
Tracker.generate_tap_reports
def generate_tap_reports(self): """Generate TAP reports. The results are either combined into a single output file or the output file name is generated from the test case. """ # We're streaming but set_plan wasn't called, so we can only # know the plan now (at the end). ...
python
def generate_tap_reports(self): """Generate TAP reports. The results are either combined into a single output file or the output file name is generated from the test case. """ # We're streaming but set_plan wasn't called, so we can only # know the plan now (at the end). ...
[ "def", "generate_tap_reports", "(", "self", ")", ":", "# We're streaming but set_plan wasn't called, so we can only", "# know the plan now (at the end).", "if", "self", ".", "streaming", "and", "not", "self", ".", "_plan_written", ":", "print", "(", "\"1..{0}\"", ".", "fo...
Generate TAP reports. The results are either combined into a single output file or the output file name is generated from the test case.
[ "Generate", "TAP", "reports", "." ]
79a749313c61ea94ee49d67ba6a1534974bc03aa
https://github.com/python-tap/tappy/blob/79a749313c61ea94ee49d67ba6a1534974bc03aa/tap/tracker.py#L149-L180
train
python-tap/tappy
tap/tracker.py
Tracker._write_plan
def _write_plan(self, stream): """Write the plan line to the stream. If we have a plan and have not yet written it out, write it to the given stream. """ if self.plan is not None: if not self._plan_written: print("1..{0}".format(self.plan), file=strea...
python
def _write_plan(self, stream): """Write the plan line to the stream. If we have a plan and have not yet written it out, write it to the given stream. """ if self.plan is not None: if not self._plan_written: print("1..{0}".format(self.plan), file=strea...
[ "def", "_write_plan", "(", "self", ",", "stream", ")", ":", "if", "self", ".", "plan", "is", "not", "None", ":", "if", "not", "self", ".", "_plan_written", ":", "print", "(", "\"1..{0}\"", ".", "format", "(", "self", ".", "plan", ")", ",", "file", ...
Write the plan line to the stream. If we have a plan and have not yet written it out, write it to the given stream.
[ "Write", "the", "plan", "line", "to", "the", "stream", "." ]
79a749313c61ea94ee49d67ba6a1534974bc03aa
https://github.com/python-tap/tappy/blob/79a749313c61ea94ee49d67ba6a1534974bc03aa/tap/tracker.py#L201-L210
train
python-tap/tappy
tap/tracker.py
Tracker._get_tap_file_path
def _get_tap_file_path(self, test_case): """Get the TAP output file path for the test case.""" sanitized_test_case = test_case.translate(self._sanitized_table) tap_file = sanitized_test_case + ".tap" if self.outdir: return os.path.join(self.outdir, tap_file) return ta...
python
def _get_tap_file_path(self, test_case): """Get the TAP output file path for the test case.""" sanitized_test_case = test_case.translate(self._sanitized_table) tap_file = sanitized_test_case + ".tap" if self.outdir: return os.path.join(self.outdir, tap_file) return ta...
[ "def", "_get_tap_file_path", "(", "self", ",", "test_case", ")", ":", "sanitized_test_case", "=", "test_case", ".", "translate", "(", "self", ".", "_sanitized_table", ")", "tap_file", "=", "sanitized_test_case", "+", "\".tap\"", "if", "self", ".", "outdir", ":",...
Get the TAP output file path for the test case.
[ "Get", "the", "TAP", "output", "file", "path", "for", "the", "test", "case", "." ]
79a749313c61ea94ee49d67ba6a1534974bc03aa
https://github.com/python-tap/tappy/blob/79a749313c61ea94ee49d67ba6a1534974bc03aa/tap/tracker.py#L217-L223
train
python-tap/tappy
tap/main.py
main
def main(argv=sys.argv, stream=sys.stderr): """Entry point for ``tappy`` command.""" args = parse_args(argv) suite = build_suite(args) runner = unittest.TextTestRunner(verbosity=args.verbose, stream=stream) result = runner.run(suite) return get_status(result)
python
def main(argv=sys.argv, stream=sys.stderr): """Entry point for ``tappy`` command.""" args = parse_args(argv) suite = build_suite(args) runner = unittest.TextTestRunner(verbosity=args.verbose, stream=stream) result = runner.run(suite) return get_status(result)
[ "def", "main", "(", "argv", "=", "sys", ".", "argv", ",", "stream", "=", "sys", ".", "stderr", ")", ":", "args", "=", "parse_args", "(", "argv", ")", "suite", "=", "build_suite", "(", "args", ")", "runner", "=", "unittest", ".", "TextTestRunner", "("...
Entry point for ``tappy`` command.
[ "Entry", "point", "for", "tappy", "command", "." ]
79a749313c61ea94ee49d67ba6a1534974bc03aa
https://github.com/python-tap/tappy/blob/79a749313c61ea94ee49d67ba6a1534974bc03aa/tap/main.py#L11-L18
train
python-tap/tappy
tap/main.py
build_suite
def build_suite(args): """Build a test suite by loading TAP files or a TAP stream.""" loader = Loader() if len(args.files) == 0 or args.files[0] == "-": suite = loader.load_suite_from_stdin() else: suite = loader.load(args.files) return suite
python
def build_suite(args): """Build a test suite by loading TAP files or a TAP stream.""" loader = Loader() if len(args.files) == 0 or args.files[0] == "-": suite = loader.load_suite_from_stdin() else: suite = loader.load(args.files) return suite
[ "def", "build_suite", "(", "args", ")", ":", "loader", "=", "Loader", "(", ")", "if", "len", "(", "args", ".", "files", ")", "==", "0", "or", "args", ".", "files", "[", "0", "]", "==", "\"-\"", ":", "suite", "=", "loader", ".", "load_suite_from_std...
Build a test suite by loading TAP files or a TAP stream.
[ "Build", "a", "test", "suite", "by", "loading", "TAP", "files", "or", "a", "TAP", "stream", "." ]
79a749313c61ea94ee49d67ba6a1534974bc03aa
https://github.com/python-tap/tappy/blob/79a749313c61ea94ee49d67ba6a1534974bc03aa/tap/main.py#L21-L28
train
python-tap/tappy
tap/adapter.py
Adapter.addFailure
def addFailure(self, result): """Add a failure to the result.""" result.addFailure(self, (Exception, Exception(), None)) # Since TAP will not provide assertion data, clean up the assertion # section so it is not so spaced out. test, err = result.failures[-1] result.failur...
python
def addFailure(self, result): """Add a failure to the result.""" result.addFailure(self, (Exception, Exception(), None)) # Since TAP will not provide assertion data, clean up the assertion # section so it is not so spaced out. test, err = result.failures[-1] result.failur...
[ "def", "addFailure", "(", "self", ",", "result", ")", ":", "result", ".", "addFailure", "(", "self", ",", "(", "Exception", ",", "Exception", "(", ")", ",", "None", ")", ")", "# Since TAP will not provide assertion data, clean up the assertion", "# section so it is ...
Add a failure to the result.
[ "Add", "a", "failure", "to", "the", "result", "." ]
79a749313c61ea94ee49d67ba6a1534974bc03aa
https://github.com/python-tap/tappy/blob/79a749313c61ea94ee49d67ba6a1534974bc03aa/tap/adapter.py#L43-L49
train
uralbash/sqlalchemy_mptt
sqlalchemy_mptt/events.py
mptt_before_insert
def mptt_before_insert(mapper, connection, instance): """ Based on example https://bitbucket.org/zzzeek/sqlalchemy/src/73095b353124/examples/nested_sets/nested_sets.py?at=master """ table = _get_tree_table(mapper) db_pk = instance.get_pk_column() table_pk = getattr(table.c, db_pk.name) if i...
python
def mptt_before_insert(mapper, connection, instance): """ Based on example https://bitbucket.org/zzzeek/sqlalchemy/src/73095b353124/examples/nested_sets/nested_sets.py?at=master """ table = _get_tree_table(mapper) db_pk = instance.get_pk_column() table_pk = getattr(table.c, db_pk.name) if i...
[ "def", "mptt_before_insert", "(", "mapper", ",", "connection", ",", "instance", ")", ":", "table", "=", "_get_tree_table", "(", "mapper", ")", "db_pk", "=", "instance", ".", "get_pk_column", "(", ")", "table_pk", "=", "getattr", "(", "table", ".", "c", ","...
Based on example https://bitbucket.org/zzzeek/sqlalchemy/src/73095b353124/examples/nested_sets/nested_sets.py?at=master
[ "Based", "on", "example", "https", ":", "//", "bitbucket", ".", "org", "/", "zzzeek", "/", "sqlalchemy", "/", "src", "/", "73095b353124", "/", "examples", "/", "nested_sets", "/", "nested_sets", ".", "py?at", "=", "master" ]
2971c9fa49bbeaa3e2fb96229d933ceae450b319
https://github.com/uralbash/sqlalchemy_mptt/blob/2971c9fa49bbeaa3e2fb96229d933ceae450b319/sqlalchemy_mptt/events.py#L83-L150
train
uralbash/sqlalchemy_mptt
sqlalchemy_mptt/events.py
mptt_before_update
def mptt_before_update(mapper, connection, instance): """ Based on this example: http://stackoverflow.com/questions/889527/move-node-in-nested-set """ node_id = getattr(instance, instance.get_pk_name()) table = _get_tree_table(mapper) db_pk = instance.get_pk_column() default_level = inst...
python
def mptt_before_update(mapper, connection, instance): """ Based on this example: http://stackoverflow.com/questions/889527/move-node-in-nested-set """ node_id = getattr(instance, instance.get_pk_name()) table = _get_tree_table(mapper) db_pk = instance.get_pk_column() default_level = inst...
[ "def", "mptt_before_update", "(", "mapper", ",", "connection", ",", "instance", ")", ":", "node_id", "=", "getattr", "(", "instance", ",", "instance", ".", "get_pk_name", "(", ")", ")", "table", "=", "_get_tree_table", "(", "mapper", ")", "db_pk", "=", "in...
Based on this example: http://stackoverflow.com/questions/889527/move-node-in-nested-set
[ "Based", "on", "this", "example", ":", "http", ":", "//", "stackoverflow", ".", "com", "/", "questions", "/", "889527", "/", "move", "-", "node", "-", "in", "-", "nested", "-", "set" ]
2971c9fa49bbeaa3e2fb96229d933ceae450b319
https://github.com/uralbash/sqlalchemy_mptt/blob/2971c9fa49bbeaa3e2fb96229d933ceae450b319/sqlalchemy_mptt/events.py#L221-L479
train
uralbash/sqlalchemy_mptt
sqlalchemy_mptt/events.py
TreesManager.after_flush_postexec
def after_flush_postexec(self, session, context): """ Event listener to recursively expire `left` and `right` attributes the parents of all modified instances part of this flush. """ instances = self.instances[session] while instances: instance = instances.pop...
python
def after_flush_postexec(self, session, context): """ Event listener to recursively expire `left` and `right` attributes the parents of all modified instances part of this flush. """ instances = self.instances[session] while instances: instance = instances.pop...
[ "def", "after_flush_postexec", "(", "self", ",", "session", ",", "context", ")", ":", "instances", "=", "self", ".", "instances", "[", "session", "]", "while", "instances", ":", "instance", "=", "instances", ".", "pop", "(", ")", "if", "instance", "not", ...
Event listener to recursively expire `left` and `right` attributes the parents of all modified instances part of this flush.
[ "Event", "listener", "to", "recursively", "expire", "left", "and", "right", "attributes", "the", "parents", "of", "all", "modified", "instances", "part", "of", "this", "flush", "." ]
2971c9fa49bbeaa3e2fb96229d933ceae450b319
https://github.com/uralbash/sqlalchemy_mptt/blob/2971c9fa49bbeaa3e2fb96229d933ceae450b319/sqlalchemy_mptt/events.py#L586-L604
train
uralbash/sqlalchemy_mptt
sqlalchemy_mptt/mixins.py
BaseNestedSets.is_ancestor_of
def is_ancestor_of(self, other, inclusive=False): """ class or instance level method which returns True if self is ancestor (closer to root) of other else False. Optional flag `inclusive` on whether or not to treat self as ancestor of self. For example see: * :mod:`sqlalchemy_m...
python
def is_ancestor_of(self, other, inclusive=False): """ class or instance level method which returns True if self is ancestor (closer to root) of other else False. Optional flag `inclusive` on whether or not to treat self as ancestor of self. For example see: * :mod:`sqlalchemy_m...
[ "def", "is_ancestor_of", "(", "self", ",", "other", ",", "inclusive", "=", "False", ")", ":", "if", "inclusive", ":", "return", "(", "self", ".", "tree_id", "==", "other", ".", "tree_id", ")", "&", "(", "self", ".", "left", "<=", "other", ".", "left"...
class or instance level method which returns True if self is ancestor (closer to root) of other else False. Optional flag `inclusive` on whether or not to treat self as ancestor of self. For example see: * :mod:`sqlalchemy_mptt.tests.cases.integrity.test_hierarchy_structure`
[ "class", "or", "instance", "level", "method", "which", "returns", "True", "if", "self", "is", "ancestor", "(", "closer", "to", "root", ")", "of", "other", "else", "False", ".", "Optional", "flag", "inclusive", "on", "whether", "or", "not", "to", "treat", ...
2971c9fa49bbeaa3e2fb96229d933ceae450b319
https://github.com/uralbash/sqlalchemy_mptt/blob/2971c9fa49bbeaa3e2fb96229d933ceae450b319/sqlalchemy_mptt/mixins.py#L124-L139
train
uralbash/sqlalchemy_mptt
sqlalchemy_mptt/mixins.py
BaseNestedSets.move_inside
def move_inside(self, parent_id): """ Moving one node of tree inside another For example see: * :mod:`sqlalchemy_mptt.tests.cases.move_node.test_move_inside_function` * :mod:`sqlalchemy_mptt.tests.cases.move_node.test_move_inside_to_the_same_parent_function` """ # noqa ...
python
def move_inside(self, parent_id): """ Moving one node of tree inside another For example see: * :mod:`sqlalchemy_mptt.tests.cases.move_node.test_move_inside_function` * :mod:`sqlalchemy_mptt.tests.cases.move_node.test_move_inside_to_the_same_parent_function` """ # noqa ...
[ "def", "move_inside", "(", "self", ",", "parent_id", ")", ":", "# noqa", "session", "=", "Session", ".", "object_session", "(", "self", ")", "self", ".", "parent_id", "=", "parent_id", "self", ".", "mptt_move_inside", "=", "parent_id", "session", ".", "add",...
Moving one node of tree inside another For example see: * :mod:`sqlalchemy_mptt.tests.cases.move_node.test_move_inside_function` * :mod:`sqlalchemy_mptt.tests.cases.move_node.test_move_inside_to_the_same_parent_function`
[ "Moving", "one", "node", "of", "tree", "inside", "another" ]
2971c9fa49bbeaa3e2fb96229d933ceae450b319
https://github.com/uralbash/sqlalchemy_mptt/blob/2971c9fa49bbeaa3e2fb96229d933ceae450b319/sqlalchemy_mptt/mixins.py#L153-L164
train
uralbash/sqlalchemy_mptt
sqlalchemy_mptt/mixins.py
BaseNestedSets.move_after
def move_after(self, node_id): """ Moving one node of tree after another For example see :mod:`sqlalchemy_mptt.tests.cases.move_node.test_move_after_function` """ # noqa session = Session.object_session(self) self.parent_id = self.parent_id self.mptt_move_after = node_i...
python
def move_after(self, node_id): """ Moving one node of tree after another For example see :mod:`sqlalchemy_mptt.tests.cases.move_node.test_move_after_function` """ # noqa session = Session.object_session(self) self.parent_id = self.parent_id self.mptt_move_after = node_i...
[ "def", "move_after", "(", "self", ",", "node_id", ")", ":", "# noqa", "session", "=", "Session", ".", "object_session", "(", "self", ")", "self", ".", "parent_id", "=", "self", ".", "parent_id", "self", ".", "mptt_move_after", "=", "node_id", "session", "....
Moving one node of tree after another For example see :mod:`sqlalchemy_mptt.tests.cases.move_node.test_move_after_function`
[ "Moving", "one", "node", "of", "tree", "after", "another" ]
2971c9fa49bbeaa3e2fb96229d933ceae450b319
https://github.com/uralbash/sqlalchemy_mptt/blob/2971c9fa49bbeaa3e2fb96229d933ceae450b319/sqlalchemy_mptt/mixins.py#L166-L174
train
uralbash/sqlalchemy_mptt
sqlalchemy_mptt/mixins.py
BaseNestedSets.move_before
def move_before(self, node_id): """ Moving one node of tree before another For example see: * :mod:`sqlalchemy_mptt.tests.cases.move_node.test_move_before_function` * :mod:`sqlalchemy_mptt.tests.cases.move_node.test_move_before_to_other_tree` * :mod:`sqlalchemy_mptt.tests.cases...
python
def move_before(self, node_id): """ Moving one node of tree before another For example see: * :mod:`sqlalchemy_mptt.tests.cases.move_node.test_move_before_function` * :mod:`sqlalchemy_mptt.tests.cases.move_node.test_move_before_to_other_tree` * :mod:`sqlalchemy_mptt.tests.cases...
[ "def", "move_before", "(", "self", ",", "node_id", ")", ":", "# noqa", "session", "=", "Session", ".", "object_session", "(", "self", ")", "table", "=", "_get_tree_table", "(", "self", ".", "__mapper__", ")", "pk", "=", "getattr", "(", "table", ".", "c",...
Moving one node of tree before another For example see: * :mod:`sqlalchemy_mptt.tests.cases.move_node.test_move_before_function` * :mod:`sqlalchemy_mptt.tests.cases.move_node.test_move_before_to_other_tree` * :mod:`sqlalchemy_mptt.tests.cases.move_node.test_move_before_to_top_level`
[ "Moving", "one", "node", "of", "tree", "before", "another" ]
2971c9fa49bbeaa3e2fb96229d933ceae450b319
https://github.com/uralbash/sqlalchemy_mptt/blob/2971c9fa49bbeaa3e2fb96229d933ceae450b319/sqlalchemy_mptt/mixins.py#L176-L191
train
uralbash/sqlalchemy_mptt
sqlalchemy_mptt/mixins.py
BaseNestedSets.leftsibling_in_level
def leftsibling_in_level(self): """ Node to the left of the current node at the same level For example see :mod:`sqlalchemy_mptt.tests.cases.get_tree.test_leftsibling_in_level` """ # noqa table = _get_tree_table(self.__mapper__) session = Session.object_session(self) ...
python
def leftsibling_in_level(self): """ Node to the left of the current node at the same level For example see :mod:`sqlalchemy_mptt.tests.cases.get_tree.test_leftsibling_in_level` """ # noqa table = _get_tree_table(self.__mapper__) session = Session.object_session(self) ...
[ "def", "leftsibling_in_level", "(", "self", ")", ":", "# noqa", "table", "=", "_get_tree_table", "(", "self", ".", "__mapper__", ")", "session", "=", "Session", ".", "object_session", "(", "self", ")", "current_lvl_nodes", "=", "session", ".", "query", "(", ...
Node to the left of the current node at the same level For example see :mod:`sqlalchemy_mptt.tests.cases.get_tree.test_leftsibling_in_level`
[ "Node", "to", "the", "left", "of", "the", "current", "node", "at", "the", "same", "level" ]
2971c9fa49bbeaa3e2fb96229d933ceae450b319
https://github.com/uralbash/sqlalchemy_mptt/blob/2971c9fa49bbeaa3e2fb96229d933ceae450b319/sqlalchemy_mptt/mixins.py#L193-L206
train
uralbash/sqlalchemy_mptt
sqlalchemy_mptt/mixins.py
BaseNestedSets._node_to_dict
def _node_to_dict(cls, node, json, json_fields): """ Helper method for ``get_tree``. """ if json: pk_name = node.get_pk_name() # jqTree or jsTree format result = {'id': getattr(node, pk_name), 'label': node.__repr__()} if json_fields: ...
python
def _node_to_dict(cls, node, json, json_fields): """ Helper method for ``get_tree``. """ if json: pk_name = node.get_pk_name() # jqTree or jsTree format result = {'id': getattr(node, pk_name), 'label': node.__repr__()} if json_fields: ...
[ "def", "_node_to_dict", "(", "cls", ",", "node", ",", "json", ",", "json_fields", ")", ":", "if", "json", ":", "pk_name", "=", "node", ".", "get_pk_name", "(", ")", "# jqTree or jsTree format", "result", "=", "{", "'id'", ":", "getattr", "(", "node", ","...
Helper method for ``get_tree``.
[ "Helper", "method", "for", "get_tree", "." ]
2971c9fa49bbeaa3e2fb96229d933ceae450b319
https://github.com/uralbash/sqlalchemy_mptt/blob/2971c9fa49bbeaa3e2fb96229d933ceae450b319/sqlalchemy_mptt/mixins.py#L209-L220
train
uralbash/sqlalchemy_mptt
sqlalchemy_mptt/mixins.py
BaseNestedSets.get_tree
def get_tree(cls, session=None, json=False, json_fields=None, query=None): """ This method generate tree of current node table in dict or json format. You can make custom query with attribute ``query``. By default it return all nodes in table. Args: session (:mod:`sqlalchemy...
python
def get_tree(cls, session=None, json=False, json_fields=None, query=None): """ This method generate tree of current node table in dict or json format. You can make custom query with attribute ``query``. By default it return all nodes in table. Args: session (:mod:`sqlalchemy...
[ "def", "get_tree", "(", "cls", ",", "session", "=", "None", ",", "json", "=", "False", ",", "json_fields", "=", "None", ",", "query", "=", "None", ")", ":", "# noqa", "tree", "=", "[", "]", "nodes_of_level", "=", "{", "}", "# handle custom query", "nod...
This method generate tree of current node table in dict or json format. You can make custom query with attribute ``query``. By default it return all nodes in table. Args: session (:mod:`sqlalchemy.orm.session.Session`): SQLAlchemy session Kwargs: json (bool): if...
[ "This", "method", "generate", "tree", "of", "current", "node", "table", "in", "dict", "or", "json", "format", ".", "You", "can", "make", "custom", "query", "with", "attribute", "query", ".", "By", "default", "it", "return", "all", "nodes", "in", "table", ...
2971c9fa49bbeaa3e2fb96229d933ceae450b319
https://github.com/uralbash/sqlalchemy_mptt/blob/2971c9fa49bbeaa3e2fb96229d933ceae450b319/sqlalchemy_mptt/mixins.py#L238-L296
train
uralbash/sqlalchemy_mptt
sqlalchemy_mptt/mixins.py
BaseNestedSets.drilldown_tree
def drilldown_tree(self, session=None, json=False, json_fields=None): """ This method generate a branch from a tree, begining with current node. For example: node7.drilldown_tree() .. code:: level Nested sets example 1 ...
python
def drilldown_tree(self, session=None, json=False, json_fields=None): """ This method generate a branch from a tree, begining with current node. For example: node7.drilldown_tree() .. code:: level Nested sets example 1 ...
[ "def", "drilldown_tree", "(", "self", ",", "session", "=", "None", ",", "json", "=", "False", ",", "json_fields", "=", "None", ")", ":", "if", "not", "session", ":", "session", "=", "object_session", "(", "self", ")", "return", "self", ".", "get_tree", ...
This method generate a branch from a tree, begining with current node. For example: node7.drilldown_tree() .. code:: level Nested sets example 1 1(1)22 --------------------- ___________...
[ "This", "method", "generate", "a", "branch", "from", "a", "tree", "begining", "with", "current", "node", "." ]
2971c9fa49bbeaa3e2fb96229d933ceae450b319
https://github.com/uralbash/sqlalchemy_mptt/blob/2971c9fa49bbeaa3e2fb96229d933ceae450b319/sqlalchemy_mptt/mixins.py#L304-L337
train
uralbash/sqlalchemy_mptt
sqlalchemy_mptt/mixins.py
BaseNestedSets.path_to_root
def path_to_root(self, session=None, order=desc): """Generate path from a leaf or intermediate node to the root. For example: node11.path_to_root() .. code:: level Nested sets example --------------------------------...
python
def path_to_root(self, session=None, order=desc): """Generate path from a leaf or intermediate node to the root. For example: node11.path_to_root() .. code:: level Nested sets example --------------------------------...
[ "def", "path_to_root", "(", "self", ",", "session", "=", "None", ",", "order", "=", "desc", ")", ":", "table", "=", "self", ".", "__class__", "query", "=", "self", ".", "_base_query_obj", "(", "session", "=", "session", ")", "query", "=", "query", ".",...
Generate path from a leaf or intermediate node to the root. For example: node11.path_to_root() .. code:: level Nested sets example ----------------------------------------- 1 | 1(1)22 ...
[ "Generate", "path", "from", "a", "leaf", "or", "intermediate", "node", "to", "the", "root", "." ]
2971c9fa49bbeaa3e2fb96229d933ceae450b319
https://github.com/uralbash/sqlalchemy_mptt/blob/2971c9fa49bbeaa3e2fb96229d933ceae450b319/sqlalchemy_mptt/mixins.py#L339-L367
train
uralbash/sqlalchemy_mptt
sqlalchemy_mptt/mixins.py
BaseNestedSets.rebuild_tree
def rebuild_tree(cls, session, tree_id): """ This method rebuid tree. Args: session (:mod:`sqlalchemy.orm.session.Session`): SQLAlchemy session tree_id (int or str): id of tree Example: * :mod:`sqlalchemy_mptt.tests.cases.get_tree.test_rebuild` """ ...
python
def rebuild_tree(cls, session, tree_id): """ This method rebuid tree. Args: session (:mod:`sqlalchemy.orm.session.Session`): SQLAlchemy session tree_id (int or str): id of tree Example: * :mod:`sqlalchemy_mptt.tests.cases.get_tree.test_rebuild` """ ...
[ "def", "rebuild_tree", "(", "cls", ",", "session", ",", "tree_id", ")", ":", "session", ".", "query", "(", "cls", ")", ".", "filter_by", "(", "tree_id", "=", "tree_id", ")", ".", "update", "(", "{", "cls", ".", "left", ":", "0", ",", "cls", ".", ...
This method rebuid tree. Args: session (:mod:`sqlalchemy.orm.session.Session`): SQLAlchemy session tree_id (int or str): id of tree Example: * :mod:`sqlalchemy_mptt.tests.cases.get_tree.test_rebuild`
[ "This", "method", "rebuid", "tree", "." ]
2971c9fa49bbeaa3e2fb96229d933ceae450b319
https://github.com/uralbash/sqlalchemy_mptt/blob/2971c9fa49bbeaa3e2fb96229d933ceae450b319/sqlalchemy_mptt/mixins.py#L370-L414
train
uralbash/sqlalchemy_mptt
sqlalchemy_mptt/mixins.py
BaseNestedSets.rebuild
def rebuild(cls, session, tree_id=None): """ This function rebuid tree. Args: session (:mod:`sqlalchemy.orm.session.Session`): SQLAlchemy session Kwargs: tree_id (int or str): id of tree, default None Example: * :mod:`sqlalchemy_mptt.tests.TestTree.tes...
python
def rebuild(cls, session, tree_id=None): """ This function rebuid tree. Args: session (:mod:`sqlalchemy.orm.session.Session`): SQLAlchemy session Kwargs: tree_id (int or str): id of tree, default None Example: * :mod:`sqlalchemy_mptt.tests.TestTree.tes...
[ "def", "rebuild", "(", "cls", ",", "session", ",", "tree_id", "=", "None", ")", ":", "trees", "=", "session", ".", "query", "(", "cls", ")", ".", "filter_by", "(", "parent_id", "=", "None", ")", "if", "tree_id", ":", "trees", "=", "trees", ".", "fi...
This function rebuid tree. Args: session (:mod:`sqlalchemy.orm.session.Session`): SQLAlchemy session Kwargs: tree_id (int or str): id of tree, default None Example: * :mod:`sqlalchemy_mptt.tests.TestTree.test_rebuild`
[ "This", "function", "rebuid", "tree", "." ]
2971c9fa49bbeaa3e2fb96229d933ceae450b319
https://github.com/uralbash/sqlalchemy_mptt/blob/2971c9fa49bbeaa3e2fb96229d933ceae450b319/sqlalchemy_mptt/mixins.py#L417-L435
train
franciscogarate/pyliferisk
pyliferisk/__init__.py
qx
def qx(mt, x): """ qx: Returns the probability that a life aged x dies before 1 year With the convention: the true probability is qx/1000 Args: mt: the mortality table x: the age as integer number. """ if x < len(mt.qx): return mt.qx[x] else: return 0
python
def qx(mt, x): """ qx: Returns the probability that a life aged x dies before 1 year With the convention: the true probability is qx/1000 Args: mt: the mortality table x: the age as integer number. """ if x < len(mt.qx): return mt.qx[x] else: return 0
[ "def", "qx", "(", "mt", ",", "x", ")", ":", "if", "x", "<", "len", "(", "mt", ".", "qx", ")", ":", "return", "mt", ".", "qx", "[", "x", "]", "else", ":", "return", "0" ]
qx: Returns the probability that a life aged x dies before 1 year With the convention: the true probability is qx/1000 Args: mt: the mortality table x: the age as integer number.
[ "qx", ":", "Returns", "the", "probability", "that", "a", "life", "aged", "x", "dies", "before", "1", "year", "With", "the", "convention", ":", "the", "true", "probability", "is", "qx", "/", "1000", "Args", ":", "mt", ":", "the", "mortality", "table", "...
8d906bed04df1ba00fa1cacc6f31030ce5ab6233
https://github.com/franciscogarate/pyliferisk/blob/8d906bed04df1ba00fa1cacc6f31030ce5ab6233/pyliferisk/__init__.py#L180-L190
train
franciscogarate/pyliferisk
pyliferisk/__init__.py
lx
def lx(mt, x): """ lx : Returns the number of survivors at begining of age x """ if x < len(mt.lx): return mt.lx[x] else: return 0
python
def lx(mt, x): """ lx : Returns the number of survivors at begining of age x """ if x < len(mt.lx): return mt.lx[x] else: return 0
[ "def", "lx", "(", "mt", ",", "x", ")", ":", "if", "x", "<", "len", "(", "mt", ".", "lx", ")", ":", "return", "mt", ".", "lx", "[", "x", "]", "else", ":", "return", "0" ]
lx : Returns the number of survivors at begining of age x
[ "lx", ":", "Returns", "the", "number", "of", "survivors", "at", "begining", "of", "age", "x" ]
8d906bed04df1ba00fa1cacc6f31030ce5ab6233
https://github.com/franciscogarate/pyliferisk/blob/8d906bed04df1ba00fa1cacc6f31030ce5ab6233/pyliferisk/__init__.py#L192-L197
train
franciscogarate/pyliferisk
pyliferisk/__init__.py
dx
def dx(mt, x): """ Returns the number of dying at begining of age x """ end_x_val = mt.lx.index(0) if x < end_x_val: return mt.lx[x] - mt.lx[x + 1] else: return 0.0
python
def dx(mt, x): """ Returns the number of dying at begining of age x """ end_x_val = mt.lx.index(0) if x < end_x_val: return mt.lx[x] - mt.lx[x + 1] else: return 0.0
[ "def", "dx", "(", "mt", ",", "x", ")", ":", "end_x_val", "=", "mt", ".", "lx", ".", "index", "(", "0", ")", "if", "x", "<", "end_x_val", ":", "return", "mt", ".", "lx", "[", "x", "]", "-", "mt", ".", "lx", "[", "x", "+", "1", "]", "else",...
Returns the number of dying at begining of age x
[ "Returns", "the", "number", "of", "dying", "at", "begining", "of", "age", "x" ]
8d906bed04df1ba00fa1cacc6f31030ce5ab6233
https://github.com/franciscogarate/pyliferisk/blob/8d906bed04df1ba00fa1cacc6f31030ce5ab6233/pyliferisk/__init__.py#L203-L209
train
franciscogarate/pyliferisk
pyliferisk/__init__.py
tpx
def tpx(mt, x, t): """ tpx : Returns the probability that x will survive within t years """ """ npx : Returns n years survival probability at age x """ return mt.lx[x + t] / mt.lx[x]
python
def tpx(mt, x, t): """ tpx : Returns the probability that x will survive within t years """ """ npx : Returns n years survival probability at age x """ return mt.lx[x + t] / mt.lx[x]
[ "def", "tpx", "(", "mt", ",", "x", ",", "t", ")", ":", "\"\"\" npx : Returns n years survival probability at age x \"\"\"", "return", "mt", ".", "lx", "[", "x", "+", "t", "]", "/", "mt", ".", "lx", "[", "x", "]" ]
tpx : Returns the probability that x will survive within t years
[ "tpx", ":", "Returns", "the", "probability", "that", "x", "will", "survive", "within", "t", "years" ]
8d906bed04df1ba00fa1cacc6f31030ce5ab6233
https://github.com/franciscogarate/pyliferisk/blob/8d906bed04df1ba00fa1cacc6f31030ce5ab6233/pyliferisk/__init__.py#L215-L218
train
franciscogarate/pyliferisk
pyliferisk/__init__.py
tqx
def tqx(mt, x, t): """ nqx : Returns the probability to die within n years at age x """ return (mt.lx[x] - mt.lx[x + t]) / mt.lx[x]
python
def tqx(mt, x, t): """ nqx : Returns the probability to die within n years at age x """ return (mt.lx[x] - mt.lx[x + t]) / mt.lx[x]
[ "def", "tqx", "(", "mt", ",", "x", ",", "t", ")", ":", "return", "(", "mt", ".", "lx", "[", "x", "]", "-", "mt", ".", "lx", "[", "x", "+", "t", "]", ")", "/", "mt", ".", "lx", "[", "x", "]" ]
nqx : Returns the probability to die within n years at age x
[ "nqx", ":", "Returns", "the", "probability", "to", "die", "within", "n", "years", "at", "age", "x" ]
8d906bed04df1ba00fa1cacc6f31030ce5ab6233
https://github.com/franciscogarate/pyliferisk/blob/8d906bed04df1ba00fa1cacc6f31030ce5ab6233/pyliferisk/__init__.py#L220-L222
train
franciscogarate/pyliferisk
pyliferisk/__init__.py
tqxn
def tqxn(mt, x, n, t): """ n/qx : Probability to die in n years being alive at age x. Probability that x survives n year, and then dies in th subsequent t years """ return tpx(mt, x, t) * qx(mt, x + n)
python
def tqxn(mt, x, n, t): """ n/qx : Probability to die in n years being alive at age x. Probability that x survives n year, and then dies in th subsequent t years """ return tpx(mt, x, t) * qx(mt, x + n)
[ "def", "tqxn", "(", "mt", ",", "x", ",", "n", ",", "t", ")", ":", "return", "tpx", "(", "mt", ",", "x", ",", "t", ")", "*", "qx", "(", "mt", ",", "x", "+", "n", ")" ]
n/qx : Probability to die in n years being alive at age x. Probability that x survives n year, and then dies in th subsequent t years
[ "n", "/", "qx", ":", "Probability", "to", "die", "in", "n", "years", "being", "alive", "at", "age", "x", ".", "Probability", "that", "x", "survives", "n", "year", "and", "then", "dies", "in", "th", "subsequent", "t", "years" ]
8d906bed04df1ba00fa1cacc6f31030ce5ab6233
https://github.com/franciscogarate/pyliferisk/blob/8d906bed04df1ba00fa1cacc6f31030ce5ab6233/pyliferisk/__init__.py#L224-L227
train
franciscogarate/pyliferisk
pyliferisk/__init__.py
ex
def ex(mt, x): """ ex : Returns the curtate expectation of life. Life expectancy """ sum1 = 0 for j in mt.lx[x + 1:-1]: sum1 += j #print sum1 try: return sum1 / mt.lx[x] + 0.5 except: return 0
python
def ex(mt, x): """ ex : Returns the curtate expectation of life. Life expectancy """ sum1 = 0 for j in mt.lx[x + 1:-1]: sum1 += j #print sum1 try: return sum1 / mt.lx[x] + 0.5 except: return 0
[ "def", "ex", "(", "mt", ",", "x", ")", ":", "sum1", "=", "0", "for", "j", "in", "mt", ".", "lx", "[", "x", "+", "1", ":", "-", "1", "]", ":", "sum1", "+=", "j", "#print sum1", "try", ":", "return", "sum1", "/", "mt", ".", "lx", "[", "x", ...
ex : Returns the curtate expectation of life. Life expectancy
[ "ex", ":", "Returns", "the", "curtate", "expectation", "of", "life", ".", "Life", "expectancy" ]
8d906bed04df1ba00fa1cacc6f31030ce5ab6233
https://github.com/franciscogarate/pyliferisk/blob/8d906bed04df1ba00fa1cacc6f31030ce5ab6233/pyliferisk/__init__.py#L229-L238
train
franciscogarate/pyliferisk
pyliferisk/__init__.py
Sx
def Sx(mt, x): """ Return the Sx """ n = len(mt.Nx) sum1 = 0 for j in range(x, n): k = mt.Nx[j] sum1 += k return sum1
python
def Sx(mt, x): """ Return the Sx """ n = len(mt.Nx) sum1 = 0 for j in range(x, n): k = mt.Nx[j] sum1 += k return sum1
[ "def", "Sx", "(", "mt", ",", "x", ")", ":", "n", "=", "len", "(", "mt", ".", "Nx", ")", "sum1", "=", "0", "for", "j", "in", "range", "(", "x", ",", "n", ")", ":", "k", "=", "mt", ".", "Nx", "[", "j", "]", "sum1", "+=", "k", "return", ...
Return the Sx
[ "Return", "the", "Sx" ]
8d906bed04df1ba00fa1cacc6f31030ce5ab6233
https://github.com/franciscogarate/pyliferisk/blob/8d906bed04df1ba00fa1cacc6f31030ce5ab6233/pyliferisk/__init__.py#L259-L266
train
franciscogarate/pyliferisk
pyliferisk/__init__.py
Cx
def Cx(mt, x): """ Return the Cx """ return ((1 / (1 + mt.i)) ** (x + 1)) * mt.dx[x] * ((1 + mt.i) ** 0.5)
python
def Cx(mt, x): """ Return the Cx """ return ((1 / (1 + mt.i)) ** (x + 1)) * mt.dx[x] * ((1 + mt.i) ** 0.5)
[ "def", "Cx", "(", "mt", ",", "x", ")", ":", "return", "(", "(", "1", "/", "(", "1", "+", "mt", ".", "i", ")", ")", "**", "(", "x", "+", "1", ")", ")", "*", "mt", ".", "dx", "[", "x", "]", "*", "(", "(", "1", "+", "mt", ".", "i", "...
Return the Cx
[ "Return", "the", "Cx" ]
8d906bed04df1ba00fa1cacc6f31030ce5ab6233
https://github.com/franciscogarate/pyliferisk/blob/8d906bed04df1ba00fa1cacc6f31030ce5ab6233/pyliferisk/__init__.py#L268-L270
train
franciscogarate/pyliferisk
pyliferisk/__init__.py
Mx
def Mx(mt, x): """ Return the Mx """ n = len(mt.Cx) sum1 = 0 for j in range(x, n): k = mt.Cx[j] sum1 += k return sum1
python
def Mx(mt, x): """ Return the Mx """ n = len(mt.Cx) sum1 = 0 for j in range(x, n): k = mt.Cx[j] sum1 += k return sum1
[ "def", "Mx", "(", "mt", ",", "x", ")", ":", "n", "=", "len", "(", "mt", ".", "Cx", ")", "sum1", "=", "0", "for", "j", "in", "range", "(", "x", ",", "n", ")", ":", "k", "=", "mt", ".", "Cx", "[", "j", "]", "sum1", "+=", "k", "return", ...
Return the Mx
[ "Return", "the", "Mx" ]
8d906bed04df1ba00fa1cacc6f31030ce5ab6233
https://github.com/franciscogarate/pyliferisk/blob/8d906bed04df1ba00fa1cacc6f31030ce5ab6233/pyliferisk/__init__.py#L272-L279
train
franciscogarate/pyliferisk
pyliferisk/__init__.py
nEx
def nEx(mt, x, n): """ nEx : Returns the EPV of a pure endowment (deferred capital). Pure endowment benefits are conditional on the survival of the policyholder. (v^n * npx) """ return mt.Dx[x + n] / mt.Dx[x]
python
def nEx(mt, x, n): """ nEx : Returns the EPV of a pure endowment (deferred capital). Pure endowment benefits are conditional on the survival of the policyholder. (v^n * npx) """ return mt.Dx[x + n] / mt.Dx[x]
[ "def", "nEx", "(", "mt", ",", "x", ",", "n", ")", ":", "return", "mt", ".", "Dx", "[", "x", "+", "n", "]", "/", "mt", ".", "Dx", "[", "x", "]" ]
nEx : Returns the EPV of a pure endowment (deferred capital). Pure endowment benefits are conditional on the survival of the policyholder. (v^n * npx)
[ "nEx", ":", "Returns", "the", "EPV", "of", "a", "pure", "endowment", "(", "deferred", "capital", ")", ".", "Pure", "endowment", "benefits", "are", "conditional", "on", "the", "survival", "of", "the", "policyholder", ".", "(", "v^n", "*", "npx", ")" ]
8d906bed04df1ba00fa1cacc6f31030ce5ab6233
https://github.com/franciscogarate/pyliferisk/blob/8d906bed04df1ba00fa1cacc6f31030ce5ab6233/pyliferisk/__init__.py#L291-L294
train
franciscogarate/pyliferisk
pyliferisk/__init__.py
Axn
def Axn(mt, x, n): """ (A^1)x:n : Returns the EPV (net single premium) of a term insurance. """ return (mt.Mx[x] - mt.Mx[x + n]) / mt.Dx[x]
python
def Axn(mt, x, n): """ (A^1)x:n : Returns the EPV (net single premium) of a term insurance. """ return (mt.Mx[x] - mt.Mx[x + n]) / mt.Dx[x]
[ "def", "Axn", "(", "mt", ",", "x", ",", "n", ")", ":", "return", "(", "mt", ".", "Mx", "[", "x", "]", "-", "mt", ".", "Mx", "[", "x", "+", "n", "]", ")", "/", "mt", ".", "Dx", "[", "x", "]" ]
(A^1)x:n : Returns the EPV (net single premium) of a term insurance.
[ "(", "A^1", ")", "x", ":", "n", ":", "Returns", "the", "EPV", "(", "net", "single", "premium", ")", "of", "a", "term", "insurance", "." ]
8d906bed04df1ba00fa1cacc6f31030ce5ab6233
https://github.com/franciscogarate/pyliferisk/blob/8d906bed04df1ba00fa1cacc6f31030ce5ab6233/pyliferisk/__init__.py#L305-L307
train
franciscogarate/pyliferisk
pyliferisk/__init__.py
AExn
def AExn(mt, x, n): """ AExn : Returns the EPV of a endowment insurance. An endowment insurance provides a combination of a term insurance and a pure endowment """ return (mt.Mx[x] - mt.Mx[x + n]) / mt.Dx[x] + mt.Dx[x + n] / mt.Dx[x]
python
def AExn(mt, x, n): """ AExn : Returns the EPV of a endowment insurance. An endowment insurance provides a combination of a term insurance and a pure endowment """ return (mt.Mx[x] - mt.Mx[x + n]) / mt.Dx[x] + mt.Dx[x + n] / mt.Dx[x]
[ "def", "AExn", "(", "mt", ",", "x", ",", "n", ")", ":", "return", "(", "mt", ".", "Mx", "[", "x", "]", "-", "mt", ".", "Mx", "[", "x", "+", "n", "]", ")", "/", "mt", ".", "Dx", "[", "x", "]", "+", "mt", ".", "Dx", "[", "x", "+", "n"...
AExn : Returns the EPV of a endowment insurance. An endowment insurance provides a combination of a term insurance and a pure endowment
[ "AExn", ":", "Returns", "the", "EPV", "of", "a", "endowment", "insurance", ".", "An", "endowment", "insurance", "provides", "a", "combination", "of", "a", "term", "insurance", "and", "a", "pure", "endowment" ]
8d906bed04df1ba00fa1cacc6f31030ce5ab6233
https://github.com/franciscogarate/pyliferisk/blob/8d906bed04df1ba00fa1cacc6f31030ce5ab6233/pyliferisk/__init__.py#L310-L314
train
franciscogarate/pyliferisk
pyliferisk/__init__.py
tAx
def tAx(mt, x, t): """ n/Ax : Returns the EPV (net single premium) of a deferred whole life insurance. """ return mt.Mx[x + t] / mt.Dx[x]
python
def tAx(mt, x, t): """ n/Ax : Returns the EPV (net single premium) of a deferred whole life insurance. """ return mt.Mx[x + t] / mt.Dx[x]
[ "def", "tAx", "(", "mt", ",", "x", ",", "t", ")", ":", "return", "mt", ".", "Mx", "[", "x", "+", "t", "]", "/", "mt", ".", "Dx", "[", "x", "]" ]
n/Ax : Returns the EPV (net single premium) of a deferred whole life insurance.
[ "n", "/", "Ax", ":", "Returns", "the", "EPV", "(", "net", "single", "premium", ")", "of", "a", "deferred", "whole", "life", "insurance", "." ]
8d906bed04df1ba00fa1cacc6f31030ce5ab6233
https://github.com/franciscogarate/pyliferisk/blob/8d906bed04df1ba00fa1cacc6f31030ce5ab6233/pyliferisk/__init__.py#L317-L319
train
franciscogarate/pyliferisk
pyliferisk/__init__.py
qAx
def qAx(mt, x, q): """ This function evaluates the APV of a geometrically increasing annual annuity-due """ q = float(q) j = (mt.i - q) / (1 + q) mtj = Actuarial(nt=mt.nt, i=j) return Ax(mtj, x)
python
def qAx(mt, x, q): """ This function evaluates the APV of a geometrically increasing annual annuity-due """ q = float(q) j = (mt.i - q) / (1 + q) mtj = Actuarial(nt=mt.nt, i=j) return Ax(mtj, x)
[ "def", "qAx", "(", "mt", ",", "x", ",", "q", ")", ":", "q", "=", "float", "(", "q", ")", "j", "=", "(", "mt", ".", "i", "-", "q", ")", "/", "(", "1", "+", "q", ")", "mtj", "=", "Actuarial", "(", "nt", "=", "mt", ".", "nt", ",", "i", ...
This function evaluates the APV of a geometrically increasing annual annuity-due
[ "This", "function", "evaluates", "the", "APV", "of", "a", "geometrically", "increasing", "annual", "annuity", "-", "due" ]
8d906bed04df1ba00fa1cacc6f31030ce5ab6233
https://github.com/franciscogarate/pyliferisk/blob/8d906bed04df1ba00fa1cacc6f31030ce5ab6233/pyliferisk/__init__.py#L333-L338
train
franciscogarate/pyliferisk
pyliferisk/__init__.py
aaxn
def aaxn(mt, x, n, m=1): """ äxn : Return the actuarial present value of a (immediate) temporal (term certain) annuity: n-year temporary life annuity-anticipatory. Payable 'm' per year at the beginning of the period """ if m == 1: return (mt.Nx[x] - mt.Nx[x + n]) / mt.Dx[x] else: r...
python
def aaxn(mt, x, n, m=1): """ äxn : Return the actuarial present value of a (immediate) temporal (term certain) annuity: n-year temporary life annuity-anticipatory. Payable 'm' per year at the beginning of the period """ if m == 1: return (mt.Nx[x] - mt.Nx[x + n]) / mt.Dx[x] else: r...
[ "def", "aaxn", "(", "mt", ",", "x", ",", "n", ",", "m", "=", "1", ")", ":", "if", "m", "==", "1", ":", "return", "(", "mt", ".", "Nx", "[", "x", "]", "-", "mt", ".", "Nx", "[", "x", "+", "n", "]", ")", "/", "mt", ".", "Dx", "[", "x"...
äxn : Return the actuarial present value of a (immediate) temporal (term certain) annuity: n-year temporary life annuity-anticipatory. Payable 'm' per year at the beginning of the period
[ "äxn", ":", "Return", "the", "actuarial", "present", "value", "of", "a", "(", "immediate", ")", "temporal", "(", "term", "certain", ")", "annuity", ":", "n", "-", "year", "temporary", "life", "annuity", "-", "anticipatory", ".", "Payable", "m", "per", "y...
8d906bed04df1ba00fa1cacc6f31030ce5ab6233
https://github.com/franciscogarate/pyliferisk/blob/8d906bed04df1ba00fa1cacc6f31030ce5ab6233/pyliferisk/__init__.py#L357-L364
train
franciscogarate/pyliferisk
pyliferisk/__init__.py
aax
def aax(mt, x, m=1): """ äx : Returns the actuarial present value of an (immediate) annuity of 1 per time period (whole life annuity-anticipatory). Payable 'm' per year at the beginning of the period """ return mt.Nx[x] / mt.Dx[x] - (float(m - 1) / float(m * 2))
python
def aax(mt, x, m=1): """ äx : Returns the actuarial present value of an (immediate) annuity of 1 per time period (whole life annuity-anticipatory). Payable 'm' per year at the beginning of the period """ return mt.Nx[x] / mt.Dx[x] - (float(m - 1) / float(m * 2))
[ "def", "aax", "(", "mt", ",", "x", ",", "m", "=", "1", ")", ":", "return", "mt", ".", "Nx", "[", "x", "]", "/", "mt", ".", "Dx", "[", "x", "]", "-", "(", "float", "(", "m", "-", "1", ")", "/", "float", "(", "m", "*", "2", ")", ")" ]
äx : Returns the actuarial present value of an (immediate) annuity of 1 per time period (whole life annuity-anticipatory). Payable 'm' per year at the beginning of the period
[ "äx", ":", "Returns", "the", "actuarial", "present", "value", "of", "an", "(", "immediate", ")", "annuity", "of", "1", "per", "time", "period", "(", "whole", "life", "annuity", "-", "anticipatory", ")", ".", "Payable", "m", "per", "year", "at", "the", ...
8d906bed04df1ba00fa1cacc6f31030ce5ab6233
https://github.com/franciscogarate/pyliferisk/blob/8d906bed04df1ba00fa1cacc6f31030ce5ab6233/pyliferisk/__init__.py#L375-L379
train
franciscogarate/pyliferisk
pyliferisk/__init__.py
ax
def ax(mt, x, m=1): """ ax : Returns the actuarial present value of an (immediate) annuity of 1 per time period (whole life annuity-late). Payable 'm' per year at the ends of the period """ return (mt.Nx[x] / mt.Dx[x] - 1) + (float(m - 1) / float(m * 2))
python
def ax(mt, x, m=1): """ ax : Returns the actuarial present value of an (immediate) annuity of 1 per time period (whole life annuity-late). Payable 'm' per year at the ends of the period """ return (mt.Nx[x] / mt.Dx[x] - 1) + (float(m - 1) / float(m * 2))
[ "def", "ax", "(", "mt", ",", "x", ",", "m", "=", "1", ")", ":", "return", "(", "mt", ".", "Nx", "[", "x", "]", "/", "mt", ".", "Dx", "[", "x", "]", "-", "1", ")", "+", "(", "float", "(", "m", "-", "1", ")", "/", "float", "(", "m", "...
ax : Returns the actuarial present value of an (immediate) annuity of 1 per time period (whole life annuity-late). Payable 'm' per year at the ends of the period
[ "ax", ":", "Returns", "the", "actuarial", "present", "value", "of", "an", "(", "immediate", ")", "annuity", "of", "1", "per", "time", "period", "(", "whole", "life", "annuity", "-", "late", ")", ".", "Payable", "m", "per", "year", "at", "the", "ends", ...
8d906bed04df1ba00fa1cacc6f31030ce5ab6233
https://github.com/franciscogarate/pyliferisk/blob/8d906bed04df1ba00fa1cacc6f31030ce5ab6233/pyliferisk/__init__.py#L381-L385
train
franciscogarate/pyliferisk
pyliferisk/__init__.py
taax
def taax(mt, x, t, m=1): """ n/äx : Return the actuarial present value of a deferred annuity (deferred n years): n-year deferred whole life annuity-anticipatory. Payable 'm' per year at the beginning of the period """ return mt.Nx[x + t] / mt.Dx[x] - ((float(m - 1) / float(m * 2)) * (1 - nEx(mt, x, t)...
python
def taax(mt, x, t, m=1): """ n/äx : Return the actuarial present value of a deferred annuity (deferred n years): n-year deferred whole life annuity-anticipatory. Payable 'm' per year at the beginning of the period """ return mt.Nx[x + t] / mt.Dx[x] - ((float(m - 1) / float(m * 2)) * (1 - nEx(mt, x, t)...
[ "def", "taax", "(", "mt", ",", "x", ",", "t", ",", "m", "=", "1", ")", ":", "return", "mt", ".", "Nx", "[", "x", "+", "t", "]", "/", "mt", ".", "Dx", "[", "x", "]", "-", "(", "(", "float", "(", "m", "-", "1", ")", "/", "float", "(", ...
n/äx : Return the actuarial present value of a deferred annuity (deferred n years): n-year deferred whole life annuity-anticipatory. Payable 'm' per year at the beginning of the period
[ "n", "/", "äx", ":", "Return", "the", "actuarial", "present", "value", "of", "a", "deferred", "annuity", "(", "deferred", "n", "years", ")", ":", "n", "-", "year", "deferred", "whole", "life", "annuity", "-", "anticipatory", ".", "Payable", "m", "per", ...
8d906bed04df1ba00fa1cacc6f31030ce5ab6233
https://github.com/franciscogarate/pyliferisk/blob/8d906bed04df1ba00fa1cacc6f31030ce5ab6233/pyliferisk/__init__.py#L393-L397
train
franciscogarate/pyliferisk
pyliferisk/__init__.py
Iaaxn
def Iaaxn(mt, x, n, *args): """ during a term certain, IAn """ return (Sx(mt, x) - Sx(nt, x + n) - n * Nx(nt, x + n)) / Dx(nt, x)
python
def Iaaxn(mt, x, n, *args): """ during a term certain, IAn """ return (Sx(mt, x) - Sx(nt, x + n) - n * Nx(nt, x + n)) / Dx(nt, x)
[ "def", "Iaaxn", "(", "mt", ",", "x", ",", "n", ",", "*", "args", ")", ":", "return", "(", "Sx", "(", "mt", ",", "x", ")", "-", "Sx", "(", "nt", ",", "x", "+", "n", ")", "-", "n", "*", "Nx", "(", "nt", ",", "x", "+", "n", ")", ")", "...
during a term certain, IAn
[ "during", "a", "term", "certain", "IAn" ]
8d906bed04df1ba00fa1cacc6f31030ce5ab6233
https://github.com/franciscogarate/pyliferisk/blob/8d906bed04df1ba00fa1cacc6f31030ce5ab6233/pyliferisk/__init__.py#L408-L410
train
franciscogarate/pyliferisk
pyliferisk/__init__.py
Iaxn
def Iaxn(mt, x, n, *args): """ during a term certain, IAn """ return (Sx(mt, x + 1) - Sx(mt, x + n + 1) - n * Nx(mt, x + n + 1)) / Dx(mt, x)
python
def Iaxn(mt, x, n, *args): """ during a term certain, IAn """ return (Sx(mt, x + 1) - Sx(mt, x + n + 1) - n * Nx(mt, x + n + 1)) / Dx(mt, x)
[ "def", "Iaxn", "(", "mt", ",", "x", ",", "n", ",", "*", "args", ")", ":", "return", "(", "Sx", "(", "mt", ",", "x", "+", "1", ")", "-", "Sx", "(", "mt", ",", "x", "+", "n", "+", "1", ")", "-", "n", "*", "Nx", "(", "mt", ",", "x", "+...
during a term certain, IAn
[ "during", "a", "term", "certain", "IAn" ]
8d906bed04df1ba00fa1cacc6f31030ce5ab6233
https://github.com/franciscogarate/pyliferisk/blob/8d906bed04df1ba00fa1cacc6f31030ce5ab6233/pyliferisk/__init__.py#L412-L414
train
franciscogarate/pyliferisk
pyliferisk/__init__.py
Iaax
def Iaax(mt, x, *args): """ (Iä)x : Returns the present value of annuity-certain at the beginning of the first year and increasing linerly. Arithmetically increasing annuity-anticipatory """ return Sx(mt, x) / Dx(mt, x)
python
def Iaax(mt, x, *args): """ (Iä)x : Returns the present value of annuity-certain at the beginning of the first year and increasing linerly. Arithmetically increasing annuity-anticipatory """ return Sx(mt, x) / Dx(mt, x)
[ "def", "Iaax", "(", "mt", ",", "x", ",", "*", "args", ")", ":", "return", "Sx", "(", "mt", ",", "x", ")", "/", "Dx", "(", "mt", ",", "x", ")" ]
(Iä)x : Returns the present value of annuity-certain at the beginning of the first year and increasing linerly. Arithmetically increasing annuity-anticipatory
[ "(", "Iä", ")", "x", ":", "Returns", "the", "present", "value", "of", "annuity", "-", "certain", "at", "the", "beginning", "of", "the", "first", "year", "and", "increasing", "linerly", ".", "Arithmetically", "increasing", "annuity", "-", "anticipatory" ]
8d906bed04df1ba00fa1cacc6f31030ce5ab6233
https://github.com/franciscogarate/pyliferisk/blob/8d906bed04df1ba00fa1cacc6f31030ce5ab6233/pyliferisk/__init__.py#L416-L420
train
franciscogarate/pyliferisk
pyliferisk/__init__.py
Iax
def Iax(mt, x, *args): """ (Ia)x : Returns the present value of annuity-certain at the end of the first year and increasing linerly. Arithmetically increasing annuity-late """ return Sx(mt, x + 1) / Dx(mt, x)
python
def Iax(mt, x, *args): """ (Ia)x : Returns the present value of annuity-certain at the end of the first year and increasing linerly. Arithmetically increasing annuity-late """ return Sx(mt, x + 1) / Dx(mt, x)
[ "def", "Iax", "(", "mt", ",", "x", ",", "*", "args", ")", ":", "return", "Sx", "(", "mt", ",", "x", "+", "1", ")", "/", "Dx", "(", "mt", ",", "x", ")" ]
(Ia)x : Returns the present value of annuity-certain at the end of the first year and increasing linerly. Arithmetically increasing annuity-late
[ "(", "Ia", ")", "x", ":", "Returns", "the", "present", "value", "of", "annuity", "-", "certain", "at", "the", "end", "of", "the", "first", "year", "and", "increasing", "linerly", ".", "Arithmetically", "increasing", "annuity", "-", "late" ]
8d906bed04df1ba00fa1cacc6f31030ce5ab6233
https://github.com/franciscogarate/pyliferisk/blob/8d906bed04df1ba00fa1cacc6f31030ce5ab6233/pyliferisk/__init__.py#L422-L426
train
franciscogarate/pyliferisk
pyliferisk/__init__.py
Itaax
def Itaax(mt, x, t): """ deffered t years """ return (Sx(mt, x) - Sx(mt, x + t)) / Dx(mt, x)
python
def Itaax(mt, x, t): """ deffered t years """ return (Sx(mt, x) - Sx(mt, x + t)) / Dx(mt, x)
[ "def", "Itaax", "(", "mt", ",", "x", ",", "t", ")", ":", "return", "(", "Sx", "(", "mt", ",", "x", ")", "-", "Sx", "(", "mt", ",", "x", "+", "t", ")", ")", "/", "Dx", "(", "mt", ",", "x", ")" ]
deffered t years
[ "deffered", "t", "years" ]
8d906bed04df1ba00fa1cacc6f31030ce5ab6233
https://github.com/franciscogarate/pyliferisk/blob/8d906bed04df1ba00fa1cacc6f31030ce5ab6233/pyliferisk/__init__.py#L434-L436
train
franciscogarate/pyliferisk
pyliferisk/__init__.py
Itax
def Itax(mt, x, t): """ deffered t years """ return (Sx(mt, x + 1) - Sx(mt, x + t + 1)) / Dx(mt, x)
python
def Itax(mt, x, t): """ deffered t years """ return (Sx(mt, x + 1) - Sx(mt, x + t + 1)) / Dx(mt, x)
[ "def", "Itax", "(", "mt", ",", "x", ",", "t", ")", ":", "return", "(", "Sx", "(", "mt", ",", "x", "+", "1", ")", "-", "Sx", "(", "mt", ",", "x", "+", "t", "+", "1", ")", ")", "/", "Dx", "(", "mt", ",", "x", ")" ]
deffered t years
[ "deffered", "t", "years" ]
8d906bed04df1ba00fa1cacc6f31030ce5ab6233
https://github.com/franciscogarate/pyliferisk/blob/8d906bed04df1ba00fa1cacc6f31030ce5ab6233/pyliferisk/__init__.py#L438-L440
train
franciscogarate/pyliferisk
pyliferisk/__init__.py
qax
def qax(mt, x, q, m=1): """ geometrica """ q = float(q) j = (mt.i - q) / (1 + q) mtj = Actuarial(nt=mt.nt, i=j) return ax(mtj, x, m)
python
def qax(mt, x, q, m=1): """ geometrica """ q = float(q) j = (mt.i - q) / (1 + q) mtj = Actuarial(nt=mt.nt, i=j) return ax(mtj, x, m)
[ "def", "qax", "(", "mt", ",", "x", ",", "q", ",", "m", "=", "1", ")", ":", "q", "=", "float", "(", "q", ")", "j", "=", "(", "mt", ".", "i", "-", "q", ")", "/", "(", "1", "+", "q", ")", "mtj", "=", "Actuarial", "(", "nt", "=", "mt", ...
geometrica
[ "geometrica" ]
8d906bed04df1ba00fa1cacc6f31030ce5ab6233
https://github.com/franciscogarate/pyliferisk/blob/8d906bed04df1ba00fa1cacc6f31030ce5ab6233/pyliferisk/__init__.py#L443-L448
train
franciscogarate/pyliferisk
pyliferisk/__init__.py
qaax
def qaax(mt, x, q, m=1): """ geometrica """ q = float(q) j = (mt.i - q) / (1 + q) mtj = Actuarial(nt=mt.nt, i=j) return aax(mtj, x, m)
python
def qaax(mt, x, q, m=1): """ geometrica """ q = float(q) j = (mt.i - q) / (1 + q) mtj = Actuarial(nt=mt.nt, i=j) return aax(mtj, x, m)
[ "def", "qaax", "(", "mt", ",", "x", ",", "q", ",", "m", "=", "1", ")", ":", "q", "=", "float", "(", "q", ")", "j", "=", "(", "mt", ".", "i", "-", "q", ")", "/", "(", "1", "+", "q", ")", "mtj", "=", "Actuarial", "(", "nt", "=", "mt", ...
geometrica
[ "geometrica" ]
8d906bed04df1ba00fa1cacc6f31030ce5ab6233
https://github.com/franciscogarate/pyliferisk/blob/8d906bed04df1ba00fa1cacc6f31030ce5ab6233/pyliferisk/__init__.py#L450-L455
train
franciscogarate/pyliferisk
pyliferisk/__init__.py
qaxn
def qaxn(mt, x, n, q, m=1): """ geometrica """ q = float(q) j = (mt.i - q) / (1 + q) mtj = Actuarial(nt=mt.nt, i=j) return axn(mtj, x, n, m)
python
def qaxn(mt, x, n, q, m=1): """ geometrica """ q = float(q) j = (mt.i - q) / (1 + q) mtj = Actuarial(nt=mt.nt, i=j) return axn(mtj, x, n, m)
[ "def", "qaxn", "(", "mt", ",", "x", ",", "n", ",", "q", ",", "m", "=", "1", ")", ":", "q", "=", "float", "(", "q", ")", "j", "=", "(", "mt", ".", "i", "-", "q", ")", "/", "(", "1", "+", "q", ")", "mtj", "=", "Actuarial", "(", "nt", ...
geometrica
[ "geometrica" ]
8d906bed04df1ba00fa1cacc6f31030ce5ab6233
https://github.com/franciscogarate/pyliferisk/blob/8d906bed04df1ba00fa1cacc6f31030ce5ab6233/pyliferisk/__init__.py#L457-L462
train
franciscogarate/pyliferisk
pyliferisk/__init__.py
qaaxn
def qaaxn(mt, x, n, q, m = 1): """ geometrica """ #i = float(nt[1]) q = float(q) j = (mt.i - q) / (1 + q) mtj = Actuarial(nt=mt.nt, i=j) return aaxn(mtj, x, n, m)
python
def qaaxn(mt, x, n, q, m = 1): """ geometrica """ #i = float(nt[1]) q = float(q) j = (mt.i - q) / (1 + q) mtj = Actuarial(nt=mt.nt, i=j) return aaxn(mtj, x, n, m)
[ "def", "qaaxn", "(", "mt", ",", "x", ",", "n", ",", "q", ",", "m", "=", "1", ")", ":", "#i = float(nt[1])", "q", "=", "float", "(", "q", ")", "j", "=", "(", "mt", ".", "i", "-", "q", ")", "/", "(", "1", "+", "q", ")", "mtj", "=", "Actua...
geometrica
[ "geometrica" ]
8d906bed04df1ba00fa1cacc6f31030ce5ab6233
https://github.com/franciscogarate/pyliferisk/blob/8d906bed04df1ba00fa1cacc6f31030ce5ab6233/pyliferisk/__init__.py#L464-L470
train
franciscogarate/pyliferisk
pyliferisk/__init__.py
qtax
def qtax(mt, x, t, q, m=1): """ geometrica """ q = float(q) j = (mt.i - q) / (1 + q) mtj = Actuarial(nt=mt.nt, i=j) return tax(mtj, x, t) + ((float(m - 1) / float(m * 2)) * (1 - nEx(mt, x, t)))
python
def qtax(mt, x, t, q, m=1): """ geometrica """ q = float(q) j = (mt.i - q) / (1 + q) mtj = Actuarial(nt=mt.nt, i=j) return tax(mtj, x, t) + ((float(m - 1) / float(m * 2)) * (1 - nEx(mt, x, t)))
[ "def", "qtax", "(", "mt", ",", "x", ",", "t", ",", "q", ",", "m", "=", "1", ")", ":", "q", "=", "float", "(", "q", ")", "j", "=", "(", "mt", ".", "i", "-", "q", ")", "/", "(", "1", "+", "q", ")", "mtj", "=", "Actuarial", "(", "nt", ...
geometrica
[ "geometrica" ]
8d906bed04df1ba00fa1cacc6f31030ce5ab6233
https://github.com/franciscogarate/pyliferisk/blob/8d906bed04df1ba00fa1cacc6f31030ce5ab6233/pyliferisk/__init__.py#L472-L477
train
franciscogarate/pyliferisk
pyliferisk/__init__.py
qtaax
def qtaax(mt, x, t, q, m=1): """ geometrica """ q = float(q) j = (mt.i - q) / (1 + q) mtj = Actuarial(nt=mt.nt, i=j) return taax(mtj, x, t) - ((float(m - 1) / float(m * 2)) * (1 - nEx(mt, x, t)))
python
def qtaax(mt, x, t, q, m=1): """ geometrica """ q = float(q) j = (mt.i - q) / (1 + q) mtj = Actuarial(nt=mt.nt, i=j) return taax(mtj, x, t) - ((float(m - 1) / float(m * 2)) * (1 - nEx(mt, x, t)))
[ "def", "qtaax", "(", "mt", ",", "x", ",", "t", ",", "q", ",", "m", "=", "1", ")", ":", "q", "=", "float", "(", "q", ")", "j", "=", "(", "mt", ".", "i", "-", "q", ")", "/", "(", "1", "+", "q", ")", "mtj", "=", "Actuarial", "(", "nt", ...
geometrica
[ "geometrica" ]
8d906bed04df1ba00fa1cacc6f31030ce5ab6233
https://github.com/franciscogarate/pyliferisk/blob/8d906bed04df1ba00fa1cacc6f31030ce5ab6233/pyliferisk/__init__.py#L479-L484
train