id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
45,200
aisthesis/pynance
pynance/opt/price.py
Price.exps
def exps(self, opttype, strike): """ Prices for given strike on all available dates. Parameters ---------- opttype : str ('call' or 'put') strike : numeric Returns ---------- df : :class:`pandas.DataFrame` eq : float Price of ...
python
def exps(self, opttype, strike): """ Prices for given strike on all available dates. Parameters ---------- opttype : str ('call' or 'put') strike : numeric Returns ---------- df : :class:`pandas.DataFrame` eq : float Price of ...
[ "def", "exps", "(", "self", ",", "opttype", ",", "strike", ")", ":", "_relevant", "=", "_relevant_rows", "(", "self", ".", "data", ",", "(", "strike", ",", "slice", "(", "None", ")", ",", "opttype", ",", ")", ",", "\"No key for {} {}\"", ".", "format",...
Prices for given strike on all available dates. Parameters ---------- opttype : str ('call' or 'put') strike : numeric Returns ---------- df : :class:`pandas.DataFrame` eq : float Price of underlying. qt : :class:`datetime.datetime` ...
[ "Prices", "for", "given", "strike", "on", "all", "available", "dates", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/opt/price.py#L150-L182
45,201
aisthesis/pynance
pynance/data/combine.py
labeledfeatures
def labeledfeatures(eqdata, featurefunc, labelfunc): """ Return features and labels for the given equity data. Each row of the features returned contains `2 * n_sessions + 1` columns (or 1 less if the constant feature is excluded). After the constant feature, if present, there will be `n_sessions` ...
python
def labeledfeatures(eqdata, featurefunc, labelfunc): """ Return features and labels for the given equity data. Each row of the features returned contains `2 * n_sessions + 1` columns (or 1 less if the constant feature is excluded). After the constant feature, if present, there will be `n_sessions` ...
[ "def", "labeledfeatures", "(", "eqdata", ",", "featurefunc", ",", "labelfunc", ")", ":", "_size", "=", "len", "(", "eqdata", ".", "index", ")", "_labels", ",", "_skipatend", "=", "labelfunc", "(", "eqdata", ")", "_features", ",", "_skipatstart", "=", "feat...
Return features and labels for the given equity data. Each row of the features returned contains `2 * n_sessions + 1` columns (or 1 less if the constant feature is excluded). After the constant feature, if present, there will be `n_sessions` columns derived from daily growth of the given price column, ...
[ "Return", "features", "and", "labels", "for", "the", "given", "equity", "data", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/data/combine.py#L15-L76
45,202
aisthesis/pynance
pynance/data/lab.py
growth
def growth(interval, pricecol, eqdata): """ Retrieve growth labels. Parameters -------------- interval : int Number of sessions over which growth is measured. For example, if the value of 32 is passed for `interval`, the data returned will show the growth 32 sessions ahead ...
python
def growth(interval, pricecol, eqdata): """ Retrieve growth labels. Parameters -------------- interval : int Number of sessions over which growth is measured. For example, if the value of 32 is passed for `interval`, the data returned will show the growth 32 sessions ahead ...
[ "def", "growth", "(", "interval", ",", "pricecol", ",", "eqdata", ")", ":", "size", "=", "len", "(", "eqdata", ".", "index", ")", "labeldata", "=", "eqdata", ".", "loc", "[", ":", ",", "pricecol", "]", ".", "values", "[", "interval", ":", "]", "/",...
Retrieve growth labels. Parameters -------------- interval : int Number of sessions over which growth is measured. For example, if the value of 32 is passed for `interval`, the data returned will show the growth 32 sessions ahead for each data point. eqdata : DataFrame ...
[ "Retrieve", "growth", "labels", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/data/lab.py#L22-L56
45,203
aisthesis/pynance
pynance/tech/movave.py
sma
def sma(eqdata, **kwargs): """ simple moving average Parameters ---------- eqdata : DataFrame window : int, optional Lookback period for sma. Defaults to 20. outputcol : str, optional Column to use for output. Defaults to 'SMA'. selection : str, optional Column...
python
def sma(eqdata, **kwargs): """ simple moving average Parameters ---------- eqdata : DataFrame window : int, optional Lookback period for sma. Defaults to 20. outputcol : str, optional Column to use for output. Defaults to 'SMA'. selection : str, optional Column...
[ "def", "sma", "(", "eqdata", ",", "*", "*", "kwargs", ")", ":", "if", "len", "(", "eqdata", ".", "shape", ")", ">", "1", "and", "eqdata", ".", "shape", "[", "1", "]", "!=", "1", ":", "_selection", "=", "kwargs", ".", "get", "(", "'selection'", ...
simple moving average Parameters ---------- eqdata : DataFrame window : int, optional Lookback period for sma. Defaults to 20. outputcol : str, optional Column to use for output. Defaults to 'SMA'. selection : str, optional Column of eqdata on which to calculate sma. If...
[ "simple", "moving", "average" ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/tech/movave.py#L18-L44
45,204
aisthesis/pynance
pynance/tech/movave.py
ema
def ema(eqdata, **kwargs): """ Exponential moving average with the given span. Parameters ---------- eqdata : DataFrame Must have exactly 1 column on which to calculate EMA span : int, optional Span for exponential moving average. Cf. `pandas.stats.moments.ewma <http://...
python
def ema(eqdata, **kwargs): """ Exponential moving average with the given span. Parameters ---------- eqdata : DataFrame Must have exactly 1 column on which to calculate EMA span : int, optional Span for exponential moving average. Cf. `pandas.stats.moments.ewma <http://...
[ "def", "ema", "(", "eqdata", ",", "*", "*", "kwargs", ")", ":", "if", "len", "(", "eqdata", ".", "shape", ")", ">", "1", "and", "eqdata", ".", "shape", "[", "1", "]", "!=", "1", ":", "_selection", "=", "kwargs", ".", "get", "(", "'selection'", ...
Exponential moving average with the given span. Parameters ---------- eqdata : DataFrame Must have exactly 1 column on which to calculate EMA span : int, optional Span for exponential moving average. Cf. `pandas.stats.moments.ewma <http://pandas.pydata.org/pandas-docs/stable/ge...
[ "Exponential", "moving", "average", "with", "the", "given", "span", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/tech/movave.py#L46-L81
45,205
aisthesis/pynance
pynance/tech/movave.py
ema_growth
def ema_growth(eqdata, **kwargs): """ Growth of exponential moving average. Parameters ---------- eqdata : DataFrame span : int, optional Span for exponential moving average. Defaults to 20. outputcol : str, optional. Column to use for output. Defaults to 'EMA Growth'. s...
python
def ema_growth(eqdata, **kwargs): """ Growth of exponential moving average. Parameters ---------- eqdata : DataFrame span : int, optional Span for exponential moving average. Defaults to 20. outputcol : str, optional. Column to use for output. Defaults to 'EMA Growth'. s...
[ "def", "ema_growth", "(", "eqdata", ",", "*", "*", "kwargs", ")", ":", "_growth_outputcol", "=", "kwargs", ".", "get", "(", "'outputcol'", ",", "'EMA Growth'", ")", "_ema_outputcol", "=", "'EMA'", "kwargs", "[", "'outputcol'", "]", "=", "_ema_outputcol", "_e...
Growth of exponential moving average. Parameters ---------- eqdata : DataFrame span : int, optional Span for exponential moving average. Defaults to 20. outputcol : str, optional. Column to use for output. Defaults to 'EMA Growth'. selection : str, optional Column of eqd...
[ "Growth", "of", "exponential", "moving", "average", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/tech/movave.py#L83-L109
45,206
aisthesis/pynance
pynance/tech/movave.py
growth_volatility
def growth_volatility(eqdata, **kwargs): """ Return the volatility of growth. Note that, like :func:`pynance.tech.simple.growth` but in contrast to :func:`volatility`, :func:`growth_volatility` applies directly to a dataframe like that returned by :func:`pynance.data.retrieve.get`, not necess...
python
def growth_volatility(eqdata, **kwargs): """ Return the volatility of growth. Note that, like :func:`pynance.tech.simple.growth` but in contrast to :func:`volatility`, :func:`growth_volatility` applies directly to a dataframe like that returned by :func:`pynance.data.retrieve.get`, not necess...
[ "def", "growth_volatility", "(", "eqdata", ",", "*", "*", "kwargs", ")", ":", "_window", "=", "kwargs", ".", "get", "(", "'window'", ",", "20", ")", "_selection", "=", "kwargs", ".", "get", "(", "'selection'", ",", "'Adj Close'", ")", "_outputcol", "=", ...
Return the volatility of growth. Note that, like :func:`pynance.tech.simple.growth` but in contrast to :func:`volatility`, :func:`growth_volatility` applies directly to a dataframe like that returned by :func:`pynance.data.retrieve.get`, not necessarily to a single-column dataframe. Parameters ...
[ "Return", "the", "volatility", "of", "growth", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/tech/movave.py#L144-L176
45,207
aisthesis/pynance
pynance/tech/movave.py
ratio_to_ave
def ratio_to_ave(window, eqdata, **kwargs): """ Return values expressed as ratios to the average over some number of prior sessions. Parameters ---------- eqdata : DataFrame Must contain a column with name matching `selection`, or, if `selection` is not specified, a column named...
python
def ratio_to_ave(window, eqdata, **kwargs): """ Return values expressed as ratios to the average over some number of prior sessions. Parameters ---------- eqdata : DataFrame Must contain a column with name matching `selection`, or, if `selection` is not specified, a column named...
[ "def", "ratio_to_ave", "(", "window", ",", "eqdata", ",", "*", "*", "kwargs", ")", ":", "_selection", "=", "kwargs", ".", "get", "(", "'selection'", ",", "'Volume'", ")", "_skipstartrows", "=", "kwargs", ".", "get", "(", "'skipstartrows'", ",", "0", ")",...
Return values expressed as ratios to the average over some number of prior sessions. Parameters ---------- eqdata : DataFrame Must contain a column with name matching `selection`, or, if `selection` is not specified, a column named 'Volume' window : int Interval over which t...
[ "Return", "values", "expressed", "as", "ratios", "to", "the", "average", "over", "some", "number", "of", "prior", "sessions", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/tech/movave.py#L222-L259
45,208
aisthesis/pynance
pynance/learn/linreg.py
run
def run(features, labels, regularization=0., constfeat=True): """ Run linear regression on the given data. .. versionadded:: 0.5.0 If a regularization parameter is provided, this function is a simplification and specialization of ridge regression, as implemented in `scikit-learn <http://sc...
python
def run(features, labels, regularization=0., constfeat=True): """ Run linear regression on the given data. .. versionadded:: 0.5.0 If a regularization parameter is provided, this function is a simplification and specialization of ridge regression, as implemented in `scikit-learn <http://sc...
[ "def", "run", "(", "features", ",", "labels", ",", "regularization", "=", "0.", ",", "constfeat", "=", "True", ")", ":", "n_col", "=", "(", "features", ".", "shape", "[", "1", "]", "if", "len", "(", "features", ".", "shape", ")", ">", "1", "else", ...
Run linear regression on the given data. .. versionadded:: 0.5.0 If a regularization parameter is provided, this function is a simplification and specialization of ridge regression, as implemented in `scikit-learn <http://scikit-learn.org/stable/modules/generated/sklearn.linear_model.Ridge.html#sk...
[ "Run", "linear", "regression", "on", "the", "given", "data", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/learn/linreg.py#L13-L53
45,209
aisthesis/pynance
pynance/opt/spread/core.py
Spread.cal
def cal(self, opttype, strike, exp1, exp2): """ Metrics for evaluating a calendar spread. Parameters ------------ opttype : str ('call' or 'put') Type of option on which to collect data. strike : numeric Strike price. exp1 : date or date s...
python
def cal(self, opttype, strike, exp1, exp2): """ Metrics for evaluating a calendar spread. Parameters ------------ opttype : str ('call' or 'put') Type of option on which to collect data. strike : numeric Strike price. exp1 : date or date s...
[ "def", "cal", "(", "self", ",", "opttype", ",", "strike", ",", "exp1", ",", "exp2", ")", ":", "assert", "pd", ".", "Timestamp", "(", "exp1", ")", "<", "pd", ".", "Timestamp", "(", "exp2", ")", "_row1", "=", "_relevant_rows", "(", "self", ".", "data...
Metrics for evaluating a calendar spread. Parameters ------------ opttype : str ('call' or 'put') Type of option on which to collect data. strike : numeric Strike price. exp1 : date or date str (e.g. '2015-01-01') Earlier expiration date. ...
[ "Metrics", "for", "evaluating", "a", "calendar", "spread", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/opt/spread/core.py#L53-L84
45,210
aisthesis/pynance
pynance/common.py
expand
def expand(fn, col, inputtype=pd.DataFrame): """ Wrap a function applying to a single column to make a function applying to a multi-dimensional dataframe or ndarray Parameters ---------- fn : function Function that applies to a series or vector. col : str or int Index of co...
python
def expand(fn, col, inputtype=pd.DataFrame): """ Wrap a function applying to a single column to make a function applying to a multi-dimensional dataframe or ndarray Parameters ---------- fn : function Function that applies to a series or vector. col : str or int Index of co...
[ "def", "expand", "(", "fn", ",", "col", ",", "inputtype", "=", "pd", ".", "DataFrame", ")", ":", "if", "inputtype", "==", "pd", ".", "DataFrame", ":", "if", "isinstance", "(", "col", ",", "int", ")", ":", "def", "_wrapper", "(", "*", "args", ",", ...
Wrap a function applying to a single column to make a function applying to a multi-dimensional dataframe or ndarray Parameters ---------- fn : function Function that applies to a series or vector. col : str or int Index of column to which to apply `fn`. inputtype : class or ty...
[ "Wrap", "a", "function", "applying", "to", "a", "single", "column", "to", "make", "a", "function", "applying", "to", "a", "multi", "-", "dimensional", "dataframe", "or", "ndarray" ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/common.py#L121-L156
45,211
aisthesis/pynance
pynance/common.py
has_na
def has_na(eqdata): """ Return false if `eqdata` contains no missing values. Parameters ---------- eqdata : DataFrame or ndarray Data to check for missing values (NaN, None) Returns ---------- answer : bool False iff `eqdata` contains no missing values. """ if i...
python
def has_na(eqdata): """ Return false if `eqdata` contains no missing values. Parameters ---------- eqdata : DataFrame or ndarray Data to check for missing values (NaN, None) Returns ---------- answer : bool False iff `eqdata` contains no missing values. """ if i...
[ "def", "has_na", "(", "eqdata", ")", ":", "if", "isinstance", "(", "eqdata", ",", "pd", ".", "DataFrame", ")", ":", "_values", "=", "eqdata", ".", "values", "else", ":", "_values", "=", "eqdata", "return", "len", "(", "_values", "[", "pd", ".", "isnu...
Return false if `eqdata` contains no missing values. Parameters ---------- eqdata : DataFrame or ndarray Data to check for missing values (NaN, None) Returns ---------- answer : bool False iff `eqdata` contains no missing values.
[ "Return", "false", "if", "eqdata", "contains", "no", "missing", "values", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/common.py#L158-L176
45,212
aisthesis/pynance
pynance/data/feat.py
add_const
def add_const(features): """ Prepend the constant feature 1 as first feature and return the modified feature set. Parameters ---------- features : ndarray or DataFrame """ content = np.empty((features.shape[0], features.shape[1] + 1), dtype='float64') content[:, 0] = 1. if isins...
python
def add_const(features): """ Prepend the constant feature 1 as first feature and return the modified feature set. Parameters ---------- features : ndarray or DataFrame """ content = np.empty((features.shape[0], features.shape[1] + 1), dtype='float64') content[:, 0] = 1. if isins...
[ "def", "add_const", "(", "features", ")", ":", "content", "=", "np", ".", "empty", "(", "(", "features", ".", "shape", "[", "0", "]", ",", "features", ".", "shape", "[", "1", "]", "+", "1", ")", ",", "dtype", "=", "'float64'", ")", "content", "["...
Prepend the constant feature 1 as first feature and return the modified feature set. Parameters ---------- features : ndarray or DataFrame
[ "Prepend", "the", "constant", "feature", "1", "as", "first", "feature", "and", "return", "the", "modified", "feature", "set", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/data/feat.py#L26-L42
45,213
aisthesis/pynance
pynance/data/feat.py
fromcols
def fromcols(selection, n_sessions, eqdata, **kwargs): """ Generate features from selected columns of a dataframe. Parameters ---------- selection : list or tuple of str Columns to be used as features. n_sessions : int Number of sessions over which to create features. eqda...
python
def fromcols(selection, n_sessions, eqdata, **kwargs): """ Generate features from selected columns of a dataframe. Parameters ---------- selection : list or tuple of str Columns to be used as features. n_sessions : int Number of sessions over which to create features. eqda...
[ "def", "fromcols", "(", "selection", ",", "n_sessions", ",", "eqdata", ",", "*", "*", "kwargs", ")", ":", "_constfeat", "=", "kwargs", ".", "get", "(", "'constfeat'", ",", "True", ")", "_outcols", "=", "[", "'Constant'", "]", "if", "_constfeat", "else", ...
Generate features from selected columns of a dataframe. Parameters ---------- selection : list or tuple of str Columns to be used as features. n_sessions : int Number of sessions over which to create features. eqdata : DataFrame Data from which to generate feature set. Mus...
[ "Generate", "features", "from", "selected", "columns", "of", "a", "dataframe", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/data/feat.py#L44-L84
45,214
aisthesis/pynance
pynance/data/feat.py
fromfuncs
def fromfuncs(funcs, n_sessions, eqdata, **kwargs): """ Generate features using a list of functions to apply to input data Parameters ---------- funcs : list of function Functions to apply to eqdata. Each function is expected to output a dataframe with index identical to a slice of ...
python
def fromfuncs(funcs, n_sessions, eqdata, **kwargs): """ Generate features using a list of functions to apply to input data Parameters ---------- funcs : list of function Functions to apply to eqdata. Each function is expected to output a dataframe with index identical to a slice of ...
[ "def", "fromfuncs", "(", "funcs", ",", "n_sessions", ",", "eqdata", ",", "*", "*", "kwargs", ")", ":", "_skipatstart", "=", "kwargs", ".", "get", "(", "'skipatstart'", ",", "0", ")", "_constfeat", "=", "kwargs", ".", "get", "(", "'constfeat'", ",", "Tr...
Generate features using a list of functions to apply to input data Parameters ---------- funcs : list of function Functions to apply to eqdata. Each function is expected to output a dataframe with index identical to a slice of `eqdata`. The slice must include at least `eqdata.index[...
[ "Generate", "features", "using", "a", "list", "of", "functions", "to", "apply", "to", "input", "data" ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/data/feat.py#L86-L142
45,215
aisthesis/pynance
pynance/tech/simple.py
ln_growth
def ln_growth(eqdata, **kwargs): """ Return the natural log of growth. See also -------- :func:`growth` """ if 'outputcol' not in kwargs: kwargs['outputcol'] = 'LnGrowth' return np.log(growth(eqdata, **kwargs))
python
def ln_growth(eqdata, **kwargs): """ Return the natural log of growth. See also -------- :func:`growth` """ if 'outputcol' not in kwargs: kwargs['outputcol'] = 'LnGrowth' return np.log(growth(eqdata, **kwargs))
[ "def", "ln_growth", "(", "eqdata", ",", "*", "*", "kwargs", ")", ":", "if", "'outputcol'", "not", "in", "kwargs", ":", "kwargs", "[", "'outputcol'", "]", "=", "'LnGrowth'", "return", "np", ".", "log", "(", "growth", "(", "eqdata", ",", "*", "*", "kwa...
Return the natural log of growth. See also -------- :func:`growth`
[ "Return", "the", "natural", "log", "of", "growth", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/tech/simple.py#L71-L81
45,216
aisthesis/pynance
pynance/learn/metrics.py
mse
def mse(predicted, actual): """ Mean squared error of predictions. .. versionadded:: 0.5.0 Parameters ---------- predicted : ndarray Predictions on which to measure error. May contain a single or multiple column but must match `actual` in shape. actual : ndarray ...
python
def mse(predicted, actual): """ Mean squared error of predictions. .. versionadded:: 0.5.0 Parameters ---------- predicted : ndarray Predictions on which to measure error. May contain a single or multiple column but must match `actual` in shape. actual : ndarray ...
[ "def", "mse", "(", "predicted", ",", "actual", ")", ":", "diff", "=", "predicted", "-", "actual", "return", "np", ".", "average", "(", "diff", "*", "diff", ",", "axis", "=", "0", ")" ]
Mean squared error of predictions. .. versionadded:: 0.5.0 Parameters ---------- predicted : ndarray Predictions on which to measure error. May contain a single or multiple column but must match `actual` in shape. actual : ndarray Actual values against which to mea...
[ "Mean", "squared", "error", "of", "predictions", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/learn/metrics.py#L13-L36
45,217
aisthesis/pynance
pynance/opt/covcall.py
get
def get(eqprice, callprice, strike, shares=1, buycomm=0., excomm=0., dividend=0.): """ Metrics for covered calls. Parameters ---------- eqprice : float Price at which stock is purchased. callprice : float Price for which call is sold. strike : float Strike price of c...
python
def get(eqprice, callprice, strike, shares=1, buycomm=0., excomm=0., dividend=0.): """ Metrics for covered calls. Parameters ---------- eqprice : float Price at which stock is purchased. callprice : float Price for which call is sold. strike : float Strike price of c...
[ "def", "get", "(", "eqprice", ",", "callprice", ",", "strike", ",", "shares", "=", "1", ",", "buycomm", "=", "0.", ",", "excomm", "=", "0.", ",", "dividend", "=", "0.", ")", ":", "_index", "=", "[", "'Eq Cost'", ",", "'Option Premium'", ",", "'Commis...
Metrics for covered calls. Parameters ---------- eqprice : float Price at which stock is purchased. callprice : float Price for which call is sold. strike : float Strike price of call sold. shares : int, optional Number of shares of stock. Defaults to 1. buyc...
[ "Metrics", "for", "covered", "calls", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/opt/covcall.py#L17-L68
45,218
aisthesis/pynance
pynance/dateutils.py
is_bday
def is_bday(date, bday=None): """ Return true iff the given date is a business day. Parameters ---------- date : :class:`pandas.Timestamp` Any value that can be converted to a pandas Timestamp--e.g., '2012-05-01', dt.datetime(2012, 5, 1, 3) bday : :class:`pandas.tseries.offsets...
python
def is_bday(date, bday=None): """ Return true iff the given date is a business day. Parameters ---------- date : :class:`pandas.Timestamp` Any value that can be converted to a pandas Timestamp--e.g., '2012-05-01', dt.datetime(2012, 5, 1, 3) bday : :class:`pandas.tseries.offsets...
[ "def", "is_bday", "(", "date", ",", "bday", "=", "None", ")", ":", "_date", "=", "Timestamp", "(", "date", ")", "if", "bday", "is", "None", ":", "bday", "=", "CustomBusinessDay", "(", "calendar", "=", "USFederalHolidayCalendar", "(", ")", ")", "return", ...
Return true iff the given date is a business day. Parameters ---------- date : :class:`pandas.Timestamp` Any value that can be converted to a pandas Timestamp--e.g., '2012-05-01', dt.datetime(2012, 5, 1, 3) bday : :class:`pandas.tseries.offsets.CustomBusinessDay` Defaults to `C...
[ "Return", "true", "iff", "the", "given", "date", "is", "a", "business", "day", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/dateutils.py#L19-L45
45,219
aisthesis/pynance
pynance/data/compare.py
compare
def compare(eq_dfs, columns=None, selection='Adj Close'): """ Get the relative performance of multiple equities. .. versionadded:: 0.5.0 Parameters ---------- eq_dfs : list or tuple of DataFrame Performance data for multiple equities over a consistent time frame. columns : ...
python
def compare(eq_dfs, columns=None, selection='Adj Close'): """ Get the relative performance of multiple equities. .. versionadded:: 0.5.0 Parameters ---------- eq_dfs : list or tuple of DataFrame Performance data for multiple equities over a consistent time frame. columns : ...
[ "def", "compare", "(", "eq_dfs", ",", "columns", "=", "None", ",", "selection", "=", "'Adj Close'", ")", ":", "content", "=", "np", ".", "empty", "(", "(", "eq_dfs", "[", "0", "]", ".", "shape", "[", "0", "]", ",", "len", "(", "eq_dfs", ")", ")",...
Get the relative performance of multiple equities. .. versionadded:: 0.5.0 Parameters ---------- eq_dfs : list or tuple of DataFrame Performance data for multiple equities over a consistent time frame. columns : iterable of str, default None Labels to use for the columns of...
[ "Get", "the", "relative", "performance", "of", "multiple", "equities", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/data/compare.py#L14-L62
45,220
aisthesis/pynance
pynance/opt/spread/diag.py
Diag.diagbtrfly
def diagbtrfly(self, lowstrike, midstrike, highstrike, expiry1, expiry2): """ Metrics for evaluating a diagonal butterfly spread. Parameters ------------ opttype : str ('call' or 'put') Type of option on which to collect data. lowstrike : numeric ...
python
def diagbtrfly(self, lowstrike, midstrike, highstrike, expiry1, expiry2): """ Metrics for evaluating a diagonal butterfly spread. Parameters ------------ opttype : str ('call' or 'put') Type of option on which to collect data. lowstrike : numeric ...
[ "def", "diagbtrfly", "(", "self", ",", "lowstrike", ",", "midstrike", ",", "highstrike", ",", "expiry1", ",", "expiry2", ")", ":", "assert", "lowstrike", "<", "midstrike", "assert", "midstrike", "<", "highstrike", "assert", "pd", ".", "Timestamp", "(", "expi...
Metrics for evaluating a diagonal butterfly spread. Parameters ------------ opttype : str ('call' or 'put') Type of option on which to collect data. lowstrike : numeric Lower strike price. To be used for far put. midstrike : numeric Middle str...
[ "Metrics", "for", "evaluating", "a", "diagonal", "butterfly", "spread", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/opt/spread/diag.py#L113-L173
45,221
aisthesis/pynance
pynance/opt/core.py
Options.info
def info(self): """ Show expiration dates, equity price, quote time. Returns ------- self : :class:`~pynance.opt.core.Options` Returns a reference to the calling object to allow chaining. expiries : :class:`pandas.tseries.index.DatetimeIndex` ...
python
def info(self): """ Show expiration dates, equity price, quote time. Returns ------- self : :class:`~pynance.opt.core.Options` Returns a reference to the calling object to allow chaining. expiries : :class:`pandas.tseries.index.DatetimeIndex` ...
[ "def", "info", "(", "self", ")", ":", "print", "(", "\"Expirations:\"", ")", "_i", "=", "0", "for", "_datetime", "in", "self", ".", "data", ".", "index", ".", "levels", "[", "1", "]", ".", "to_pydatetime", "(", ")", ":", "print", "(", "\"{:2d} {}\"",...
Show expiration dates, equity price, quote time. Returns ------- self : :class:`~pynance.opt.core.Options` Returns a reference to the calling object to allow chaining. expiries : :class:`pandas.tseries.index.DatetimeIndex` Examples -------- ...
[ "Show", "expiration", "dates", "equity", "price", "quote", "time", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/opt/core.py#L69-L96
45,222
aisthesis/pynance
pynance/opt/core.py
Options.tolist
def tolist(self): """ Return the array as a list of rows. Each row is a `dict` of values. Facilitates inserting data into a database. .. versionadded:: 0.3.1 Returns ------- quotes : list A list in which each entry is a dictionary representing ...
python
def tolist(self): """ Return the array as a list of rows. Each row is a `dict` of values. Facilitates inserting data into a database. .. versionadded:: 0.3.1 Returns ------- quotes : list A list in which each entry is a dictionary representing ...
[ "def", "tolist", "(", "self", ")", ":", "return", "[", "_todict", "(", "key", ",", "self", ".", "data", ".", "loc", "[", "key", ",", ":", "]", ")", "for", "key", "in", "self", ".", "data", ".", "index", "]" ]
Return the array as a list of rows. Each row is a `dict` of values. Facilitates inserting data into a database. .. versionadded:: 0.3.1 Returns ------- quotes : list A list in which each entry is a dictionary representing a single options quote.
[ "Return", "the", "array", "as", "a", "list", "of", "rows", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/opt/core.py#L119-L133
45,223
stephrdev/django-userprofiles
userprofiles/forms.py
RegistrationForm._generate_username
def _generate_username(self): """ Generate a unique username """ while True: # Generate a UUID username, removing dashes and the last 2 chars # to make it fit into the 30 char User.username field. Gracefully # handle any unlikely, but possible duplicate usernames. ...
python
def _generate_username(self): """ Generate a unique username """ while True: # Generate a UUID username, removing dashes and the last 2 chars # to make it fit into the 30 char User.username field. Gracefully # handle any unlikely, but possible duplicate usernames. ...
[ "def", "_generate_username", "(", "self", ")", ":", "while", "True", ":", "# Generate a UUID username, removing dashes and the last 2 chars", "# to make it fit into the 30 char User.username field. Gracefully", "# handle any unlikely, but possible duplicate usernames.", "username", "=", ...
Generate a unique username
[ "Generate", "a", "unique", "username" ]
79227566abe53ee9b834709b35ae276b40114c0b
https://github.com/stephrdev/django-userprofiles/blob/79227566abe53ee9b834709b35ae276b40114c0b/userprofiles/forms.py#L44-L57
45,224
vijaykatam/django-cache-manager
django_cache_manager/models.py
update_model_cache
def update_model_cache(table_name): """ Updates model cache by generating a new key for the model """ model_cache_info = ModelCacheInfo(table_name, uuid.uuid4().hex) model_cache_backend.share_model_cache_info(model_cache_info)
python
def update_model_cache(table_name): """ Updates model cache by generating a new key for the model """ model_cache_info = ModelCacheInfo(table_name, uuid.uuid4().hex) model_cache_backend.share_model_cache_info(model_cache_info)
[ "def", "update_model_cache", "(", "table_name", ")", ":", "model_cache_info", "=", "ModelCacheInfo", "(", "table_name", ",", "uuid", ".", "uuid4", "(", ")", ".", "hex", ")", "model_cache_backend", ".", "share_model_cache_info", "(", "model_cache_info", ")" ]
Updates model cache by generating a new key for the model
[ "Updates", "model", "cache", "by", "generating", "a", "new", "key", "for", "the", "model" ]
05142c44eb349d3f24f962592945888d9d367375
https://github.com/vijaykatam/django-cache-manager/blob/05142c44eb349d3f24f962592945888d9d367375/django_cache_manager/models.py#L21-L26
45,225
vijaykatam/django-cache-manager
django_cache_manager/models.py
invalidate_model_cache
def invalidate_model_cache(sender, instance, **kwargs): """ Signal receiver for models to invalidate model cache of sender and related models. Model cache is invalidated by generating new key for each model. Parameters ~~~~~~~~~~ sender The model class instance The actual in...
python
def invalidate_model_cache(sender, instance, **kwargs): """ Signal receiver for models to invalidate model cache of sender and related models. Model cache is invalidated by generating new key for each model. Parameters ~~~~~~~~~~ sender The model class instance The actual in...
[ "def", "invalidate_model_cache", "(", "sender", ",", "instance", ",", "*", "*", "kwargs", ")", ":", "logger", ".", "debug", "(", "'Received post_save/post_delete signal from sender {0}'", ".", "format", "(", "sender", ")", ")", "if", "django", ".", "VERSION", ">...
Signal receiver for models to invalidate model cache of sender and related models. Model cache is invalidated by generating new key for each model. Parameters ~~~~~~~~~~ sender The model class instance The actual instance being saved.
[ "Signal", "receiver", "for", "models", "to", "invalidate", "model", "cache", "of", "sender", "and", "related", "models", ".", "Model", "cache", "is", "invalidated", "by", "generating", "new", "key", "for", "each", "model", "." ]
05142c44eb349d3f24f962592945888d9d367375
https://github.com/vijaykatam/django-cache-manager/blob/05142c44eb349d3f24f962592945888d9d367375/django_cache_manager/models.py#L29-L55
45,226
vijaykatam/django-cache-manager
django_cache_manager/models.py
invalidate_m2m_cache
def invalidate_m2m_cache(sender, instance, model, **kwargs): """ Signal receiver for models to invalidate model cache for many-to-many relationship. Parameters ~~~~~~~~~~ sender The model class instance The instance whose many-to-many relation is updated. model The c...
python
def invalidate_m2m_cache(sender, instance, model, **kwargs): """ Signal receiver for models to invalidate model cache for many-to-many relationship. Parameters ~~~~~~~~~~ sender The model class instance The instance whose many-to-many relation is updated. model The c...
[ "def", "invalidate_m2m_cache", "(", "sender", ",", "instance", ",", "model", ",", "*", "*", "kwargs", ")", ":", "logger", ".", "debug", "(", "'Received m2m_changed signals from sender {0}'", ".", "format", "(", "sender", ")", ")", "update_model_cache", "(", "ins...
Signal receiver for models to invalidate model cache for many-to-many relationship. Parameters ~~~~~~~~~~ sender The model class instance The instance whose many-to-many relation is updated. model The class of the objects that are added to, removed from or cleared from the r...
[ "Signal", "receiver", "for", "models", "to", "invalidate", "model", "cache", "for", "many", "-", "to", "-", "many", "relationship", "." ]
05142c44eb349d3f24f962592945888d9d367375
https://github.com/vijaykatam/django-cache-manager/blob/05142c44eb349d3f24f962592945888d9d367375/django_cache_manager/models.py#L57-L72
45,227
vijaykatam/django-cache-manager
django_cache_manager/mixins.py
CacheKeyMixin.generate_key
def generate_key(self): """ Generate cache key for the current query. If a new key is created for the model it is then shared with other consumers. """ sql = self.sql() key, created = self.get_or_create_model_key() if created: db_table = self.model._me...
python
def generate_key(self): """ Generate cache key for the current query. If a new key is created for the model it is then shared with other consumers. """ sql = self.sql() key, created = self.get_or_create_model_key() if created: db_table = self.model._me...
[ "def", "generate_key", "(", "self", ")", ":", "sql", "=", "self", ".", "sql", "(", ")", "key", ",", "created", "=", "self", ".", "get_or_create_model_key", "(", ")", "if", "created", ":", "db_table", "=", "self", ".", "model", ".", "_meta", ".", "db_...
Generate cache key for the current query. If a new key is created for the model it is then shared with other consumers.
[ "Generate", "cache", "key", "for", "the", "current", "query", ".", "If", "a", "new", "key", "is", "created", "for", "the", "model", "it", "is", "then", "shared", "with", "other", "consumers", "." ]
05142c44eb349d3f24f962592945888d9d367375
https://github.com/vijaykatam/django-cache-manager/blob/05142c44eb349d3f24f962592945888d9d367375/django_cache_manager/mixins.py#L23-L39
45,228
vijaykatam/django-cache-manager
django_cache_manager/mixins.py
CacheKeyMixin.sql
def sql(self): """ Get sql for the current query. """ clone = self.query.clone() sql, params = clone.get_compiler(using=self.db).as_sql() return sql % params
python
def sql(self): """ Get sql for the current query. """ clone = self.query.clone() sql, params = clone.get_compiler(using=self.db).as_sql() return sql % params
[ "def", "sql", "(", "self", ")", ":", "clone", "=", "self", ".", "query", ".", "clone", "(", ")", "sql", ",", "params", "=", "clone", ".", "get_compiler", "(", "using", "=", "self", ".", "db", ")", ".", "as_sql", "(", ")", "return", "sql", "%", ...
Get sql for the current query.
[ "Get", "sql", "for", "the", "current", "query", "." ]
05142c44eb349d3f24f962592945888d9d367375
https://github.com/vijaykatam/django-cache-manager/blob/05142c44eb349d3f24f962592945888d9d367375/django_cache_manager/mixins.py#L41-L47
45,229
vijaykatam/django-cache-manager
django_cache_manager/mixins.py
CacheKeyMixin.get_or_create_model_key
def get_or_create_model_key(self): """ Get or create key for the model. Returns ~~~~~~~ (model_key, boolean) tuple """ model_cache_info = model_cache_backend.retrieve_model_cache_info(self.model._meta.db_table) if not model_cache_info: return...
python
def get_or_create_model_key(self): """ Get or create key for the model. Returns ~~~~~~~ (model_key, boolean) tuple """ model_cache_info = model_cache_backend.retrieve_model_cache_info(self.model._meta.db_table) if not model_cache_info: return...
[ "def", "get_or_create_model_key", "(", "self", ")", ":", "model_cache_info", "=", "model_cache_backend", ".", "retrieve_model_cache_info", "(", "self", ".", "model", ".", "_meta", ".", "db_table", ")", "if", "not", "model_cache_info", ":", "return", "uuid", ".", ...
Get or create key for the model. Returns ~~~~~~~ (model_key, boolean) tuple
[ "Get", "or", "create", "key", "for", "the", "model", "." ]
05142c44eb349d3f24f962592945888d9d367375
https://github.com/vijaykatam/django-cache-manager/blob/05142c44eb349d3f24f962592945888d9d367375/django_cache_manager/mixins.py#L49-L61
45,230
vijaykatam/django-cache-manager
django_cache_manager/mixins.py
CacheInvalidateMixin.invalidate_model_cache
def invalidate_model_cache(self): """ Invalidate model cache by generating new key for the model. """ logger.info('Invalidating cache for table {0}'.format(self.model._meta.db_table)) if django.VERSION >= (1, 8): related_tables = set( [f.related_model....
python
def invalidate_model_cache(self): """ Invalidate model cache by generating new key for the model. """ logger.info('Invalidating cache for table {0}'.format(self.model._meta.db_table)) if django.VERSION >= (1, 8): related_tables = set( [f.related_model....
[ "def", "invalidate_model_cache", "(", "self", ")", ":", "logger", ".", "info", "(", "'Invalidating cache for table {0}'", ".", "format", "(", "self", ".", "model", ".", "_meta", ".", "db_table", ")", ")", "if", "django", ".", "VERSION", ">=", "(", "1", ","...
Invalidate model cache by generating new key for the model.
[ "Invalidate", "model", "cache", "by", "generating", "new", "key", "for", "the", "model", "." ]
05142c44eb349d3f24f962592945888d9d367375
https://github.com/vijaykatam/django-cache-manager/blob/05142c44eb349d3f24f962592945888d9d367375/django_cache_manager/mixins.py#L66-L84
45,231
vijaykatam/django-cache-manager
django_cache_manager/mixins.py
CacheBackendMixin.cache_backend
def cache_backend(self): """ Get the cache backend Returns ~~~~~~~ Django cache backend """ if not hasattr(self, '_cache_backend'): if hasattr(django.core.cache, 'caches'): self._cache_backend = django.core.cache.caches[_cache_name] ...
python
def cache_backend(self): """ Get the cache backend Returns ~~~~~~~ Django cache backend """ if not hasattr(self, '_cache_backend'): if hasattr(django.core.cache, 'caches'): self._cache_backend = django.core.cache.caches[_cache_name] ...
[ "def", "cache_backend", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'_cache_backend'", ")", ":", "if", "hasattr", "(", "django", ".", "core", ".", "cache", ",", "'caches'", ")", ":", "self", ".", "_cache_backend", "=", "django", "...
Get the cache backend Returns ~~~~~~~ Django cache backend
[ "Get", "the", "cache", "backend" ]
05142c44eb349d3f24f962592945888d9d367375
https://github.com/vijaykatam/django-cache-manager/blob/05142c44eb349d3f24f962592945888d9d367375/django_cache_manager/mixins.py#L90-L105
45,232
UDST/orca
orca/server/server.py
import_file
def import_file(filename): """ Import a file that will trigger the population of Orca. Parameters ---------- filename : str """ pathname, filename = os.path.split(filename) modname = re.match( r'(?P<modname>\w+)\.py', filename).group('modname') file, path, desc = imp.find_m...
python
def import_file(filename): """ Import a file that will trigger the population of Orca. Parameters ---------- filename : str """ pathname, filename = os.path.split(filename) modname = re.match( r'(?P<modname>\w+)\.py', filename).group('modname') file, path, desc = imp.find_m...
[ "def", "import_file", "(", "filename", ")", ":", "pathname", ",", "filename", "=", "os", ".", "path", ".", "split", "(", "filename", ")", "modname", "=", "re", ".", "match", "(", "r'(?P<modname>\\w+)\\.py'", ",", "filename", ")", ".", "group", "(", "'mod...
Import a file that will trigger the population of Orca. Parameters ---------- filename : str
[ "Import", "a", "file", "that", "will", "trigger", "the", "population", "of", "Orca", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/server/server.py#L27-L44
45,233
UDST/orca
orca/server/server.py
check_is_table
def check_is_table(func): """ Decorator that will check whether the "table_name" keyword argument to the wrapped function matches a registered Orca table. """ @wraps(func) def wrapper(**kwargs): if not orca.is_table(kwargs['table_name']): abort(404) return func(**kwa...
python
def check_is_table(func): """ Decorator that will check whether the "table_name" keyword argument to the wrapped function matches a registered Orca table. """ @wraps(func) def wrapper(**kwargs): if not orca.is_table(kwargs['table_name']): abort(404) return func(**kwa...
[ "def", "check_is_table", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "*", "kwargs", ")", ":", "if", "not", "orca", ".", "is_table", "(", "kwargs", "[", "'table_name'", "]", ")", ":", "abort", "(", "404", ")", ...
Decorator that will check whether the "table_name" keyword argument to the wrapped function matches a registered Orca table.
[ "Decorator", "that", "will", "check", "whether", "the", "table_name", "keyword", "argument", "to", "the", "wrapped", "function", "matches", "a", "registered", "Orca", "table", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/server/server.py#L47-L58
45,234
UDST/orca
orca/server/server.py
check_is_column
def check_is_column(func): """ Decorator that will check whether the "table_name" and "col_name" keyword arguments to the wrapped function match a registered Orca table and column. """ @wraps(func) def wrapper(**kwargs): table_name = kwargs['table_name'] col_name = kwargs['c...
python
def check_is_column(func): """ Decorator that will check whether the "table_name" and "col_name" keyword arguments to the wrapped function match a registered Orca table and column. """ @wraps(func) def wrapper(**kwargs): table_name = kwargs['table_name'] col_name = kwargs['c...
[ "def", "check_is_column", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "*", "kwargs", ")", ":", "table_name", "=", "kwargs", "[", "'table_name'", "]", "col_name", "=", "kwargs", "[", "'col_name'", "]", "if", "not",...
Decorator that will check whether the "table_name" and "col_name" keyword arguments to the wrapped function match a registered Orca table and column.
[ "Decorator", "that", "will", "check", "whether", "the", "table_name", "and", "col_name", "keyword", "arguments", "to", "the", "wrapped", "function", "match", "a", "registered", "Orca", "table", "and", "column", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/server/server.py#L61-L78
45,235
UDST/orca
orca/server/server.py
check_is_injectable
def check_is_injectable(func): """ Decorator that will check whether the "inj_name" keyword argument to the wrapped function matches a registered Orca injectable. """ @wraps(func) def wrapper(**kwargs): name = kwargs['inj_name'] if not orca.is_injectable(name): abort...
python
def check_is_injectable(func): """ Decorator that will check whether the "inj_name" keyword argument to the wrapped function matches a registered Orca injectable. """ @wraps(func) def wrapper(**kwargs): name = kwargs['inj_name'] if not orca.is_injectable(name): abort...
[ "def", "check_is_injectable", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "*", "kwargs", ")", ":", "name", "=", "kwargs", "[", "'inj_name'", "]", "if", "not", "orca", ".", "is_injectable", "(", "name", ")", ":",...
Decorator that will check whether the "inj_name" keyword argument to the wrapped function matches a registered Orca injectable.
[ "Decorator", "that", "will", "check", "whether", "the", "inj_name", "keyword", "argument", "to", "the", "wrapped", "function", "matches", "a", "registered", "Orca", "injectable", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/server/server.py#L81-L93
45,236
UDST/orca
orca/server/server.py
schema
def schema(): """ All tables, columns, steps, injectables and broadcasts registered with Orca. Includes local columns on tables. """ tables = orca.list_tables() cols = {t: orca.get_table(t).columns for t in tables} steps = orca.list_steps() injectables = orca.list_injectables() broa...
python
def schema(): """ All tables, columns, steps, injectables and broadcasts registered with Orca. Includes local columns on tables. """ tables = orca.list_tables() cols = {t: orca.get_table(t).columns for t in tables} steps = orca.list_steps() injectables = orca.list_injectables() broa...
[ "def", "schema", "(", ")", ":", "tables", "=", "orca", ".", "list_tables", "(", ")", "cols", "=", "{", "t", ":", "orca", ".", "get_table", "(", "t", ")", ".", "columns", "for", "t", "in", "tables", "}", "steps", "=", "orca", ".", "list_steps", "(...
All tables, columns, steps, injectables and broadcasts registered with Orca. Includes local columns on tables.
[ "All", "tables", "columns", "steps", "injectables", "and", "broadcasts", "registered", "with", "Orca", ".", "Includes", "local", "columns", "on", "tables", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/server/server.py#L97-L111
45,237
UDST/orca
orca/server/server.py
table_preview
def table_preview(table_name): """ Returns the first five rows of a table as JSON. Inlcudes all columns. Uses Pandas' "split" JSON format. """ preview = orca.get_table(table_name).to_frame().head() return ( preview.to_json(orient='split', date_format='iso'), 200, {'Conte...
python
def table_preview(table_name): """ Returns the first five rows of a table as JSON. Inlcudes all columns. Uses Pandas' "split" JSON format. """ preview = orca.get_table(table_name).to_frame().head() return ( preview.to_json(orient='split', date_format='iso'), 200, {'Conte...
[ "def", "table_preview", "(", "table_name", ")", ":", "preview", "=", "orca", ".", "get_table", "(", "table_name", ")", ".", "to_frame", "(", ")", ".", "head", "(", ")", "return", "(", "preview", ".", "to_json", "(", "orient", "=", "'split'", ",", "date...
Returns the first five rows of a table as JSON. Inlcudes all columns. Uses Pandas' "split" JSON format.
[ "Returns", "the", "first", "five", "rows", "of", "a", "table", "as", "JSON", ".", "Inlcudes", "all", "columns", ".", "Uses", "Pandas", "split", "JSON", "format", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/server/server.py#L140-L150
45,238
UDST/orca
orca/server/server.py
table_describe
def table_describe(table_name): """ Return summary statistics of a table as JSON. Includes all columns. Uses Pandas' "split" JSON format. """ desc = orca.get_table(table_name).to_frame().describe() return ( desc.to_json(orient='split', date_format='iso'), 200, {'Content-...
python
def table_describe(table_name): """ Return summary statistics of a table as JSON. Includes all columns. Uses Pandas' "split" JSON format. """ desc = orca.get_table(table_name).to_frame().describe() return ( desc.to_json(orient='split', date_format='iso'), 200, {'Content-...
[ "def", "table_describe", "(", "table_name", ")", ":", "desc", "=", "orca", ".", "get_table", "(", "table_name", ")", ".", "to_frame", "(", ")", ".", "describe", "(", ")", "return", "(", "desc", ".", "to_json", "(", "orient", "=", "'split'", ",", "date_...
Return summary statistics of a table as JSON. Includes all columns. Uses Pandas' "split" JSON format.
[ "Return", "summary", "statistics", "of", "a", "table", "as", "JSON", ".", "Includes", "all", "columns", ".", "Uses", "Pandas", "split", "JSON", "format", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/server/server.py#L155-L165
45,239
UDST/orca
orca/server/server.py
table_definition
def table_definition(table_name): """ Get the source of a table function. If a table is registered DataFrame and not a function then all that is returned is {'type': 'dataframe'}. If the table is a registered function then the JSON returned has keys "type", "filename", "lineno", "text", and "h...
python
def table_definition(table_name): """ Get the source of a table function. If a table is registered DataFrame and not a function then all that is returned is {'type': 'dataframe'}. If the table is a registered function then the JSON returned has keys "type", "filename", "lineno", "text", and "h...
[ "def", "table_definition", "(", "table_name", ")", ":", "if", "orca", ".", "table_type", "(", "table_name", ")", "==", "'dataframe'", ":", "return", "jsonify", "(", "type", "=", "'dataframe'", ")", "filename", ",", "lineno", ",", "source", "=", "orca", "."...
Get the source of a table function. If a table is registered DataFrame and not a function then all that is returned is {'type': 'dataframe'}. If the table is a registered function then the JSON returned has keys "type", "filename", "lineno", "text", and "html". "text" is the raw text of the functi...
[ "Get", "the", "source", "of", "a", "table", "function", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/server/server.py#L170-L192
45,240
UDST/orca
orca/server/server.py
table_groupbyagg
def table_groupbyagg(table_name): """ Perform a groupby on a table and return an aggregation on a single column. This depends on some request parameters in the URL. "column" and "agg" must always be present, and one of "by" or "level" must be present. "column" is the table column on which aggregati...
python
def table_groupbyagg(table_name): """ Perform a groupby on a table and return an aggregation on a single column. This depends on some request parameters in the URL. "column" and "agg" must always be present, and one of "by" or "level" must be present. "column" is the table column on which aggregati...
[ "def", "table_groupbyagg", "(", "table_name", ")", ":", "table", "=", "orca", ".", "get_table", "(", "table_name", ")", "# column to aggregate", "column", "=", "request", ".", "args", ".", "get", "(", "'column'", ",", "None", ")", "if", "not", "column", "o...
Perform a groupby on a table and return an aggregation on a single column. This depends on some request parameters in the URL. "column" and "agg" must always be present, and one of "by" or "level" must be present. "column" is the table column on which aggregation will be performed, "agg" is the aggrega...
[ "Perform", "a", "groupby", "on", "a", "table", "and", "return", "an", "aggregation", "on", "a", "single", "column", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/server/server.py#L208-L259
45,241
UDST/orca
orca/server/server.py
column_preview
def column_preview(table_name, col_name): """ Return the first ten elements of a column as JSON in Pandas' "split" format. """ col = orca.get_table(table_name).get_column(col_name).head(10) return ( col.to_json(orient='split', date_format='iso'), 200, {'Content-Type': '...
python
def column_preview(table_name, col_name): """ Return the first ten elements of a column as JSON in Pandas' "split" format. """ col = orca.get_table(table_name).get_column(col_name).head(10) return ( col.to_json(orient='split', date_format='iso'), 200, {'Content-Type': '...
[ "def", "column_preview", "(", "table_name", ",", "col_name", ")", ":", "col", "=", "orca", ".", "get_table", "(", "table_name", ")", ".", "get_column", "(", "col_name", ")", ".", "head", "(", "10", ")", "return", "(", "col", ".", "to_json", "(", "orien...
Return the first ten elements of a column as JSON in Pandas' "split" format.
[ "Return", "the", "first", "ten", "elements", "of", "a", "column", "as", "JSON", "in", "Pandas", "split", "format", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/server/server.py#L274-L285
45,242
UDST/orca
orca/server/server.py
column_definition
def column_definition(table_name, col_name): """ Get the source of a column function. If a column is a registered Series and not a function then all that is returned is {'type': 'series'}. If the column is a registered function then the JSON returned has keys "type", "filename", "lineno", "tex...
python
def column_definition(table_name, col_name): """ Get the source of a column function. If a column is a registered Series and not a function then all that is returned is {'type': 'series'}. If the column is a registered function then the JSON returned has keys "type", "filename", "lineno", "tex...
[ "def", "column_definition", "(", "table_name", ",", "col_name", ")", ":", "col_type", "=", "orca", ".", "get_table", "(", "table_name", ")", ".", "column_type", "(", "col_name", ")", "if", "col_type", "!=", "'function'", ":", "return", "jsonify", "(", "type"...
Get the source of a column function. If a column is a registered Series and not a function then all that is returned is {'type': 'series'}. If the column is a registered function then the JSON returned has keys "type", "filename", "lineno", "text", and "html". "text" is the raw text of the functio...
[ "Get", "the", "source", "of", "a", "column", "function", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/server/server.py#L290-L314
45,243
UDST/orca
orca/server/server.py
column_describe
def column_describe(table_name, col_name): """ Return summary statistics of a column as JSON. Uses Pandas' "split" JSON format. """ col_desc = orca.get_table(table_name).get_column(col_name).describe() return ( col_desc.to_json(orient='split'), 200, {'Content-Type': 'app...
python
def column_describe(table_name, col_name): """ Return summary statistics of a column as JSON. Uses Pandas' "split" JSON format. """ col_desc = orca.get_table(table_name).get_column(col_name).describe() return ( col_desc.to_json(orient='split'), 200, {'Content-Type': 'app...
[ "def", "column_describe", "(", "table_name", ",", "col_name", ")", ":", "col_desc", "=", "orca", ".", "get_table", "(", "table_name", ")", ".", "get_column", "(", "col_name", ")", ".", "describe", "(", ")", "return", "(", "col_desc", ".", "to_json", "(", ...
Return summary statistics of a column as JSON. Uses Pandas' "split" JSON format.
[ "Return", "summary", "statistics", "of", "a", "column", "as", "JSON", ".", "Uses", "Pandas", "split", "JSON", "format", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/server/server.py#L319-L329
45,244
UDST/orca
orca/server/server.py
column_csv
def column_csv(table_name, col_name): """ Return a column as CSV using Pandas' default CSV output. """ csv = orca.get_table(table_name).get_column(col_name).to_csv(path=None) return csv, 200, {'Content-Type': 'text/csv'}
python
def column_csv(table_name, col_name): """ Return a column as CSV using Pandas' default CSV output. """ csv = orca.get_table(table_name).get_column(col_name).to_csv(path=None) return csv, 200, {'Content-Type': 'text/csv'}
[ "def", "column_csv", "(", "table_name", ",", "col_name", ")", ":", "csv", "=", "orca", ".", "get_table", "(", "table_name", ")", ".", "get_column", "(", "col_name", ")", ".", "to_csv", "(", "path", "=", "None", ")", "return", "csv", ",", "200", ",", ...
Return a column as CSV using Pandas' default CSV output.
[ "Return", "a", "column", "as", "CSV", "using", "Pandas", "default", "CSV", "output", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/server/server.py#L334-L340
45,245
UDST/orca
orca/server/server.py
injectable_repr
def injectable_repr(inj_name): """ Returns the type and repr of an injectable. JSON response has "type" and "repr" keys. """ i = orca.get_injectable(inj_name) return jsonify(type=str(type(i)), repr=repr(i))
python
def injectable_repr(inj_name): """ Returns the type and repr of an injectable. JSON response has "type" and "repr" keys. """ i = orca.get_injectable(inj_name) return jsonify(type=str(type(i)), repr=repr(i))
[ "def", "injectable_repr", "(", "inj_name", ")", ":", "i", "=", "orca", ".", "get_injectable", "(", "inj_name", ")", "return", "jsonify", "(", "type", "=", "str", "(", "type", "(", "i", ")", ")", ",", "repr", "=", "repr", "(", "i", ")", ")" ]
Returns the type and repr of an injectable. JSON response has "type" and "repr" keys.
[ "Returns", "the", "type", "and", "repr", "of", "an", "injectable", ".", "JSON", "response", "has", "type", "and", "repr", "keys", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/server/server.py#L354-L361
45,246
UDST/orca
orca/server/server.py
injectable_definition
def injectable_definition(inj_name): """ Get the source of an injectable function. If an injectable is a registered Python variable and not a function then all that is returned is {'type': 'variable'}. If the column is a registered function then the JSON returned has keys "type", "filename", "...
python
def injectable_definition(inj_name): """ Get the source of an injectable function. If an injectable is a registered Python variable and not a function then all that is returned is {'type': 'variable'}. If the column is a registered function then the JSON returned has keys "type", "filename", "...
[ "def", "injectable_definition", "(", "inj_name", ")", ":", "inj_type", "=", "orca", ".", "injectable_type", "(", "inj_name", ")", "if", "inj_type", "==", "'variable'", ":", "return", "jsonify", "(", "type", "=", "'variable'", ")", "else", ":", "filename", ",...
Get the source of an injectable function. If an injectable is a registered Python variable and not a function then all that is returned is {'type': 'variable'}. If the column is a registered function then the JSON returned has keys "type", "filename", "lineno", "text", and "html". "text" is the raw ...
[ "Get", "the", "source", "of", "an", "injectable", "function", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/server/server.py#L366-L388
45,247
UDST/orca
orca/server/server.py
list_broadcasts
def list_broadcasts(): """ List all registered broadcasts as a list of objects with keys "cast" and "onto". """ casts = [{'cast': b[0], 'onto': b[1]} for b in orca.list_broadcasts()] return jsonify(broadcasts=casts)
python
def list_broadcasts(): """ List all registered broadcasts as a list of objects with keys "cast" and "onto". """ casts = [{'cast': b[0], 'onto': b[1]} for b in orca.list_broadcasts()] return jsonify(broadcasts=casts)
[ "def", "list_broadcasts", "(", ")", ":", "casts", "=", "[", "{", "'cast'", ":", "b", "[", "0", "]", ",", "'onto'", ":", "b", "[", "1", "]", "}", "for", "b", "in", "orca", ".", "list_broadcasts", "(", ")", "]", "return", "jsonify", "(", "broadcast...
List all registered broadcasts as a list of objects with keys "cast" and "onto".
[ "List", "all", "registered", "broadcasts", "as", "a", "list", "of", "objects", "with", "keys", "cast", "and", "onto", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/server/server.py#L392-L399
45,248
UDST/orca
orca/server/server.py
broadcast_definition
def broadcast_definition(cast_name, onto_name): """ Return the definition of a broadcast as an object with keys "cast", "onto", "cast_on", "onto_on", "cast_index", and "onto_index". These are the same as the arguments to the ``broadcast`` function. """ if not orca.is_broadcast(cast_name, onto_n...
python
def broadcast_definition(cast_name, onto_name): """ Return the definition of a broadcast as an object with keys "cast", "onto", "cast_on", "onto_on", "cast_index", and "onto_index". These are the same as the arguments to the ``broadcast`` function. """ if not orca.is_broadcast(cast_name, onto_n...
[ "def", "broadcast_definition", "(", "cast_name", ",", "onto_name", ")", ":", "if", "not", "orca", ".", "is_broadcast", "(", "cast_name", ",", "onto_name", ")", ":", "abort", "(", "404", ")", "b", "=", "orca", ".", "get_broadcast", "(", "cast_name", ",", ...
Return the definition of a broadcast as an object with keys "cast", "onto", "cast_on", "onto_on", "cast_index", and "onto_index". These are the same as the arguments to the ``broadcast`` function.
[ "Return", "the", "definition", "of", "a", "broadcast", "as", "an", "object", "with", "keys", "cast", "onto", "cast_on", "onto_on", "cast_index", "and", "onto_index", ".", "These", "are", "the", "same", "as", "the", "arguments", "to", "the", "broadcast", "fun...
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/server/server.py#L403-L417
45,249
UDST/orca
orca/server/server.py
step_definition
def step_definition(step_name): """ Get the source of a step function. Returned object has keys "filename", "lineno", "text" and "html". "text" is the raw text of the function, "html" has been marked up by Pygments. """ if not orca.is_step(step_name): abort(404) filename, lineno, s...
python
def step_definition(step_name): """ Get the source of a step function. Returned object has keys "filename", "lineno", "text" and "html". "text" is the raw text of the function, "html" has been marked up by Pygments. """ if not orca.is_step(step_name): abort(404) filename, lineno, s...
[ "def", "step_definition", "(", "step_name", ")", ":", "if", "not", "orca", ".", "is_step", "(", "step_name", ")", ":", "abort", "(", "404", ")", "filename", ",", "lineno", ",", "source", "=", "orca", ".", "get_step", "(", "step_name", ")", ".", "func_s...
Get the source of a step function. Returned object has keys "filename", "lineno", "text" and "html". "text" is the raw text of the function, "html" has been marked up by Pygments.
[ "Get", "the", "source", "of", "a", "step", "function", ".", "Returned", "object", "has", "keys", "filename", "lineno", "text", "and", "html", ".", "text", "is", "the", "raw", "text", "of", "the", "function", "html", "has", "been", "marked", "up", "by", ...
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/server/server.py#L430-L443
45,250
UDST/orca
orca/utils/logutil.py
_add_log_handler
def _add_log_handler( handler, level=None, fmt=None, datefmt=None, propagate=None): """ Add a logging handler to Orca. Parameters ---------- handler : logging.Handler subclass level : int, optional An optional logging level that will apply only to this stream handler. ...
python
def _add_log_handler( handler, level=None, fmt=None, datefmt=None, propagate=None): """ Add a logging handler to Orca. Parameters ---------- handler : logging.Handler subclass level : int, optional An optional logging level that will apply only to this stream handler. ...
[ "def", "_add_log_handler", "(", "handler", ",", "level", "=", "None", ",", "fmt", "=", "None", ",", "datefmt", "=", "None", ",", "propagate", "=", "None", ")", ":", "if", "not", "fmt", ":", "fmt", "=", "US_LOG_FMT", "if", "not", "datefmt", ":", "date...
Add a logging handler to Orca. Parameters ---------- handler : logging.Handler subclass level : int, optional An optional logging level that will apply only to this stream handler. fmt : str, optional An optional format string that will be used for the log messages. ...
[ "Add", "a", "logging", "handler", "to", "Orca", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/utils/logutil.py#L47-L84
45,251
UDST/orca
orca/utils/logutil.py
log_to_stream
def log_to_stream(level=None, fmt=None, datefmt=None): """ Send log messages to the console. Parameters ---------- level : int, optional An optional logging level that will apply only to this stream handler. fmt : str, optional An optional format string that will be used...
python
def log_to_stream(level=None, fmt=None, datefmt=None): """ Send log messages to the console. Parameters ---------- level : int, optional An optional logging level that will apply only to this stream handler. fmt : str, optional An optional format string that will be used...
[ "def", "log_to_stream", "(", "level", "=", "None", ",", "fmt", "=", "None", ",", "datefmt", "=", "None", ")", ":", "_add_log_handler", "(", "logging", ".", "StreamHandler", "(", ")", ",", "fmt", "=", "fmt", ",", "datefmt", "=", "datefmt", ",", "propaga...
Send log messages to the console. Parameters ---------- level : int, optional An optional logging level that will apply only to this stream handler. fmt : str, optional An optional format string that will be used for the log messages. datefmt : str, optional ...
[ "Send", "log", "messages", "to", "the", "console", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/utils/logutil.py#L87-L105
45,252
UDST/orca
orca/orca.py
clear_all
def clear_all(): """ Clear any and all stored state from Orca. """ _TABLES.clear() _COLUMNS.clear() _STEPS.clear() _BROADCASTS.clear() _INJECTABLES.clear() _TABLE_CACHE.clear() _COLUMN_CACHE.clear() _INJECTABLE_CACHE.clear() for m in _MEMOIZED.values(): m.value.c...
python
def clear_all(): """ Clear any and all stored state from Orca. """ _TABLES.clear() _COLUMNS.clear() _STEPS.clear() _BROADCASTS.clear() _INJECTABLES.clear() _TABLE_CACHE.clear() _COLUMN_CACHE.clear() _INJECTABLE_CACHE.clear() for m in _MEMOIZED.values(): m.value.c...
[ "def", "clear_all", "(", ")", ":", "_TABLES", ".", "clear", "(", ")", "_COLUMNS", ".", "clear", "(", ")", "_STEPS", ".", "clear", "(", ")", "_BROADCASTS", ".", "clear", "(", ")", "_INJECTABLES", ".", "clear", "(", ")", "_TABLE_CACHE", ".", "clear", "...
Clear any and all stored state from Orca.
[ "Clear", "any", "and", "all", "stored", "state", "from", "Orca", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L48-L64
45,253
UDST/orca
orca/orca.py
_collect_variables
def _collect_variables(names, expressions=None): """ Map labels and expressions to registered variables. Handles argument matching. Example: _collect_variables(names=['zones', 'zone_id'], expressions=['parcels.zone_id']) Would return a dict representing: ...
python
def _collect_variables(names, expressions=None): """ Map labels and expressions to registered variables. Handles argument matching. Example: _collect_variables(names=['zones', 'zone_id'], expressions=['parcels.zone_id']) Would return a dict representing: ...
[ "def", "_collect_variables", "(", "names", ",", "expressions", "=", "None", ")", ":", "# Map registered variable labels to expressions.", "if", "not", "expressions", ":", "expressions", "=", "[", "]", "offset", "=", "len", "(", "names", ")", "-", "len", "(", "...
Map labels and expressions to registered variables. Handles argument matching. Example: _collect_variables(names=['zones', 'zone_id'], expressions=['parcels.zone_id']) Would return a dict representing: {'parcels': <DataFrameWrapper for zones>, 'zone_i...
[ "Map", "labels", "and", "expressions", "to", "registered", "variables", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L903-L962
45,254
UDST/orca
orca/orca.py
add_table
def add_table( table_name, table, cache=False, cache_scope=_CS_FOREVER, copy_col=True): """ Register a table with Orca. Parameters ---------- table_name : str Should be globally unique to this table. table : pandas.DataFrame or function If a function, the functio...
python
def add_table( table_name, table, cache=False, cache_scope=_CS_FOREVER, copy_col=True): """ Register a table with Orca. Parameters ---------- table_name : str Should be globally unique to this table. table : pandas.DataFrame or function If a function, the functio...
[ "def", "add_table", "(", "table_name", ",", "table", ",", "cache", "=", "False", ",", "cache_scope", "=", "_CS_FOREVER", ",", "copy_col", "=", "True", ")", ":", "if", "isinstance", "(", "table", ",", "Callable", ")", ":", "table", "=", "TableFuncWrapper", ...
Register a table with Orca. Parameters ---------- table_name : str Should be globally unique to this table. table : pandas.DataFrame or function If a function, the function should return a DataFrame. The function's argument names and keyword argument values will be match...
[ "Register", "a", "table", "with", "Orca", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L965-L1008
45,255
UDST/orca
orca/orca.py
table
def table( table_name=None, cache=False, cache_scope=_CS_FOREVER, copy_col=True): """ Decorates functions that return DataFrames. Decorator version of `add_table`. Table name defaults to name of function. The function's argument names and keyword argument values will be matched to regi...
python
def table( table_name=None, cache=False, cache_scope=_CS_FOREVER, copy_col=True): """ Decorates functions that return DataFrames. Decorator version of `add_table`. Table name defaults to name of function. The function's argument names and keyword argument values will be matched to regi...
[ "def", "table", "(", "table_name", "=", "None", ",", "cache", "=", "False", ",", "cache_scope", "=", "_CS_FOREVER", ",", "copy_col", "=", "True", ")", ":", "def", "decorator", "(", "func", ")", ":", "if", "table_name", ":", "name", "=", "table_name", "...
Decorates functions that return DataFrames. Decorator version of `add_table`. Table name defaults to name of function. The function's argument names and keyword argument values will be matched to registered variables when the function needs to be evaluated by Orca. The argument name "iter_var"...
[ "Decorates", "functions", "that", "return", "DataFrames", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L1011-L1035
45,256
UDST/orca
orca/orca.py
get_table
def get_table(table_name): """ Get a registered table. Decorated functions will be converted to `DataFrameWrapper`. Parameters ---------- table_name : str Returns ------- table : `DataFrameWrapper` """ table = get_raw_table(table_name) if isinstance(table, TableFuncWr...
python
def get_table(table_name): """ Get a registered table. Decorated functions will be converted to `DataFrameWrapper`. Parameters ---------- table_name : str Returns ------- table : `DataFrameWrapper` """ table = get_raw_table(table_name) if isinstance(table, TableFuncWr...
[ "def", "get_table", "(", "table_name", ")", ":", "table", "=", "get_raw_table", "(", "table_name", ")", "if", "isinstance", "(", "table", ",", "TableFuncWrapper", ")", ":", "table", "=", "table", "(", ")", "return", "table" ]
Get a registered table. Decorated functions will be converted to `DataFrameWrapper`. Parameters ---------- table_name : str Returns ------- table : `DataFrameWrapper`
[ "Get", "a", "registered", "table", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L1057-L1075
45,257
UDST/orca
orca/orca.py
table_type
def table_type(table_name): """ Returns the type of a registered table. The type can be either "dataframe" or "function". Parameters ---------- table_name : str Returns ------- table_type : {'dataframe', 'function'} """ table = get_raw_table(table_name) if isinstance...
python
def table_type(table_name): """ Returns the type of a registered table. The type can be either "dataframe" or "function". Parameters ---------- table_name : str Returns ------- table_type : {'dataframe', 'function'} """ table = get_raw_table(table_name) if isinstance...
[ "def", "table_type", "(", "table_name", ")", ":", "table", "=", "get_raw_table", "(", "table_name", ")", "if", "isinstance", "(", "table", ",", "DataFrameWrapper", ")", ":", "return", "'dataframe'", "elif", "isinstance", "(", "table", ",", "TableFuncWrapper", ...
Returns the type of a registered table. The type can be either "dataframe" or "function". Parameters ---------- table_name : str Returns ------- table_type : {'dataframe', 'function'}
[ "Returns", "the", "type", "of", "a", "registered", "table", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L1078-L1098
45,258
UDST/orca
orca/orca.py
add_column
def add_column( table_name, column_name, column, cache=False, cache_scope=_CS_FOREVER): """ Add a new column to a table from a Series or callable. Parameters ---------- table_name : str Table with which the column will be associated. column_name : str Name for the column...
python
def add_column( table_name, column_name, column, cache=False, cache_scope=_CS_FOREVER): """ Add a new column to a table from a Series or callable. Parameters ---------- table_name : str Table with which the column will be associated. column_name : str Name for the column...
[ "def", "add_column", "(", "table_name", ",", "column_name", ",", "column", ",", "cache", "=", "False", ",", "cache_scope", "=", "_CS_FOREVER", ")", ":", "if", "isinstance", "(", "column", ",", "Callable", ")", ":", "column", "=", "_ColumnFuncWrapper", "(", ...
Add a new column to a table from a Series or callable. Parameters ---------- table_name : str Table with which the column will be associated. column_name : str Name for the column. column : pandas.Series or callable Series should have an index matching the table to which it ...
[ "Add", "a", "new", "column", "to", "a", "table", "from", "a", "Series", "or", "callable", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L1101-L1143
45,259
UDST/orca
orca/orca.py
column
def column(table_name, column_name=None, cache=False, cache_scope=_CS_FOREVER): """ Decorates functions that return a Series. Decorator version of `add_column`. Series index must match the named table. Column name defaults to name of function. The function's argument names and keyword argument val...
python
def column(table_name, column_name=None, cache=False, cache_scope=_CS_FOREVER): """ Decorates functions that return a Series. Decorator version of `add_column`. Series index must match the named table. Column name defaults to name of function. The function's argument names and keyword argument val...
[ "def", "column", "(", "table_name", ",", "column_name", "=", "None", ",", "cache", "=", "False", ",", "cache_scope", "=", "_CS_FOREVER", ")", ":", "def", "decorator", "(", "func", ")", ":", "if", "column_name", ":", "name", "=", "column_name", "else", ":...
Decorates functions that return a Series. Decorator version of `add_column`. Series index must match the named table. Column name defaults to name of function. The function's argument names and keyword argument values will be matched to registered variables when the function needs to be evaluated ...
[ "Decorates", "functions", "that", "return", "a", "Series", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L1146-L1169
45,260
UDST/orca
orca/orca.py
_columns_for_table
def _columns_for_table(table_name): """ Return all of the columns registered for a given table. Parameters ---------- table_name : str Returns ------- columns : dict of column wrappers Keys will be column names. """ return {cname: col for (tname, cname), co...
python
def _columns_for_table(table_name): """ Return all of the columns registered for a given table. Parameters ---------- table_name : str Returns ------- columns : dict of column wrappers Keys will be column names. """ return {cname: col for (tname, cname), co...
[ "def", "_columns_for_table", "(", "table_name", ")", ":", "return", "{", "cname", ":", "col", "for", "(", "tname", ",", "cname", ")", ",", "col", "in", "_COLUMNS", ".", "items", "(", ")", "if", "tname", "==", "table_name", "}" ]
Return all of the columns registered for a given table. Parameters ---------- table_name : str Returns ------- columns : dict of column wrappers Keys will be column names.
[ "Return", "all", "of", "the", "columns", "registered", "for", "a", "given", "table", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L1188-L1204
45,261
UDST/orca
orca/orca.py
get_raw_column
def get_raw_column(table_name, column_name): """ Get a wrapped, registered column. This function cannot return columns that are part of wrapped DataFrames, it's only for columns registered directly through Orca. Parameters ---------- table_name : str column_name : str Returns ...
python
def get_raw_column(table_name, column_name): """ Get a wrapped, registered column. This function cannot return columns that are part of wrapped DataFrames, it's only for columns registered directly through Orca. Parameters ---------- table_name : str column_name : str Returns ...
[ "def", "get_raw_column", "(", "table_name", ",", "column_name", ")", ":", "try", ":", "return", "_COLUMNS", "[", "(", "table_name", ",", "column_name", ")", "]", "except", "KeyError", ":", "raise", "KeyError", "(", "'column {!r} not found for table {!r}'", ".", ...
Get a wrapped, registered column. This function cannot return columns that are part of wrapped DataFrames, it's only for columns registered directly through Orca. Parameters ---------- table_name : str column_name : str Returns ------- wrapped : _SeriesWrapper or _ColumnFuncWrappe...
[ "Get", "a", "wrapped", "registered", "column", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L1239-L1260
45,262
UDST/orca
orca/orca.py
_memoize_function
def _memoize_function(f, name, cache_scope=_CS_FOREVER): """ Wraps a function for memoization and ties it's cache into the Orca cacheing system. Parameters ---------- f : function name : str Name of injectable. cache_scope : {'step', 'iteration', 'forever'}, optional Sco...
python
def _memoize_function(f, name, cache_scope=_CS_FOREVER): """ Wraps a function for memoization and ties it's cache into the Orca cacheing system. Parameters ---------- f : function name : str Name of injectable. cache_scope : {'step', 'iteration', 'forever'}, optional Sco...
[ "def", "_memoize_function", "(", "f", ",", "name", ",", "cache_scope", "=", "_CS_FOREVER", ")", ":", "cache", "=", "{", "}", "@", "wraps", "(", "f", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "cache_key"...
Wraps a function for memoization and ties it's cache into the Orca cacheing system. Parameters ---------- f : function name : str Name of injectable. cache_scope : {'step', 'iteration', 'forever'}, optional Scope for which to cache data. Default is to cache forever (or u...
[ "Wraps", "a", "function", "for", "memoization", "and", "ties", "it", "s", "cache", "into", "the", "Orca", "cacheing", "system", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L1263-L1304
45,263
UDST/orca
orca/orca.py
add_injectable
def add_injectable( name, value, autocall=True, cache=False, cache_scope=_CS_FOREVER, memoize=False): """ Add a value that will be injected into other functions. Parameters ---------- name : str value If a callable and `autocall` is True then the function's argum...
python
def add_injectable( name, value, autocall=True, cache=False, cache_scope=_CS_FOREVER, memoize=False): """ Add a value that will be injected into other functions. Parameters ---------- name : str value If a callable and `autocall` is True then the function's argum...
[ "def", "add_injectable", "(", "name", ",", "value", ",", "autocall", "=", "True", ",", "cache", "=", "False", ",", "cache_scope", "=", "_CS_FOREVER", ",", "memoize", "=", "False", ")", ":", "if", "isinstance", "(", "value", ",", "Callable", ")", ":", "...
Add a value that will be injected into other functions. Parameters ---------- name : str value If a callable and `autocall` is True then the function's argument names and keyword argument values will be matched to registered variables when the function needs to be evalua...
[ "Add", "a", "value", "that", "will", "be", "injected", "into", "other", "functions", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L1307-L1353
45,264
UDST/orca
orca/orca.py
injectable
def injectable( name=None, autocall=True, cache=False, cache_scope=_CS_FOREVER, memoize=False): """ Decorates functions that will be injected into other functions. Decorator version of `add_injectable`. Name defaults to name of function. The function's argument names and keyword ar...
python
def injectable( name=None, autocall=True, cache=False, cache_scope=_CS_FOREVER, memoize=False): """ Decorates functions that will be injected into other functions. Decorator version of `add_injectable`. Name defaults to name of function. The function's argument names and keyword ar...
[ "def", "injectable", "(", "name", "=", "None", ",", "autocall", "=", "True", ",", "cache", "=", "False", ",", "cache_scope", "=", "_CS_FOREVER", ",", "memoize", "=", "False", ")", ":", "def", "decorator", "(", "func", ")", ":", "if", "name", ":", "n"...
Decorates functions that will be injected into other functions. Decorator version of `add_injectable`. Name defaults to name of function. The function's argument names and keyword argument values will be matched to registered variables when the function needs to be evaluated by Orca. The argum...
[ "Decorates", "functions", "that", "will", "be", "injected", "into", "other", "functions", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L1356-L1381
45,265
UDST/orca
orca/orca.py
get_injectable_func_source_data
def get_injectable_func_source_data(name): """ Return data about an injectable function's source, including file name, line number, and source code. Parameters ---------- name : str Returns ------- filename : str lineno : int The line number on which the function starts...
python
def get_injectable_func_source_data(name): """ Return data about an injectable function's source, including file name, line number, and source code. Parameters ---------- name : str Returns ------- filename : str lineno : int The line number on which the function starts...
[ "def", "get_injectable_func_source_data", "(", "name", ")", ":", "if", "injectable_type", "(", "name", ")", "!=", "'function'", ":", "raise", "ValueError", "(", "'injectable {!r} is not a function'", ".", "format", "(", "name", ")", ")", "inj", "=", "get_raw_injec...
Return data about an injectable function's source, including file name, line number, and source code. Parameters ---------- name : str Returns ------- filename : str lineno : int The line number on which the function starts. source : str
[ "Return", "data", "about", "an", "injectable", "function", "s", "source", "including", "file", "name", "line", "number", "and", "source", "code", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L1452-L1479
45,266
UDST/orca
orca/orca.py
add_step
def add_step(step_name, func): """ Add a step function to Orca. The function's argument names and keyword argument values will be matched to registered variables when the function needs to be evaluated by Orca. The argument name "iter_var" may be used to have the current iteration variable ...
python
def add_step(step_name, func): """ Add a step function to Orca. The function's argument names and keyword argument values will be matched to registered variables when the function needs to be evaluated by Orca. The argument name "iter_var" may be used to have the current iteration variable ...
[ "def", "add_step", "(", "step_name", ",", "func", ")", ":", "if", "isinstance", "(", "func", ",", "Callable", ")", ":", "logger", ".", "debug", "(", "'registering step {!r}'", ".", "format", "(", "step_name", ")", ")", "_STEPS", "[", "step_name", "]", "=...
Add a step function to Orca. The function's argument names and keyword argument values will be matched to registered variables when the function needs to be evaluated by Orca. The argument name "iter_var" may be used to have the current iteration variable injected. Parameters ---------- ...
[ "Add", "a", "step", "function", "to", "Orca", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L1482-L1502
45,267
UDST/orca
orca/orca.py
step
def step(step_name=None): """ Decorates functions that will be called by the `run` function. Decorator version of `add_step`. step name defaults to name of function. The function's argument names and keyword argument values will be matched to registered variables when the function needs to...
python
def step(step_name=None): """ Decorates functions that will be called by the `run` function. Decorator version of `add_step`. step name defaults to name of function. The function's argument names and keyword argument values will be matched to registered variables when the function needs to...
[ "def", "step", "(", "step_name", "=", "None", ")", ":", "def", "decorator", "(", "func", ")", ":", "if", "step_name", ":", "name", "=", "step_name", "else", ":", "name", "=", "func", ".", "__name__", "add_step", "(", "name", ",", "func", ")", "return...
Decorates functions that will be called by the `run` function. Decorator version of `add_step`. step name defaults to name of function. The function's argument names and keyword argument values will be matched to registered variables when the function needs to be evaluated by Orca. The argumen...
[ "Decorates", "functions", "that", "will", "be", "called", "by", "the", "run", "function", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L1505-L1526
45,268
UDST/orca
orca/orca.py
broadcast
def broadcast(cast, onto, cast_on=None, onto_on=None, cast_index=False, onto_index=False): """ Register a rule for merging two tables by broadcasting one onto the other. Parameters ---------- cast, onto : str Names of registered tables. cast_on, onto_on : str, optional...
python
def broadcast(cast, onto, cast_on=None, onto_on=None, cast_index=False, onto_index=False): """ Register a rule for merging two tables by broadcasting one onto the other. Parameters ---------- cast, onto : str Names of registered tables. cast_on, onto_on : str, optional...
[ "def", "broadcast", "(", "cast", ",", "onto", ",", "cast_on", "=", "None", ",", "onto_on", "=", "None", ",", "cast_index", "=", "False", ",", "onto_index", "=", "False", ")", ":", "logger", ".", "debug", "(", "'registering broadcast of table {!r} onto {!r}'", ...
Register a rule for merging two tables by broadcasting one onto the other. Parameters ---------- cast, onto : str Names of registered tables. cast_on, onto_on : str, optional Column names used for merge, equivalent of ``left_on``/``right_on`` parameters of pandas.merge. ...
[ "Register", "a", "rule", "for", "merging", "two", "tables", "by", "broadcasting", "one", "onto", "the", "other", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L1556-L1577
45,269
UDST/orca
orca/orca.py
_get_broadcasts
def _get_broadcasts(tables): """ Get the broadcasts associated with a set of tables. Parameters ---------- tables : sequence of str Table names for which broadcasts have been registered. Returns ------- casts : dict of `Broadcast` Keys are tuples of strings like (cast_n...
python
def _get_broadcasts(tables): """ Get the broadcasts associated with a set of tables. Parameters ---------- tables : sequence of str Table names for which broadcasts have been registered. Returns ------- casts : dict of `Broadcast` Keys are tuples of strings like (cast_n...
[ "def", "_get_broadcasts", "(", "tables", ")", ":", "tables", "=", "set", "(", "tables", ")", "casts", "=", "tz", ".", "keyfilter", "(", "lambda", "x", ":", "x", "[", "0", "]", "in", "tables", "and", "x", "[", "1", "]", "in", "tables", ",", "_BROA...
Get the broadcasts associated with a set of tables. Parameters ---------- tables : sequence of str Table names for which broadcasts have been registered. Returns ------- casts : dict of `Broadcast` Keys are tuples of strings like (cast_name, onto_name).
[ "Get", "the", "broadcasts", "associated", "with", "a", "set", "of", "tables", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L1580-L1600
45,270
UDST/orca
orca/orca.py
get_broadcast
def get_broadcast(cast_name, onto_name): """ Get a single broadcast. Broadcasts are stored data about how to do a Pandas join. A Broadcast object is a namedtuple with these attributes: - cast: the name of the table being broadcast - onto: the name of the table onto which "cast" is broa...
python
def get_broadcast(cast_name, onto_name): """ Get a single broadcast. Broadcasts are stored data about how to do a Pandas join. A Broadcast object is a namedtuple with these attributes: - cast: the name of the table being broadcast - onto: the name of the table onto which "cast" is broa...
[ "def", "get_broadcast", "(", "cast_name", ",", "onto_name", ")", ":", "if", "is_broadcast", "(", "cast_name", ",", "onto_name", ")", ":", "return", "_BROADCASTS", "[", "(", "cast_name", ",", "onto_name", ")", "]", "else", ":", "raise", "KeyError", "(", "'n...
Get a single broadcast. Broadcasts are stored data about how to do a Pandas join. A Broadcast object is a namedtuple with these attributes: - cast: the name of the table being broadcast - onto: the name of the table onto which "cast" is broadcast - cast_on: The optional name of a colum...
[ "Get", "a", "single", "broadcast", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L1612-L1645
45,271
UDST/orca
orca/orca.py
_all_reachable_tables
def _all_reachable_tables(t): """ A generator that provides all the names of tables that can be reached via merges starting at the given target table. """ for k, v in t.items(): for tname in _all_reachable_tables(v): yield tname yield k
python
def _all_reachable_tables(t): """ A generator that provides all the names of tables that can be reached via merges starting at the given target table. """ for k, v in t.items(): for tname in _all_reachable_tables(v): yield tname yield k
[ "def", "_all_reachable_tables", "(", "t", ")", ":", "for", "k", ",", "v", "in", "t", ".", "items", "(", ")", ":", "for", "tname", "in", "_all_reachable_tables", "(", "v", ")", ":", "yield", "tname", "yield", "k" ]
A generator that provides all the names of tables that can be reached via merges starting at the given target table.
[ "A", "generator", "that", "provides", "all", "the", "names", "of", "tables", "that", "can", "be", "reached", "via", "merges", "starting", "at", "the", "given", "target", "table", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L1649-L1658
45,272
UDST/orca
orca/orca.py
_recursive_getitem
def _recursive_getitem(d, key): """ Descend into a dict of dicts to return the one that contains a given key. Every value in the dict must be another dict. """ if key in d: return d else: for v in d.values(): return _recursive_getitem(v, key) else: ...
python
def _recursive_getitem(d, key): """ Descend into a dict of dicts to return the one that contains a given key. Every value in the dict must be another dict. """ if key in d: return d else: for v in d.values(): return _recursive_getitem(v, key) else: ...
[ "def", "_recursive_getitem", "(", "d", ",", "key", ")", ":", "if", "key", "in", "d", ":", "return", "d", "else", ":", "for", "v", "in", "d", ".", "values", "(", ")", ":", "return", "_recursive_getitem", "(", "v", ",", "key", ")", "else", ":", "ra...
Descend into a dict of dicts to return the one that contains a given key. Every value in the dict must be another dict.
[ "Descend", "into", "a", "dict", "of", "dicts", "to", "return", "the", "one", "that", "contains", "a", "given", "key", ".", "Every", "value", "in", "the", "dict", "must", "be", "another", "dict", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L1661-L1673
45,273
UDST/orca
orca/orca.py
_next_merge
def _next_merge(merge_node): """ Gets a node that has only leaf nodes below it. This table and the ones below are ready to be merged to make a new leaf node. """ if all(_is_leaf_node(d) for d in _dict_value_to_pairs(merge_node)): return merge_node else: for d in tz.remove(_is_le...
python
def _next_merge(merge_node): """ Gets a node that has only leaf nodes below it. This table and the ones below are ready to be merged to make a new leaf node. """ if all(_is_leaf_node(d) for d in _dict_value_to_pairs(merge_node)): return merge_node else: for d in tz.remove(_is_le...
[ "def", "_next_merge", "(", "merge_node", ")", ":", "if", "all", "(", "_is_leaf_node", "(", "d", ")", "for", "d", "in", "_dict_value_to_pairs", "(", "merge_node", ")", ")", ":", "return", "merge_node", "else", ":", "for", "d", "in", "tz", ".", "remove", ...
Gets a node that has only leaf nodes below it. This table and the ones below are ready to be merged to make a new leaf node.
[ "Gets", "a", "node", "that", "has", "only", "leaf", "nodes", "below", "it", ".", "This", "table", "and", "the", "ones", "below", "are", "ready", "to", "be", "merged", "to", "make", "a", "new", "leaf", "node", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L1699-L1711
45,274
UDST/orca
orca/orca.py
get_step_table_names
def get_step_table_names(steps): """ Returns a list of table names injected into the provided steps. Parameters ---------- steps: list of str Steps to gather table inputs from. Returns ------- list of str """ table_names = set() for s in steps: table_names ...
python
def get_step_table_names(steps): """ Returns a list of table names injected into the provided steps. Parameters ---------- steps: list of str Steps to gather table inputs from. Returns ------- list of str """ table_names = set() for s in steps: table_names ...
[ "def", "get_step_table_names", "(", "steps", ")", ":", "table_names", "=", "set", "(", ")", "for", "s", "in", "steps", ":", "table_names", "|=", "get_step", "(", "s", ")", ".", "_tables_used", "(", ")", "return", "list", "(", "table_names", ")" ]
Returns a list of table names injected into the provided steps. Parameters ---------- steps: list of str Steps to gather table inputs from. Returns ------- list of str
[ "Returns", "a", "list", "of", "table", "names", "injected", "into", "the", "provided", "steps", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L1846-L1863
45,275
UDST/orca
orca/orca.py
write_tables
def write_tables(fname, table_names=None, prefix=None, compress=False, local=False): """ Writes tables to a pandas.HDFStore file. Parameters ---------- fname : str File name for HDFStore. Will be opened in append mode and closed at the end of this function. table_names: list of ...
python
def write_tables(fname, table_names=None, prefix=None, compress=False, local=False): """ Writes tables to a pandas.HDFStore file. Parameters ---------- fname : str File name for HDFStore. Will be opened in append mode and closed at the end of this function. table_names: list of ...
[ "def", "write_tables", "(", "fname", ",", "table_names", "=", "None", ",", "prefix", "=", "None", ",", "compress", "=", "False", ",", "local", "=", "False", ")", ":", "if", "table_names", "is", "None", ":", "table_names", "=", "list_tables", "(", ")", ...
Writes tables to a pandas.HDFStore file. Parameters ---------- fname : str File name for HDFStore. Will be opened in append mode and closed at the end of this function. table_names: list of str, optional, default None List of tables to write. If None, all registered tables will ...
[ "Writes", "tables", "to", "a", "pandas", ".", "HDFStore", "file", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L1866-L1902
45,276
UDST/orca
orca/orca.py
run
def run(steps, iter_vars=None, data_out=None, out_interval=1, out_base_tables=None, out_run_tables=None, compress=False, out_base_local=True, out_run_local=True): """ Run steps in series, optionally repeatedly over some sequence. The current iteration variable is set as a global injectable ...
python
def run(steps, iter_vars=None, data_out=None, out_interval=1, out_base_tables=None, out_run_tables=None, compress=False, out_base_local=True, out_run_local=True): """ Run steps in series, optionally repeatedly over some sequence. The current iteration variable is set as a global injectable ...
[ "def", "run", "(", "steps", ",", "iter_vars", "=", "None", ",", "data_out", "=", "None", ",", "out_interval", "=", "1", ",", "out_base_tables", "=", "None", ",", "out_run_tables", "=", "None", ",", "compress", "=", "False", ",", "out_base_local", "=", "T...
Run steps in series, optionally repeatedly over some sequence. The current iteration variable is set as a global injectable called ``iter_var``. Parameters ---------- steps : list of str List of steps to run identified by their name. iter_vars : iterable, optional The values of ...
[ "Run", "steps", "in", "series", "optionally", "repeatedly", "over", "some", "sequence", ".", "The", "current", "iteration", "variable", "is", "set", "as", "a", "global", "injectable", "called", "iter_var", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L1908-L2007
45,277
UDST/orca
orca/orca.py
injectables
def injectables(**kwargs): """ Temporarily add injectables to the pipeline environment. Takes only keyword arguments. Injectables will be returned to their original state when the context manager exits. """ global _INJECTABLES original = _INJECTABLES.copy() _INJECTABLES.update(kwa...
python
def injectables(**kwargs): """ Temporarily add injectables to the pipeline environment. Takes only keyword arguments. Injectables will be returned to their original state when the context manager exits. """ global _INJECTABLES original = _INJECTABLES.copy() _INJECTABLES.update(kwa...
[ "def", "injectables", "(", "*", "*", "kwargs", ")", ":", "global", "_INJECTABLES", "original", "=", "_INJECTABLES", ".", "copy", "(", ")", "_INJECTABLES", ".", "update", "(", "kwargs", ")", "yield", "_INJECTABLES", "=", "original" ]
Temporarily add injectables to the pipeline environment. Takes only keyword arguments. Injectables will be returned to their original state when the context manager exits.
[ "Temporarily", "add", "injectables", "to", "the", "pipeline", "environment", ".", "Takes", "only", "keyword", "arguments", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L2011-L2025
45,278
UDST/orca
orca/orca.py
temporary_tables
def temporary_tables(**kwargs): """ Temporarily set DataFrames as registered tables. Tables will be returned to their original state when the context manager exits. Caching is not enabled for tables registered via this function. """ global _TABLES original = _TABLES.copy() for k,...
python
def temporary_tables(**kwargs): """ Temporarily set DataFrames as registered tables. Tables will be returned to their original state when the context manager exits. Caching is not enabled for tables registered via this function. """ global _TABLES original = _TABLES.copy() for k,...
[ "def", "temporary_tables", "(", "*", "*", "kwargs", ")", ":", "global", "_TABLES", "original", "=", "_TABLES", ".", "copy", "(", ")", "for", "k", ",", "v", "in", "kwargs", ".", "items", "(", ")", ":", "if", "not", "isinstance", "(", "v", ",", "pd",...
Temporarily set DataFrames as registered tables. Tables will be returned to their original state when the context manager exits. Caching is not enabled for tables registered via this function.
[ "Temporarily", "set", "DataFrames", "as", "registered", "tables", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L2029-L2049
45,279
UDST/orca
orca/orca.py
eval_variable
def eval_variable(name, **kwargs): """ Execute a single variable function registered with Orca and return the result. Any keyword arguments are temporarily set as injectables. This gives the value as would be injected into a function. Parameters ---------- name : str Name of variabl...
python
def eval_variable(name, **kwargs): """ Execute a single variable function registered with Orca and return the result. Any keyword arguments are temporarily set as injectables. This gives the value as would be injected into a function. Parameters ---------- name : str Name of variabl...
[ "def", "eval_variable", "(", "name", ",", "*", "*", "kwargs", ")", ":", "with", "injectables", "(", "*", "*", "kwargs", ")", ":", "vars", "=", "_collect_variables", "(", "[", "name", "]", ",", "[", "name", "]", ")", "return", "vars", "[", "name", "...
Execute a single variable function registered with Orca and return the result. Any keyword arguments are temporarily set as injectables. This gives the value as would be injected into a function. Parameters ---------- name : str Name of variable to evaluate. Use variable expressions...
[ "Execute", "a", "single", "variable", "function", "registered", "with", "Orca", "and", "return", "the", "result", ".", "Any", "keyword", "arguments", "are", "temporarily", "set", "as", "injectables", ".", "This", "gives", "the", "value", "as", "would", "be", ...
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L2052-L2075
45,280
UDST/orca
orca/orca.py
DataFrameWrapper.to_frame
def to_frame(self, columns=None): """ Make a DataFrame with the given columns. Will always return a copy of the underlying table. Parameters ---------- columns : sequence or string, optional Sequence of the column names desired in the DataFrame. A string ...
python
def to_frame(self, columns=None): """ Make a DataFrame with the given columns. Will always return a copy of the underlying table. Parameters ---------- columns : sequence or string, optional Sequence of the column names desired in the DataFrame. A string ...
[ "def", "to_frame", "(", "self", ",", "columns", "=", "None", ")", ":", "extra_cols", "=", "_columns_for_table", "(", "self", ".", "name", ")", "if", "columns", "is", "not", "None", ":", "columns", "=", "[", "columns", "]", "if", "isinstance", "(", "col...
Make a DataFrame with the given columns. Will always return a copy of the underlying table. Parameters ---------- columns : sequence or string, optional Sequence of the column names desired in the DataFrame. A string can also be passed if only one column is desi...
[ "Make", "a", "DataFrame", "with", "the", "given", "columns", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L196-L237
45,281
UDST/orca
orca/orca.py
DataFrameWrapper.update_col
def update_col(self, column_name, series): """ Add or replace a column in the underlying DataFrame. Parameters ---------- column_name : str Column to add or replace. series : pandas.Series or sequence Column data. """ logger.debug...
python
def update_col(self, column_name, series): """ Add or replace a column in the underlying DataFrame. Parameters ---------- column_name : str Column to add or replace. series : pandas.Series or sequence Column data. """ logger.debug...
[ "def", "update_col", "(", "self", ",", "column_name", ",", "series", ")", ":", "logger", ".", "debug", "(", "'updating column {!r} in table {!r}'", ".", "format", "(", "column_name", ",", "self", ".", "name", ")", ")", "self", ".", "local", "[", "column_name...
Add or replace a column in the underlying DataFrame. Parameters ---------- column_name : str Column to add or replace. series : pandas.Series or sequence Column data.
[ "Add", "or", "replace", "a", "column", "in", "the", "underlying", "DataFrame", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L239-L253
45,282
UDST/orca
orca/orca.py
DataFrameWrapper.column_type
def column_type(self, column_name): """ Report column type as one of 'local', 'series', or 'function'. Parameters ---------- column_name : str Returns ------- col_type : {'local', 'series', 'function'} 'local' means that the column is part of...
python
def column_type(self, column_name): """ Report column type as one of 'local', 'series', or 'function'. Parameters ---------- column_name : str Returns ------- col_type : {'local', 'series', 'function'} 'local' means that the column is part of...
[ "def", "column_type", "(", "self", ",", "column_name", ")", ":", "extra_cols", "=", "list_columns_for_table", "(", "self", ".", "name", ")", "if", "column_name", "in", "extra_cols", ":", "col", "=", "_COLUMNS", "[", "(", "self", ".", "name", ",", "column_n...
Report column type as one of 'local', 'series', or 'function'. Parameters ---------- column_name : str Returns ------- col_type : {'local', 'series', 'function'} 'local' means that the column is part of the registered table, 'series' means the co...
[ "Report", "column", "type", "as", "one", "of", "local", "series", "or", "function", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L295-L325
45,283
UDST/orca
orca/orca.py
DataFrameWrapper.update_col_from_series
def update_col_from_series(self, column_name, series, cast=False): """ Update existing values in a column from another series. Index values must match in both column and series. Optionally casts data type to match the existing column. Parameters --------------- c...
python
def update_col_from_series(self, column_name, series, cast=False): """ Update existing values in a column from another series. Index values must match in both column and series. Optionally casts data type to match the existing column. Parameters --------------- c...
[ "def", "update_col_from_series", "(", "self", ",", "column_name", ",", "series", ",", "cast", "=", "False", ")", ":", "logger", ".", "debug", "(", "'updating column {!r} in table {!r}'", ".", "format", "(", "column_name", ",", "self", ".", "name", ")", ")", ...
Update existing values in a column from another series. Index values must match in both column and series. Optionally casts data type to match the existing column. Parameters --------------- column_name : str series : panas.Series cast: bool, optional, default Fa...
[ "Update", "existing", "values", "in", "a", "column", "from", "another", "series", ".", "Index", "values", "must", "match", "in", "both", "column", "and", "series", ".", "Optionally", "casts", "data", "type", "to", "match", "the", "existing", "column", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L327-L351
45,284
UDST/orca
orca/orca.py
DataFrameWrapper.clear_cached
def clear_cached(self): """ Remove cached results from this table's computed columns. """ _TABLE_CACHE.pop(self.name, None) for col in _columns_for_table(self.name).values(): col.clear_cached() logger.debug('cleared cached columns for table {!r}'.format(self....
python
def clear_cached(self): """ Remove cached results from this table's computed columns. """ _TABLE_CACHE.pop(self.name, None) for col in _columns_for_table(self.name).values(): col.clear_cached() logger.debug('cleared cached columns for table {!r}'.format(self....
[ "def", "clear_cached", "(", "self", ")", ":", "_TABLE_CACHE", ".", "pop", "(", "self", ".", "name", ",", "None", ")", "for", "col", "in", "_columns_for_table", "(", "self", ".", "name", ")", ".", "values", "(", ")", ":", "col", ".", "clear_cached", "...
Remove cached results from this table's computed columns.
[ "Remove", "cached", "results", "from", "this", "table", "s", "computed", "columns", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L356-L364
45,285
UDST/orca
orca/orca.py
TableFuncWrapper._call_func
def _call_func(self): """ Call the wrapped function and return the result wrapped by DataFrameWrapper. Also updates attributes like columns, index, and length. """ if _CACHING and self.cache and self.name in _TABLE_CACHE: logger.debug('returning table {!r} fr...
python
def _call_func(self): """ Call the wrapped function and return the result wrapped by DataFrameWrapper. Also updates attributes like columns, index, and length. """ if _CACHING and self.cache and self.name in _TABLE_CACHE: logger.debug('returning table {!r} fr...
[ "def", "_call_func", "(", "self", ")", ":", "if", "_CACHING", "and", "self", ".", "cache", "and", "self", ".", "name", "in", "_TABLE_CACHE", ":", "logger", ".", "debug", "(", "'returning table {!r} from cache'", ".", "format", "(", "self", ".", "name", ")"...
Call the wrapped function and return the result wrapped by DataFrameWrapper. Also updates attributes like columns, index, and length.
[ "Call", "the", "wrapped", "function", "and", "return", "the", "result", "wrapped", "by", "DataFrameWrapper", ".", "Also", "updates", "attributes", "like", "columns", "index", "and", "length", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L441-L470
45,286
UDST/orca
orca/orca.py
_ColumnFuncWrapper.clear_cached
def clear_cached(self): """ Remove any cached result of this column. """ x = _COLUMN_CACHE.pop((self.table_name, self.name), None) if x is not None: logger.debug( 'cleared cached value for column {!r} in table {!r}'.format( self.na...
python
def clear_cached(self): """ Remove any cached result of this column. """ x = _COLUMN_CACHE.pop((self.table_name, self.name), None) if x is not None: logger.debug( 'cleared cached value for column {!r} in table {!r}'.format( self.na...
[ "def", "clear_cached", "(", "self", ")", ":", "x", "=", "_COLUMN_CACHE", ".", "pop", "(", "(", "self", ".", "table_name", ",", "self", ".", "name", ")", ",", "None", ")", "if", "x", "is", "not", "None", ":", "logger", ".", "debug", "(", "'cleared c...
Remove any cached result of this column.
[ "Remove", "any", "cached", "result", "of", "this", "column", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L647-L656
45,287
UDST/orca
orca/orca.py
_InjectableFuncWrapper.clear_cached
def clear_cached(self): """ Clear a cached result for this injectable. """ x = _INJECTABLE_CACHE.pop(self.name, None) if x: logger.debug( 'injectable {!r} removed from cache'.format(self.name))
python
def clear_cached(self): """ Clear a cached result for this injectable. """ x = _INJECTABLE_CACHE.pop(self.name, None) if x: logger.debug( 'injectable {!r} removed from cache'.format(self.name))
[ "def", "clear_cached", "(", "self", ")", ":", "x", "=", "_INJECTABLE_CACHE", ".", "pop", "(", "self", ".", "name", ",", "None", ")", "if", "x", ":", "logger", ".", "debug", "(", "'injectable {!r} removed from cache'", ".", "format", "(", "self", ".", "na...
Clear a cached result for this injectable.
[ "Clear", "a", "cached", "result", "for", "this", "injectable", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L762-L770
45,288
UDST/orca
orca/orca.py
_StepFuncWrapper._tables_used
def _tables_used(self): """ Tables injected into the step. Returns ------- tables : set of str """ args = list(self._argspec.args) if self._argspec.defaults: default_args = list(self._argspec.defaults) else: default_args =...
python
def _tables_used(self): """ Tables injected into the step. Returns ------- tables : set of str """ args = list(self._argspec.args) if self._argspec.defaults: default_args = list(self._argspec.defaults) else: default_args =...
[ "def", "_tables_used", "(", "self", ")", ":", "args", "=", "list", "(", "self", ".", "_argspec", ".", "args", ")", "if", "self", ".", "_argspec", ".", "defaults", ":", "default_args", "=", "list", "(", "self", ".", "_argspec", ".", "defaults", ")", "...
Tables injected into the step. Returns ------- tables : set of str
[ "Tables", "injected", "into", "the", "step", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L799-L820
45,289
versae/qbe
django_qbe/utils.py
qbe_tree
def qbe_tree(graph, nodes, root=None): """ Given a graph, nodes to explore and an optinal root, do a breadth-first search in order to return the tree. """ if root: start = root else: index = random.randint(0, len(nodes) - 1) start = nodes[index] # A queue to BFS inste...
python
def qbe_tree(graph, nodes, root=None): """ Given a graph, nodes to explore and an optinal root, do a breadth-first search in order to return the tree. """ if root: start = root else: index = random.randint(0, len(nodes) - 1) start = nodes[index] # A queue to BFS inste...
[ "def", "qbe_tree", "(", "graph", ",", "nodes", ",", "root", "=", "None", ")", ":", "if", "root", ":", "start", "=", "root", "else", ":", "index", "=", "random", ".", "randint", "(", "0", ",", "len", "(", "nodes", ")", "-", "1", ")", "start", "=...
Given a graph, nodes to explore and an optinal root, do a breadth-first search in order to return the tree.
[ "Given", "a", "graph", "nodes", "to", "explore", "and", "an", "optinal", "root", "do", "a", "breadth", "-", "first", "search", "in", "order", "to", "return", "the", "tree", "." ]
be8b28de5bc67cf527ae5bcb183bffe5a91a41db
https://github.com/versae/qbe/blob/be8b28de5bc67cf527ae5bcb183bffe5a91a41db/django_qbe/utils.py#L244-L284
45,290
versae/qbe
django_qbe/utils.py
combine
def combine(items, k=None): """ Create a matrix in wich each row is a tuple containing one of solutions or solution k-esima. """ length_items = len(items) lengths = [len(i) for i in items] length = reduce(lambda x, y: x * y, lengths) repeats = [reduce(lambda x, y: x * y, lengths[i:]) ...
python
def combine(items, k=None): """ Create a matrix in wich each row is a tuple containing one of solutions or solution k-esima. """ length_items = len(items) lengths = [len(i) for i in items] length = reduce(lambda x, y: x * y, lengths) repeats = [reduce(lambda x, y: x * y, lengths[i:]) ...
[ "def", "combine", "(", "items", ",", "k", "=", "None", ")", ":", "length_items", "=", "len", "(", "items", ")", "lengths", "=", "[", "len", "(", "i", ")", "for", "i", "in", "items", "]", "length", "=", "reduce", "(", "lambda", "x", ",", "y", ":...
Create a matrix in wich each row is a tuple containing one of solutions or solution k-esima.
[ "Create", "a", "matrix", "in", "wich", "each", "row", "is", "a", "tuple", "containing", "one", "of", "solutions", "or", "solution", "k", "-", "esima", "." ]
be8b28de5bc67cf527ae5bcb183bffe5a91a41db
https://github.com/versae/qbe/blob/be8b28de5bc67cf527ae5bcb183bffe5a91a41db/django_qbe/utils.py#L394-L419
45,291
versae/qbe
django_qbe/utils.py
pickle_encode
def pickle_encode(session_dict): "Returns the given session dictionary pickled and encoded as a string." pickled = pickle.dumps(session_dict, pickle.HIGHEST_PROTOCOL) return base64.encodestring(pickled + get_query_hash(pickled).encode())
python
def pickle_encode(session_dict): "Returns the given session dictionary pickled and encoded as a string." pickled = pickle.dumps(session_dict, pickle.HIGHEST_PROTOCOL) return base64.encodestring(pickled + get_query_hash(pickled).encode())
[ "def", "pickle_encode", "(", "session_dict", ")", ":", "pickled", "=", "pickle", ".", "dumps", "(", "session_dict", ",", "pickle", ".", "HIGHEST_PROTOCOL", ")", "return", "base64", ".", "encodestring", "(", "pickled", "+", "get_query_hash", "(", "pickled", ")"...
Returns the given session dictionary pickled and encoded as a string.
[ "Returns", "the", "given", "session", "dictionary", "pickled", "and", "encoded", "as", "a", "string", "." ]
be8b28de5bc67cf527ae5bcb183bffe5a91a41db
https://github.com/versae/qbe/blob/be8b28de5bc67cf527ae5bcb183bffe5a91a41db/django_qbe/utils.py#L444-L447
45,292
UDST/orca
orca/utils/utils.py
func_source_data
def func_source_data(func): """ Return data about a function source, including file name, line number, and source code. Parameters ---------- func : object May be anything support by the inspect module, such as a function, method, or class. Returns ------- filename ...
python
def func_source_data(func): """ Return data about a function source, including file name, line number, and source code. Parameters ---------- func : object May be anything support by the inspect module, such as a function, method, or class. Returns ------- filename ...
[ "def", "func_source_data", "(", "func", ")", ":", "filename", "=", "inspect", ".", "getsourcefile", "(", "func", ")", "lineno", "=", "inspect", ".", "getsourcelines", "(", "func", ")", "[", "1", "]", "source", "=", "inspect", ".", "getsource", "(", "func...
Return data about a function source, including file name, line number, and source code. Parameters ---------- func : object May be anything support by the inspect module, such as a function, method, or class. Returns ------- filename : str lineno : int The line ...
[ "Return", "data", "about", "a", "function", "source", "including", "file", "name", "line", "number", "and", "source", "code", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/utils/utils.py#L4-L27
45,293
versae/qbe
django_qbe/forms.py
BaseQueryByExampleFormSet.clean
def clean(self): """ Checks that there is almost one field to select """ if any(self.errors): # Don't bother validating the formset unless each form is valid on # its own return (selects, aliases, froms, wheres, sorts, groups_by, param...
python
def clean(self): """ Checks that there is almost one field to select """ if any(self.errors): # Don't bother validating the formset unless each form is valid on # its own return (selects, aliases, froms, wheres, sorts, groups_by, param...
[ "def", "clean", "(", "self", ")", ":", "if", "any", "(", "self", ".", "errors", ")", ":", "# Don't bother validating the formset unless each form is valid on", "# its own", "return", "(", "selects", ",", "aliases", ",", "froms", ",", "wheres", ",", "sorts", ",",...
Checks that there is almost one field to select
[ "Checks", "that", "there", "is", "almost", "one", "field", "to", "select" ]
be8b28de5bc67cf527ae5bcb183bffe5a91a41db
https://github.com/versae/qbe/blob/be8b28de5bc67cf527ae5bcb183bffe5a91a41db/django_qbe/forms.py#L130-L149
45,294
versae/qbe
django_qbe/forms.py
BaseQueryByExampleFormSet.get_results
def get_results(self, limit=None, offset=None, query=None, admin_name=None, row_number=False): """ Fetch all results after perform SQL query and """ add_extra_ids = (admin_name is not None) if not query: sql = self.get_raw_query(limit=limit, offset...
python
def get_results(self, limit=None, offset=None, query=None, admin_name=None, row_number=False): """ Fetch all results after perform SQL query and """ add_extra_ids = (admin_name is not None) if not query: sql = self.get_raw_query(limit=limit, offset...
[ "def", "get_results", "(", "self", ",", "limit", "=", "None", ",", "offset", "=", "None", ",", "query", "=", "None", ",", "admin_name", "=", "None", ",", "row_number", "=", "False", ")", ":", "add_extra_ids", "=", "(", "admin_name", "is", "not", "None"...
Fetch all results after perform SQL query and
[ "Fetch", "all", "results", "after", "perform", "SQL", "query", "and" ]
be8b28de5bc67cf527ae5bcb183bffe5a91a41db
https://github.com/versae/qbe/blob/be8b28de5bc67cf527ae5bcb183bffe5a91a41db/django_qbe/forms.py#L313-L375
45,295
jgorset/django-respite
respite/utils/parsers.py
parse_content_type
def parse_content_type(content_type): """ Return a tuple of content type and charset. :param content_type: A string describing a content type. """ if '; charset=' in content_type: return tuple(content_type.split('; charset=')) else: if 'text' in content_type: encodin...
python
def parse_content_type(content_type): """ Return a tuple of content type and charset. :param content_type: A string describing a content type. """ if '; charset=' in content_type: return tuple(content_type.split('; charset=')) else: if 'text' in content_type: encodin...
[ "def", "parse_content_type", "(", "content_type", ")", ":", "if", "'; charset='", "in", "content_type", ":", "return", "tuple", "(", "content_type", ".", "split", "(", "'; charset='", ")", ")", "else", ":", "if", "'text'", "in", "content_type", ":", "encoding"...
Return a tuple of content type and charset. :param content_type: A string describing a content type.
[ "Return", "a", "tuple", "of", "content", "type", "and", "charset", "." ]
719469d11baf91d05917bab1623bd82adc543546
https://github.com/jgorset/django-respite/blob/719469d11baf91d05917bab1623bd82adc543546/respite/utils/parsers.py#L10-L29
45,296
jgorset/django-respite
respite/utils/parsers.py
parse_http_accept_header
def parse_http_accept_header(header): """ Return a list of content types listed in the HTTP Accept header ordered by quality. :param header: A string describing the contents of the HTTP Accept header. """ components = [item.strip() for item in header.split(',')] l = [] for component in...
python
def parse_http_accept_header(header): """ Return a list of content types listed in the HTTP Accept header ordered by quality. :param header: A string describing the contents of the HTTP Accept header. """ components = [item.strip() for item in header.split(',')] l = [] for component in...
[ "def", "parse_http_accept_header", "(", "header", ")", ":", "components", "=", "[", "item", ".", "strip", "(", ")", "for", "item", "in", "header", ".", "split", "(", "','", ")", "]", "l", "=", "[", "]", "for", "component", "in", "components", ":", "i...
Return a list of content types listed in the HTTP Accept header ordered by quality. :param header: A string describing the contents of the HTTP Accept header.
[ "Return", "a", "list", "of", "content", "types", "listed", "in", "the", "HTTP", "Accept", "header", "ordered", "by", "quality", "." ]
719469d11baf91d05917bab1623bd82adc543546
https://github.com/jgorset/django-respite/blob/719469d11baf91d05917bab1623bd82adc543546/respite/utils/parsers.py#L31-L62
45,297
jgorset/django-respite
respite/utils/parsers.py
parse_multipart_data
def parse_multipart_data(request): """ Parse a request with multipart data. :param request: A HttpRequest instance. """ return MultiPartParser( META=request.META, input_data=StringIO(request.body), upload_handlers=request.upload_handlers, encoding=request.encoding ...
python
def parse_multipart_data(request): """ Parse a request with multipart data. :param request: A HttpRequest instance. """ return MultiPartParser( META=request.META, input_data=StringIO(request.body), upload_handlers=request.upload_handlers, encoding=request.encoding ...
[ "def", "parse_multipart_data", "(", "request", ")", ":", "return", "MultiPartParser", "(", "META", "=", "request", ".", "META", ",", "input_data", "=", "StringIO", "(", "request", ".", "body", ")", ",", "upload_handlers", "=", "request", ".", "upload_handlers"...
Parse a request with multipart data. :param request: A HttpRequest instance.
[ "Parse", "a", "request", "with", "multipart", "data", "." ]
719469d11baf91d05917bab1623bd82adc543546
https://github.com/jgorset/django-respite/blob/719469d11baf91d05917bab1623bd82adc543546/respite/utils/parsers.py#L64-L75
45,298
jgorset/django-respite
respite/decorators.py
override_supported_formats
def override_supported_formats(formats): """ Override the views class' supported formats for the decorated function. Arguments: formats -- A list of strings describing formats, e.g. ``['html', 'json']``. """ def decorator(function): @wraps(function) def wrapper(self, *args, **kw...
python
def override_supported_formats(formats): """ Override the views class' supported formats for the decorated function. Arguments: formats -- A list of strings describing formats, e.g. ``['html', 'json']``. """ def decorator(function): @wraps(function) def wrapper(self, *args, **kw...
[ "def", "override_supported_formats", "(", "formats", ")", ":", "def", "decorator", "(", "function", ")", ":", "@", "wraps", "(", "function", ")", "def", "wrapper", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "supporte...
Override the views class' supported formats for the decorated function. Arguments: formats -- A list of strings describing formats, e.g. ``['html', 'json']``.
[ "Override", "the", "views", "class", "supported", "formats", "for", "the", "decorated", "function", "." ]
719469d11baf91d05917bab1623bd82adc543546
https://github.com/jgorset/django-respite/blob/719469d11baf91d05917bab1623bd82adc543546/respite/decorators.py#L9-L22
45,299
jgorset/django-respite
respite/decorators.py
route
def route(regex, method, name): """ Route the decorated view. :param regex: A string describing a regular expression to which the request path will be matched. :param method: A string describing the HTTP method that this view accepts. :param name: A string describing the name of the URL pattern. ...
python
def route(regex, method, name): """ Route the decorated view. :param regex: A string describing a regular expression to which the request path will be matched. :param method: A string describing the HTTP method that this view accepts. :param name: A string describing the name of the URL pattern. ...
[ "def", "route", "(", "regex", ",", "method", ",", "name", ")", ":", "def", "decorator", "(", "function", ")", ":", "function", ".", "route", "=", "routes", ".", "route", "(", "regex", "=", "regex", ",", "view", "=", "function", ".", "__name__", ",", ...
Route the decorated view. :param regex: A string describing a regular expression to which the request path will be matched. :param method: A string describing the HTTP method that this view accepts. :param name: A string describing the name of the URL pattern. ``regex`` may also be a lambda that a...
[ "Route", "the", "decorated", "view", "." ]
719469d11baf91d05917bab1623bd82adc543546
https://github.com/jgorset/django-respite/blob/719469d11baf91d05917bab1623bd82adc543546/respite/decorators.py#L24-L52