partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
valid
MochadDriver._x10_command
Real implementation
x10_any/__init__.py
def _x10_command(self, house_code, unit_number, state): """Real implementation""" # log = log or default_logger log = default_logger if state.startswith('xdim') or state.startswith('dim') or state.startswith('bright'): raise NotImplementedError('xdim/dim/bright %r' % ((house...
def _x10_command(self, house_code, unit_number, state): """Real implementation""" # log = log or default_logger log = default_logger if state.startswith('xdim') or state.startswith('dim') or state.startswith('bright'): raise NotImplementedError('xdim/dim/bright %r' % ((house...
[ "Real", "implementation" ]
clach04/x10_any
python
https://github.com/clach04/x10_any/blob/5b90a543b127ab9e6112fd547929b5ef4b8f0cbc/x10_any/__init__.py#L241-L262
[ "def", "_x10_command", "(", "self", ",", "house_code", ",", "unit_number", ",", "state", ")", ":", "# log = log or default_logger", "log", "=", "default_logger", "if", "state", ".", "startswith", "(", "'xdim'", ")", "or", "state", ".", "startswith", "(", "'dim...
5b90a543b127ab9e6112fd547929b5ef4b8f0cbc
valid
FirecrackerDriver._x10_command
Real implementation
x10_any/__init__.py
def _x10_command(self, house_code, unit_number, state): """Real implementation""" # log = log or default_logger log = default_logger # FIXME move these functions? def scale_255_to_8(x): """Scale x from 0..255 to 0..7 0 is considered OFF 8 is ...
def _x10_command(self, house_code, unit_number, state): """Real implementation""" # log = log or default_logger log = default_logger # FIXME move these functions? def scale_255_to_8(x): """Scale x from 0..255 to 0..7 0 is considered OFF 8 is ...
[ "Real", "implementation" ]
clach04/x10_any
python
https://github.com/clach04/x10_any/blob/5b90a543b127ab9e6112fd547929b5ef4b8f0cbc/x10_any/__init__.py#L290-L354
[ "def", "_x10_command", "(", "self", ",", "house_code", ",", "unit_number", ",", "state", ")", ":", "# log = log or default_logger", "log", "=", "default_logger", "# FIXME move these functions?", "def", "scale_255_to_8", "(", "x", ")", ":", "\"\"\"Scale x from 0..255 to ...
5b90a543b127ab9e6112fd547929b5ef4b8f0cbc
valid
get_parser
Generate an appropriate parser. :returns: an argument parser :rtype: `ArgumentParser`
check.py
def get_parser(): """ Generate an appropriate parser. :returns: an argument parser :rtype: `ArgumentParser` """ parser = argparse.ArgumentParser() parser.add_argument( "package", choices=arg_map.keys(), help="designates the package to test") parser.add_argument("...
def get_parser(): """ Generate an appropriate parser. :returns: an argument parser :rtype: `ArgumentParser` """ parser = argparse.ArgumentParser() parser.add_argument( "package", choices=arg_map.keys(), help="designates the package to test") parser.add_argument("...
[ "Generate", "an", "appropriate", "parser", "." ]
stratis-storage/into-dbus-python
python
https://github.com/stratis-storage/into-dbus-python/blob/81366049671f79116bbb81c97bf621800a2f6315/check.py#L19-L32
[ "def", "get_parser", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", ")", "parser", ".", "add_argument", "(", "\"package\"", ",", "choices", "=", "arg_map", ".", "keys", "(", ")", ",", "help", "=", "\"designates the package to test\"", ...
81366049671f79116bbb81c97bf621800a2f6315
valid
get_command
Get the pylint command for these arguments. :param `Namespace` namespace: the namespace
check.py
def get_command(namespace): """ Get the pylint command for these arguments. :param `Namespace` namespace: the namespace """ cmd = ["pylint", namespace.package] + arg_map[namespace.package] if namespace.ignore: cmd.append("--ignore=%s" % namespace.ignore) return cmd
def get_command(namespace): """ Get the pylint command for these arguments. :param `Namespace` namespace: the namespace """ cmd = ["pylint", namespace.package] + arg_map[namespace.package] if namespace.ignore: cmd.append("--ignore=%s" % namespace.ignore) return cmd
[ "Get", "the", "pylint", "command", "for", "these", "arguments", "." ]
stratis-storage/into-dbus-python
python
https://github.com/stratis-storage/into-dbus-python/blob/81366049671f79116bbb81c97bf621800a2f6315/check.py#L35-L44
[ "def", "get_command", "(", "namespace", ")", ":", "cmd", "=", "[", "\"pylint\"", ",", "namespace", ".", "package", "]", "+", "arg_map", "[", "namespace", ".", "package", "]", "if", "namespace", ".", "ignore", ":", "cmd", ".", "append", "(", "\"--ignore=%...
81366049671f79116bbb81c97bf621800a2f6315
valid
_wrapper
Wraps a generated function so that it catches all Type- and ValueErrors and raises IntoDPValueErrors. :param func: the transforming function
src/into_dbus_python/_xformer.py
def _wrapper(func): """ Wraps a generated function so that it catches all Type- and ValueErrors and raises IntoDPValueErrors. :param func: the transforming function """ @functools.wraps(func) def the_func(expr): """ The actual function. :param object expr: the expr...
def _wrapper(func): """ Wraps a generated function so that it catches all Type- and ValueErrors and raises IntoDPValueErrors. :param func: the transforming function """ @functools.wraps(func) def the_func(expr): """ The actual function. :param object expr: the expr...
[ "Wraps", "a", "generated", "function", "so", "that", "it", "catches", "all", "Type", "-", "and", "ValueErrors", "and", "raises", "IntoDPValueErrors", "." ]
stratis-storage/into-dbus-python
python
https://github.com/stratis-storage/into-dbus-python/blob/81366049671f79116bbb81c97bf621800a2f6315/src/into_dbus_python/_xformer.py#L27-L48
[ "def", "_wrapper", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "the_func", "(", "expr", ")", ":", "\"\"\"\n The actual function.\n\n :param object expr: the expression to be xformed to dbus-python types\n \"\"\"", "try"...
81366049671f79116bbb81c97bf621800a2f6315
valid
xformers
Get the list of xformer functions for the given signature. :param str sig: a signature :returns: a list of xformer functions for the given signature. :rtype: list of tuple of a function * str Each function catches all TypeErrors it encounters and raises corresponding IntoDPValueError exceptions.
src/into_dbus_python/_xformer.py
def xformers(sig): """ Get the list of xformer functions for the given signature. :param str sig: a signature :returns: a list of xformer functions for the given signature. :rtype: list of tuple of a function * str Each function catches all TypeErrors it encounters and raises corresponding...
def xformers(sig): """ Get the list of xformer functions for the given signature. :param str sig: a signature :returns: a list of xformer functions for the given signature. :rtype: list of tuple of a function * str Each function catches all TypeErrors it encounters and raises corresponding...
[ "Get", "the", "list", "of", "xformer", "functions", "for", "the", "given", "signature", "." ]
stratis-storage/into-dbus-python
python
https://github.com/stratis-storage/into-dbus-python/blob/81366049671f79116bbb81c97bf621800a2f6315/src/into_dbus_python/_xformer.py#L283-L296
[ "def", "xformers", "(", "sig", ")", ":", "return", "[", "(", "_wrapper", "(", "f", ")", ",", "l", ")", "for", "(", "f", ",", "l", ")", "in", "_XFORMER", ".", "PARSER", ".", "parseString", "(", "sig", ",", "parseAll", "=", "True", ")", "]" ]
81366049671f79116bbb81c97bf621800a2f6315
valid
xformer
Returns a transformer function for the given signature. :param str signature: a dbus signature :returns: a function to transform a list of objects to inhabit the signature :rtype: (list of object) -> (list of object)
src/into_dbus_python/_xformer.py
def xformer(signature): """ Returns a transformer function for the given signature. :param str signature: a dbus signature :returns: a function to transform a list of objects to inhabit the signature :rtype: (list of object) -> (list of object) """ funcs = [f for (f, _) in xformers(signatu...
def xformer(signature): """ Returns a transformer function for the given signature. :param str signature: a dbus signature :returns: a function to transform a list of objects to inhabit the signature :rtype: (list of object) -> (list of object) """ funcs = [f for (f, _) in xformers(signatu...
[ "Returns", "a", "transformer", "function", "for", "the", "given", "signature", "." ]
stratis-storage/into-dbus-python
python
https://github.com/stratis-storage/into-dbus-python/blob/81366049671f79116bbb81c97bf621800a2f6315/src/into_dbus_python/_xformer.py#L299-L329
[ "def", "xformer", "(", "signature", ")", ":", "funcs", "=", "[", "f", "for", "(", "f", ",", "_", ")", "in", "xformers", "(", "signature", ")", "]", "def", "the_func", "(", "objects", ")", ":", "\"\"\"\n Returns the a list of objects, transformed.\n\n ...
81366049671f79116bbb81c97bf621800a2f6315
valid
_ToDbusXformer._variant_levels
Gets the level for the variant. :param int level: the current variant level :param int variant: the value for this level if variant :returns: a level for the object and one for the function :rtype: int * int
src/into_dbus_python/_xformer.py
def _variant_levels(level, variant): """ Gets the level for the variant. :param int level: the current variant level :param int variant: the value for this level if variant :returns: a level for the object and one for the function :rtype: int * int """ r...
def _variant_levels(level, variant): """ Gets the level for the variant. :param int level: the current variant level :param int variant: the value for this level if variant :returns: a level for the object and one for the function :rtype: int * int """ r...
[ "Gets", "the", "level", "for", "the", "variant", "." ]
stratis-storage/into-dbus-python
python
https://github.com/stratis-storage/into-dbus-python/blob/81366049671f79116bbb81c97bf621800a2f6315/src/into_dbus_python/_xformer.py#L65-L76
[ "def", "_variant_levels", "(", "level", ",", "variant", ")", ":", "return", "(", "level", "+", "variant", ",", "level", "+", "variant", ")", "if", "variant", "!=", "0", "else", "(", "variant", ",", "level", ")" ]
81366049671f79116bbb81c97bf621800a2f6315
valid
_ToDbusXformer._handle_variant
Generate the correct function for a variant signature. :returns: function that returns an appropriate value :rtype: ((str * object) or list)-> object
src/into_dbus_python/_xformer.py
def _handle_variant(self): """ Generate the correct function for a variant signature. :returns: function that returns an appropriate value :rtype: ((str * object) or list)-> object """ def the_func(a_tuple, variant=0): """ Function for generating...
def _handle_variant(self): """ Generate the correct function for a variant signature. :returns: function that returns an appropriate value :rtype: ((str * object) or list)-> object """ def the_func(a_tuple, variant=0): """ Function for generating...
[ "Generate", "the", "correct", "function", "for", "a", "variant", "signature", "." ]
stratis-storage/into-dbus-python
python
https://github.com/stratis-storage/into-dbus-python/blob/81366049671f79116bbb81c97bf621800a2f6315/src/into_dbus_python/_xformer.py#L78-L103
[ "def", "_handle_variant", "(", "self", ")", ":", "def", "the_func", "(", "a_tuple", ",", "variant", "=", "0", ")", ":", "\"\"\"\n Function for generating a variant value from a tuple.\n\n :param a_tuple: the parts of the variant\n :type a_tuple: (str ...
81366049671f79116bbb81c97bf621800a2f6315
valid
_ToDbusXformer._handle_array
Generate the correct function for an array signature. :param toks: the list of parsed tokens :returns: function that returns an Array or Dictionary value :rtype: ((or list dict) -> ((or Array Dictionary) * int)) * str
src/into_dbus_python/_xformer.py
def _handle_array(toks): """ Generate the correct function for an array signature. :param toks: the list of parsed tokens :returns: function that returns an Array or Dictionary value :rtype: ((or list dict) -> ((or Array Dictionary) * int)) * str """ if len(toks...
def _handle_array(toks): """ Generate the correct function for an array signature. :param toks: the list of parsed tokens :returns: function that returns an Array or Dictionary value :rtype: ((or list dict) -> ((or Array Dictionary) * int)) * str """ if len(toks...
[ "Generate", "the", "correct", "function", "for", "an", "array", "signature", "." ]
stratis-storage/into-dbus-python
python
https://github.com/stratis-storage/into-dbus-python/blob/81366049671f79116bbb81c97bf621800a2f6315/src/into_dbus_python/_xformer.py#L106-L173
[ "def", "_handle_array", "(", "toks", ")", ":", "if", "len", "(", "toks", ")", "==", "5", "and", "toks", "[", "1", "]", "==", "'{'", "and", "toks", "[", "4", "]", "==", "'}'", ":", "subtree", "=", "toks", "[", "2", ":", "4", "]", "signature", ...
81366049671f79116bbb81c97bf621800a2f6315
valid
_ToDbusXformer._handle_struct
Generate the correct function for a struct signature. :param toks: the list of parsed tokens :returns: function that returns an Array or Dictionary value :rtype: ((list or tuple) -> (Struct * int)) * str
src/into_dbus_python/_xformer.py
def _handle_struct(toks): """ Generate the correct function for a struct signature. :param toks: the list of parsed tokens :returns: function that returns an Array or Dictionary value :rtype: ((list or tuple) -> (Struct * int)) * str """ subtrees = toks[1:-1] ...
def _handle_struct(toks): """ Generate the correct function for a struct signature. :param toks: the list of parsed tokens :returns: function that returns an Array or Dictionary value :rtype: ((list or tuple) -> (Struct * int)) * str """ subtrees = toks[1:-1] ...
[ "Generate", "the", "correct", "function", "for", "a", "struct", "signature", "." ]
stratis-storage/into-dbus-python
python
https://github.com/stratis-storage/into-dbus-python/blob/81366049671f79116bbb81c97bf621800a2f6315/src/into_dbus_python/_xformer.py#L176-L218
[ "def", "_handle_struct", "(", "toks", ")", ":", "subtrees", "=", "toks", "[", "1", ":", "-", "1", "]", "signature", "=", "''", ".", "join", "(", "s", "for", "(", "_", ",", "s", ")", "in", "subtrees", ")", "funcs", "=", "[", "f", "for", "(", "...
81366049671f79116bbb81c97bf621800a2f6315
valid
_ToDbusXformer._handle_base_case
Handle a base case. :param type klass: the class constructor :param str symbol: the type code
src/into_dbus_python/_xformer.py
def _handle_base_case(klass, symbol): """ Handle a base case. :param type klass: the class constructor :param str symbol: the type code """ def the_func(value, variant=0): """ Base case. :param int variant: variant level for this obj...
def _handle_base_case(klass, symbol): """ Handle a base case. :param type klass: the class constructor :param str symbol: the type code """ def the_func(value, variant=0): """ Base case. :param int variant: variant level for this obj...
[ "Handle", "a", "base", "case", "." ]
stratis-storage/into-dbus-python
python
https://github.com/stratis-storage/into-dbus-python/blob/81366049671f79116bbb81c97bf621800a2f6315/src/into_dbus_python/_xformer.py#L221-L241
[ "def", "_handle_base_case", "(", "klass", ",", "symbol", ")", ":", "def", "the_func", "(", "value", ",", "variant", "=", "0", ")", ":", "\"\"\"\n Base case.\n\n :param int variant: variant level for this object\n :returns: a tuple of a dbus object...
81366049671f79116bbb81c97bf621800a2f6315
valid
signature
Get the signature of a dbus object. :param dbus_object: the object :type dbus_object: a dbus object :param bool unpack: if True, unpack from enclosing variant type :returns: the corresponding signature :rtype: str
src/into_dbus_python/_signature.py
def signature(dbus_object, unpack=False): """ Get the signature of a dbus object. :param dbus_object: the object :type dbus_object: a dbus object :param bool unpack: if True, unpack from enclosing variant type :returns: the corresponding signature :rtype: str """ # pylint: disable=t...
def signature(dbus_object, unpack=False): """ Get the signature of a dbus object. :param dbus_object: the object :type dbus_object: a dbus object :param bool unpack: if True, unpack from enclosing variant type :returns: the corresponding signature :rtype: str """ # pylint: disable=t...
[ "Get", "the", "signature", "of", "a", "dbus", "object", "." ]
stratis-storage/into-dbus-python
python
https://github.com/stratis-storage/into-dbus-python/blob/81366049671f79116bbb81c97bf621800a2f6315/src/into_dbus_python/_signature.py#L23-L116
[ "def", "signature", "(", "dbus_object", ",", "unpack", "=", "False", ")", ":", "# pylint: disable=too-many-return-statements", "# pylint: disable=too-many-branches", "if", "dbus_object", ".", "variant_level", "!=", "0", "and", "not", "unpack", ":", "return", "'v'", "i...
81366049671f79116bbb81c97bf621800a2f6315
valid
plot_indices
Plot multi-index set :param mis: Multi-index set :type mis: Iterable of SparseIndices :param dims: Which dimensions to use for plotting :type dims: List of integers. :param weights: Weights associated with each multi-index :type weights: Dictionary :param quantiles: Number of groups plo...
swutil/plots.py
def plot_indices(mis, dims=None, weights=None, groups=1,legend = True,index_labels=None, colors = None,axis_labels = None,size_exponent=0.1,ax=None): ''' Plot multi-index set :param mis: Multi-index set :type mis: Iterable of SparseIndices :param dims: Which dimensions to use for plotting :...
def plot_indices(mis, dims=None, weights=None, groups=1,legend = True,index_labels=None, colors = None,axis_labels = None,size_exponent=0.1,ax=None): ''' Plot multi-index set :param mis: Multi-index set :type mis: Iterable of SparseIndices :param dims: Which dimensions to use for plotting :...
[ "Plot", "multi", "-", "index", "set", ":", "param", "mis", ":", "Multi", "-", "index", "set", ":", "type", "mis", ":", "Iterable", "of", "SparseIndices", ":", "param", "dims", ":", "Which", "dimensions", "to", "use", "for", "plotting", ":", "type", "di...
soerenwolfers/swutil
python
https://github.com/soerenwolfers/swutil/blob/2d598f2deac8b7e20df95dbc68017e5ab5d6180c/swutil/plots.py#L67-L191
[ "def", "plot_indices", "(", "mis", ",", "dims", "=", "None", ",", "weights", "=", "None", ",", "groups", "=", "1", ",", "legend", "=", "True", ",", "index_labels", "=", "None", ",", "colors", "=", "None", ",", "axis_labels", "=", "None", ",", "size_e...
2d598f2deac8b7e20df95dbc68017e5ab5d6180c
valid
ezplot
Plot polynomial approximation. :param vectorized: `f` can handle an array of inputs
swutil/plots.py
def ezplot(f,xlim,ylim=None,ax = None,vectorized=True,N=None,contour = False,args=None,kwargs=None,dry_run=False,show=None,include_endpoints=False): ''' Plot polynomial approximation. :param vectorized: `f` can handle an array of inputs ''' kwargs = kwargs or {} args = args or [] d = 1 ...
def ezplot(f,xlim,ylim=None,ax = None,vectorized=True,N=None,contour = False,args=None,kwargs=None,dry_run=False,show=None,include_endpoints=False): ''' Plot polynomial approximation. :param vectorized: `f` can handle an array of inputs ''' kwargs = kwargs or {} args = args or [] d = 1 ...
[ "Plot", "polynomial", "approximation", ".", ":", "param", "vectorized", ":", "f", "can", "handle", "an", "array", "of", "inputs" ]
soerenwolfers/swutil
python
https://github.com/soerenwolfers/swutil/blob/2d598f2deac8b7e20df95dbc68017e5ab5d6180c/swutil/plots.py#L194-L250
[ "def", "ezplot", "(", "f", ",", "xlim", ",", "ylim", "=", "None", ",", "ax", "=", "None", ",", "vectorized", "=", "True", ",", "N", "=", "None", ",", "contour", "=", "False", ",", "args", "=", "None", ",", "kwargs", "=", "None", ",", "dry_run", ...
2d598f2deac8b7e20df95dbc68017e5ab5d6180c
valid
plot3D
Surface plot. Generate X and Y using, for example X,Y = np.mgrid[0:1:50j, 0:1:50j] or X,Y= np.meshgrid([0,1,2],[1,2,3]). :param X: 2D-Array of x-coordinates :param Y: 2D-Array of y-coordinates :param Z: 2D-Array of z-coordinates
swutil/plots.py
def plot3D(X, Y, Z): ''' Surface plot. Generate X and Y using, for example X,Y = np.mgrid[0:1:50j, 0:1:50j] or X,Y= np.meshgrid([0,1,2],[1,2,3]). :param X: 2D-Array of x-coordinates :param Y: 2D-Array of y-coordinates :param Z: 2D-Array of z-coordinates ...
def plot3D(X, Y, Z): ''' Surface plot. Generate X and Y using, for example X,Y = np.mgrid[0:1:50j, 0:1:50j] or X,Y= np.meshgrid([0,1,2],[1,2,3]). :param X: 2D-Array of x-coordinates :param Y: 2D-Array of y-coordinates :param Z: 2D-Array of z-coordinates ...
[ "Surface", "plot", ".", "Generate", "X", "and", "Y", "using", "for", "example", "X", "Y", "=", "np", ".", "mgrid", "[", "0", ":", "1", ":", "50j", "0", ":", "1", ":", "50j", "]", "or", "X", "Y", "=", "np", ".", "meshgrid", "(", "[", "0", "1...
soerenwolfers/swutil
python
https://github.com/soerenwolfers/swutil/blob/2d598f2deac8b7e20df95dbc68017e5ab5d6180c/swutil/plots.py#L252-L279
[ "def", "plot3D", "(", "X", ",", "Y", ",", "Z", ")", ":", "fig", "=", "plt", ".", "figure", "(", ")", "ax", "=", "Axes3D", "(", "fig", ")", "light", "=", "LightSource", "(", "90", ",", "90", ")", "illuminated_surface", "=", "light", ".", "shade", ...
2d598f2deac8b7e20df95dbc68017e5ab5d6180c
valid
plot_convergence
Show loglog or semilogy convergence plot. Specify :code:`reference` if exact limit is known. Otherwise limit is taken to be last entry of :code:`values`. Distance to limit is computed as RMSE (or analogous p-norm if p is specified) Specify either :code:`plot_rate`(pass number or 'fit') o...
swutil/plots.py
def plot_convergence(times, values, name=None, title=None, reference='self', convergence_type='algebraic', expect_residuals=None, expect_times=None, plot_rate='fit', base = np.exp(0),xlabel = 'x', p=2, preasymptotics=True, stagnation=False, marker='.', legend='lower left',relat...
def plot_convergence(times, values, name=None, title=None, reference='self', convergence_type='algebraic', expect_residuals=None, expect_times=None, plot_rate='fit', base = np.exp(0),xlabel = 'x', p=2, preasymptotics=True, stagnation=False, marker='.', legend='lower left',relat...
[ "Show", "loglog", "or", "semilogy", "convergence", "plot", ".", "Specify", ":", "code", ":", "reference", "if", "exact", "limit", "is", "known", ".", "Otherwise", "limit", "is", "taken", "to", "be", "last", "entry", "of", ":", "code", ":", "values", ".",...
soerenwolfers/swutil
python
https://github.com/soerenwolfers/swutil/blob/2d598f2deac8b7e20df95dbc68017e5ab5d6180c/swutil/plots.py#L286-L428
[ "def", "plot_convergence", "(", "times", ",", "values", ",", "name", "=", "None", ",", "title", "=", "None", ",", "reference", "=", "'self'", ",", "convergence_type", "=", "'algebraic'", ",", "expect_residuals", "=", "None", ",", "expect_times", "=", "None",...
2d598f2deac8b7e20df95dbc68017e5ab5d6180c
valid
lower
Enforces lower case options and option values where appropriate
swutil/config.py
def lower(option,value): ''' Enforces lower case options and option values where appropriate ''' if type(option) is str: option=option.lower() if type(value) is str: value=value.lower() return (option,value)
def lower(option,value): ''' Enforces lower case options and option values where appropriate ''' if type(option) is str: option=option.lower() if type(value) is str: value=value.lower() return (option,value)
[ "Enforces", "lower", "case", "options", "and", "option", "values", "where", "appropriate" ]
soerenwolfers/swutil
python
https://github.com/soerenwolfers/swutil/blob/2d598f2deac8b7e20df95dbc68017e5ab5d6180c/swutil/config.py#L21-L29
[ "def", "lower", "(", "option", ",", "value", ")", ":", "if", "type", "(", "option", ")", "is", "str", ":", "option", "=", "option", ".", "lower", "(", ")", "if", "type", "(", "value", ")", "is", "str", ":", "value", "=", "value", ".", "lower", ...
2d598f2deac8b7e20df95dbc68017e5ab5d6180c
valid
to_float
Converts string values to floats when appropriate
swutil/config.py
def to_float(option,value): ''' Converts string values to floats when appropriate ''' if type(value) is str: try: value=float(value) except ValueError: pass return (option,value)
def to_float(option,value): ''' Converts string values to floats when appropriate ''' if type(value) is str: try: value=float(value) except ValueError: pass return (option,value)
[ "Converts", "string", "values", "to", "floats", "when", "appropriate" ]
soerenwolfers/swutil
python
https://github.com/soerenwolfers/swutil/blob/2d598f2deac8b7e20df95dbc68017e5ab5d6180c/swutil/config.py#L41-L50
[ "def", "to_float", "(", "option", ",", "value", ")", ":", "if", "type", "(", "value", ")", "is", "str", ":", "try", ":", "value", "=", "float", "(", "value", ")", "except", "ValueError", ":", "pass", "return", "(", "option", ",", "value", ")" ]
2d598f2deac8b7e20df95dbc68017e5ab5d6180c
valid
to_bool
Converts string values to booleans when appropriate
swutil/config.py
def to_bool(option,value): ''' Converts string values to booleans when appropriate ''' if type(value) is str: if value.lower() == 'true': value=True elif value.lower() == 'false': value=False return (option,value)
def to_bool(option,value): ''' Converts string values to booleans when appropriate ''' if type(value) is str: if value.lower() == 'true': value=True elif value.lower() == 'false': value=False return (option,value)
[ "Converts", "string", "values", "to", "booleans", "when", "appropriate" ]
soerenwolfers/swutil
python
https://github.com/soerenwolfers/swutil/blob/2d598f2deac8b7e20df95dbc68017e5ab5d6180c/swutil/config.py#L52-L61
[ "def", "to_bool", "(", "option", ",", "value", ")", ":", "if", "type", "(", "value", ")", "is", "str", ":", "if", "value", ".", "lower", "(", ")", "==", "'true'", ":", "value", "=", "True", "elif", "value", ".", "lower", "(", ")", "==", "'false'"...
2d598f2deac8b7e20df95dbc68017e5ab5d6180c
valid
Config.fork
Create fork and store it in current instance
swutil/config.py
def fork(self,name): ''' Create fork and store it in current instance ''' fork=deepcopy(self) self[name]=fork return fork
def fork(self,name): ''' Create fork and store it in current instance ''' fork=deepcopy(self) self[name]=fork return fork
[ "Create", "fork", "and", "store", "it", "in", "current", "instance" ]
soerenwolfers/swutil
python
https://github.com/soerenwolfers/swutil/blob/2d598f2deac8b7e20df95dbc68017e5ab5d6180c/swutil/config.py#L136-L142
[ "def", "fork", "(", "self", ",", "name", ")", ":", "fork", "=", "deepcopy", "(", "self", ")", "self", "[", "name", "]", "=", "fork", "return", "fork" ]
2d598f2deac8b7e20df95dbc68017e5ab5d6180c
valid
smart_range
smart_range(1,3,9)==[1,3,5,7,9]
swutil/aux.py
def smart_range(*args): ''' smart_range(1,3,9)==[1,3,5,7,9] ''' if len(args)==1:#String string_input = True string = args[0].replace(' ','') original_args=string.split(',') args = [] for arg in original_args: try: args.append(ast.litera...
def smart_range(*args): ''' smart_range(1,3,9)==[1,3,5,7,9] ''' if len(args)==1:#String string_input = True string = args[0].replace(' ','') original_args=string.split(',') args = [] for arg in original_args: try: args.append(ast.litera...
[ "smart_range", "(", "1", "3", "9", ")", "==", "[", "1", "3", "5", "7", "9", "]" ]
soerenwolfers/swutil
python
https://github.com/soerenwolfers/swutil/blob/2d598f2deac8b7e20df95dbc68017e5ab5d6180c/swutil/aux.py#L21-L97
[ "def", "smart_range", "(", "*", "args", ")", ":", "if", "len", "(", "args", ")", "==", "1", ":", "#String", "string_input", "=", "True", "string", "=", "args", "[", "0", "]", ".", "replace", "(", "' '", ",", "''", ")", "original_args", "=", "string...
2d598f2deac8b7e20df95dbc68017e5ab5d6180c
valid
ld_to_dl
Convert list of dictionaries to dictionary of lists
swutil/aux.py
def ld_to_dl(ld): ''' Convert list of dictionaries to dictionary of lists ''' if ld: keys = list(ld[0]) dl = {key:[d[key] for d in ld] for key in keys} return dl else: return {}
def ld_to_dl(ld): ''' Convert list of dictionaries to dictionary of lists ''' if ld: keys = list(ld[0]) dl = {key:[d[key] for d in ld] for key in keys} return dl else: return {}
[ "Convert", "list", "of", "dictionaries", "to", "dictionary", "of", "lists" ]
soerenwolfers/swutil
python
https://github.com/soerenwolfers/swutil/blob/2d598f2deac8b7e20df95dbc68017e5ab5d6180c/swutil/aux.py#L99-L108
[ "def", "ld_to_dl", "(", "ld", ")", ":", "if", "ld", ":", "keys", "=", "list", "(", "ld", "[", "0", "]", ")", "dl", "=", "{", "key", ":", "[", "d", "[", "key", "]", "for", "d", "in", "ld", "]", "for", "key", "in", "keys", "}", "return", "d...
2d598f2deac8b7e20df95dbc68017e5ab5d6180c
valid
chain
Concatenate functions
swutil/aux.py
def chain(*fs): ''' Concatenate functions ''' def chained(x): for f in reversed(fs): if f: x=f(x) return x return chained
def chain(*fs): ''' Concatenate functions ''' def chained(x): for f in reversed(fs): if f: x=f(x) return x return chained
[ "Concatenate", "functions" ]
soerenwolfers/swutil
python
https://github.com/soerenwolfers/swutil/blob/2d598f2deac8b7e20df95dbc68017e5ab5d6180c/swutil/aux.py#L116-L125
[ "def", "chain", "(", "*", "fs", ")", ":", "def", "chained", "(", "x", ")", ":", "for", "f", "in", "reversed", "(", "fs", ")", ":", "if", "f", ":", "x", "=", "f", "(", "x", ")", "return", "x", "return", "chained" ]
2d598f2deac8b7e20df95dbc68017e5ab5d6180c
valid
split_list
Subdivide list into N lists
swutil/aux.py
def split_list(l,N): ''' Subdivide list into N lists ''' npmode = isinstance(l,np.ndarray) if npmode: l=list(l) g=np.concatenate((np.array([0]),np.cumsum(split_integer(len(l),length=N)))) s=[l[g[i]:g[i+1]] for i in range(N)] if npmode: s=[np.array(sl) for sl in s] ret...
def split_list(l,N): ''' Subdivide list into N lists ''' npmode = isinstance(l,np.ndarray) if npmode: l=list(l) g=np.concatenate((np.array([0]),np.cumsum(split_integer(len(l),length=N)))) s=[l[g[i]:g[i+1]] for i in range(N)] if npmode: s=[np.array(sl) for sl in s] ret...
[ "Subdivide", "list", "into", "N", "lists" ]
soerenwolfers/swutil
python
https://github.com/soerenwolfers/swutil/blob/2d598f2deac8b7e20df95dbc68017e5ab5d6180c/swutil/aux.py#L158-L169
[ "def", "split_list", "(", "l", ",", "N", ")", ":", "npmode", "=", "isinstance", "(", "l", ",", "np", ".", "ndarray", ")", "if", "npmode", ":", "l", "=", "list", "(", "l", ")", "g", "=", "np", ".", "concatenate", "(", "(", "np", ".", "array", ...
2d598f2deac8b7e20df95dbc68017e5ab5d6180c
valid
random_word
Creates random lowercase words from dictionary or by alternating vowels and consonants The second method chooses from 85**length words. The dictionary method chooses from 3000--12000 words for 3<=length<=12 (though this of course depends on the available dictionary) :param length: word length ...
swutil/aux.py
def random_word(length,dictionary = False):#may return offensive words if dictionary = True ''' Creates random lowercase words from dictionary or by alternating vowels and consonants The second method chooses from 85**length words. The dictionary method chooses from 3000--12000 words for 3<=length<...
def random_word(length,dictionary = False):#may return offensive words if dictionary = True ''' Creates random lowercase words from dictionary or by alternating vowels and consonants The second method chooses from 85**length words. The dictionary method chooses from 3000--12000 words for 3<=length<...
[ "Creates", "random", "lowercase", "words", "from", "dictionary", "or", "by", "alternating", "vowels", "and", "consonants", "The", "second", "method", "chooses", "from", "85", "**", "length", "words", ".", "The", "dictionary", "method", "chooses", "from", "3000",...
soerenwolfers/swutil
python
https://github.com/soerenwolfers/swutil/blob/2d598f2deac8b7e20df95dbc68017e5ab5d6180c/swutil/aux.py#L177-L198
[ "def", "random_word", "(", "length", ",", "dictionary", "=", "False", ")", ":", "#may return offensive words if dictionary = True", "if", "dictionary", ":", "try", ":", "with", "open", "(", "'/usr/share/dict/words'", ")", "as", "fp", ":", "words", "=", "[", "wor...
2d598f2deac8b7e20df95dbc68017e5ab5d6180c
valid
string_from_seconds
Converts seconds into elapsed time string of form (X days(s)?,)? HH:MM:SS.YY
swutil/aux.py
def string_from_seconds(seconds): ''' Converts seconds into elapsed time string of form (X days(s)?,)? HH:MM:SS.YY ''' td = str(timedelta(seconds = seconds)) parts = td.split('.') if len(parts) == 1: td = td+'.00' elif len(parts) == 2: td = '.'.join([parts[0],p...
def string_from_seconds(seconds): ''' Converts seconds into elapsed time string of form (X days(s)?,)? HH:MM:SS.YY ''' td = str(timedelta(seconds = seconds)) parts = td.split('.') if len(parts) == 1: td = td+'.00' elif len(parts) == 2: td = '.'.join([parts[0],p...
[ "Converts", "seconds", "into", "elapsed", "time", "string", "of", "form", "(", "X", "days", "(", "s", ")", "?", ")", "?", "HH", ":", "MM", ":", "SS", ".", "YY" ]
soerenwolfers/swutil
python
https://github.com/soerenwolfers/swutil/blob/2d598f2deac8b7e20df95dbc68017e5ab5d6180c/swutil/aux.py#L200-L213
[ "def", "string_from_seconds", "(", "seconds", ")", ":", "td", "=", "str", "(", "timedelta", "(", "seconds", "=", "seconds", ")", ")", "parts", "=", "td", ".", "split", "(", "'.'", ")", "if", "len", "(", "parts", ")", "==", "1", ":", "td", "=", "t...
2d598f2deac8b7e20df95dbc68017e5ab5d6180c
valid
input_with_prefill
https://stackoverflow.com/questions/8505163/is-it-possible-to-prefill-a-input-in-python-3s-command-line-interface
swutil/aux.py
def input_with_prefill(prompt, text): ''' https://stackoverflow.com/questions/8505163/is-it-possible-to-prefill-a-input-in-python-3s-command-line-interface ''' def hook(): readline.insert_text(text) readline.redisplay() try: readline.set_pre_input_hook(hook) except Except...
def input_with_prefill(prompt, text): ''' https://stackoverflow.com/questions/8505163/is-it-possible-to-prefill-a-input-in-python-3s-command-line-interface ''' def hook(): readline.insert_text(text) readline.redisplay() try: readline.set_pre_input_hook(hook) except Except...
[ "https", ":", "//", "stackoverflow", ".", "com", "/", "questions", "/", "8505163", "/", "is", "-", "it", "-", "possible", "-", "to", "-", "prefill", "-", "a", "-", "input", "-", "in", "-", "python", "-", "3s", "-", "command", "-", "line", "-", "i...
soerenwolfers/swutil
python
https://github.com/soerenwolfers/swutil/blob/2d598f2deac8b7e20df95dbc68017e5ab5d6180c/swutil/aux.py#L215-L231
[ "def", "input_with_prefill", "(", "prompt", ",", "text", ")", ":", "def", "hook", "(", ")", ":", "readline", ".", "insert_text", "(", "text", ")", "readline", ".", "redisplay", "(", ")", "try", ":", "readline", ".", "set_pre_input_hook", "(", "hook", ")"...
2d598f2deac8b7e20df95dbc68017e5ab5d6180c
valid
EasyHPC
:param n_tasks: How many tasks does the decorated function handle? :param n_results: If the decorated function handles many tasks at once, are the results reduced (n_results = 'one') or not (as many results as tasks)? :param reduce: Function that reduces multiple outputs to a single output :par...
swutil/hpc.py
def EasyHPC(backend:In('MP', 'MPI')|Function='MP', n_tasks:In('implicitly many', 'many', 'one', 'count')='one',#Count is special case of implicitly many where it is already known how to split jobs n_results:In('many', 'one')='one', aux_output:Bool=True, # Parellelize only first ent...
def EasyHPC(backend:In('MP', 'MPI')|Function='MP', n_tasks:In('implicitly many', 'many', 'one', 'count')='one',#Count is special case of implicitly many where it is already known how to split jobs n_results:In('many', 'one')='one', aux_output:Bool=True, # Parellelize only first ent...
[ ":", "param", "n_tasks", ":", "How", "many", "tasks", "does", "the", "decorated", "function", "handle?", ":", "param", "n_results", ":", "If", "the", "decorated", "function", "handles", "many", "tasks", "at", "once", "are", "the", "results", "reduced", "(", ...
soerenwolfers/swutil
python
https://github.com/soerenwolfers/swutil/blob/2d598f2deac8b7e20df95dbc68017e5ab5d6180c/swutil/hpc.py#L33-L81
[ "def", "EasyHPC", "(", "backend", ":", "In", "(", "'MP'", ",", "'MPI'", ")", "|", "Function", "=", "'MP'", ",", "n_tasks", ":", "In", "(", "'implicitly many'", ",", "'many'", ",", "'one'", ",", "'count'", ")", "=", "'one'", ",", "#Count is special case o...
2d598f2deac8b7e20df95dbc68017e5ab5d6180c
valid
path_from_keywords
turns keyword pairs into path or filename if `into=='path'`, then keywords are separted by underscores, else keywords are used to create a directory hierarchy
swutil/files.py
def path_from_keywords(keywords,into='path'): ''' turns keyword pairs into path or filename if `into=='path'`, then keywords are separted by underscores, else keywords are used to create a directory hierarchy ''' subdirs = [] def prepare_string(s): s = str(s) s = re.sub('[]...
def path_from_keywords(keywords,into='path'): ''' turns keyword pairs into path or filename if `into=='path'`, then keywords are separted by underscores, else keywords are used to create a directory hierarchy ''' subdirs = [] def prepare_string(s): s = str(s) s = re.sub('[]...
[ "turns", "keyword", "pairs", "into", "path", "or", "filename", "if", "into", "==", "path", "then", "keywords", "are", "separted", "by", "underscores", "else", "keywords", "are", "used", "to", "create", "a", "directory", "hierarchy" ]
soerenwolfers/swutil
python
https://github.com/soerenwolfers/swutil/blob/2d598f2deac8b7e20df95dbc68017e5ab5d6180c/swutil/files.py#L6-L41
[ "def", "path_from_keywords", "(", "keywords", ",", "into", "=", "'path'", ")", ":", "subdirs", "=", "[", "]", "def", "prepare_string", "(", "s", ")", ":", "s", "=", "str", "(", "s", ")", "s", "=", "re", ".", "sub", "(", "'[][{},*\"'", "+", "f\"'{os...
2d598f2deac8b7e20df95dbc68017e5ab5d6180c
valid
find_files
https://stackoverflow.com/questions/1724693/find-a-file-in-python WARNING: pattern is by default matched to entire path not to file names
swutil/files.py
def find_files(pattern, path=None,match_name=False): ''' https://stackoverflow.com/questions/1724693/find-a-file-in-python WARNING: pattern is by default matched to entire path not to file names ''' if not path: path = os.getcwd() result = [] for root, __, files in os.walk(path): ...
def find_files(pattern, path=None,match_name=False): ''' https://stackoverflow.com/questions/1724693/find-a-file-in-python WARNING: pattern is by default matched to entire path not to file names ''' if not path: path = os.getcwd() result = [] for root, __, files in os.walk(path): ...
[ "https", ":", "//", "stackoverflow", ".", "com", "/", "questions", "/", "1724693", "/", "find", "-", "a", "-", "file", "-", "in", "-", "python" ]
soerenwolfers/swutil
python
https://github.com/soerenwolfers/swutil/blob/2d598f2deac8b7e20df95dbc68017e5ab5d6180c/swutil/files.py#L55-L68
[ "def", "find_files", "(", "pattern", ",", "path", "=", "None", ",", "match_name", "=", "False", ")", ":", "if", "not", "path", ":", "path", "=", "os", ".", "getcwd", "(", ")", "result", "=", "[", "]", "for", "root", ",", "__", ",", "files", "in",...
2d598f2deac8b7e20df95dbc68017e5ab5d6180c
valid
find_directories
WARNING: pattern is matched to entire path, not directory names, unless match_name = True
swutil/files.py
def find_directories(pattern, path=None,match_name=False): ''' WARNING: pattern is matched to entire path, not directory names, unless match_name = True ''' if not path: path = os.getcwd() result = [] for root, __, __ in os.walk(path): match_against = os.path.basename(root) i...
def find_directories(pattern, path=None,match_name=False): ''' WARNING: pattern is matched to entire path, not directory names, unless match_name = True ''' if not path: path = os.getcwd() result = [] for root, __, __ in os.walk(path): match_against = os.path.basename(root) i...
[ "WARNING", ":", "pattern", "is", "matched", "to", "entire", "path", "not", "directory", "names", "unless", "match_name", "=", "True" ]
soerenwolfers/swutil
python
https://github.com/soerenwolfers/swutil/blob/2d598f2deac8b7e20df95dbc68017e5ab5d6180c/swutil/files.py#L70-L86
[ "def", "find_directories", "(", "pattern", ",", "path", "=", "None", ",", "match_name", "=", "False", ")", ":", "if", "not", "path", ":", "path", "=", "os", ".", "getcwd", "(", ")", "result", "=", "[", "]", "for", "root", ",", "__", ",", "__", "i...
2d598f2deac8b7e20df95dbc68017e5ab5d6180c
valid
zip_dir
https://stackoverflow.com/questions/1855095/how-to-create-a-zip-archive-of-a-directory
swutil/files.py
def zip_dir(zip_name, source_dir,rename_source_dir=False): ''' https://stackoverflow.com/questions/1855095/how-to-create-a-zip-archive-of-a-directory ''' src_path = Path(source_dir).expanduser().resolve() with ZipFile(zip_name, 'w', ZIP_DEFLATED) as zf: for file in src_path.rglob('*'): ...
def zip_dir(zip_name, source_dir,rename_source_dir=False): ''' https://stackoverflow.com/questions/1855095/how-to-create-a-zip-archive-of-a-directory ''' src_path = Path(source_dir).expanduser().resolve() with ZipFile(zip_name, 'w', ZIP_DEFLATED) as zf: for file in src_path.rglob('*'): ...
[ "https", ":", "//", "stackoverflow", ".", "com", "/", "questions", "/", "1855095", "/", "how", "-", "to", "-", "create", "-", "a", "-", "zip", "-", "archive", "-", "of", "-", "a", "-", "directory" ]
soerenwolfers/swutil
python
https://github.com/soerenwolfers/swutil/blob/2d598f2deac8b7e20df95dbc68017e5ab5d6180c/swutil/files.py#L91-L102
[ "def", "zip_dir", "(", "zip_name", ",", "source_dir", ",", "rename_source_dir", "=", "False", ")", ":", "src_path", "=", "Path", "(", "source_dir", ")", ".", "expanduser", "(", ")", ".", "resolve", "(", ")", "with", "ZipFile", "(", "zip_name", ",", "'w'"...
2d598f2deac8b7e20df95dbc68017e5ab5d6180c
valid
integral
Turns an array A of length N (the function values in N points) and an array dF of length N-1 (the masses of the N-1 intervals) into an array of length N (the integral \int A dF at N points, with first entry 0) :param A: Integrand (optional, default ones, length N) :param dF: Integrator (optional, d...
swutil/np_tools.py
def integral(A=None,dF=None,F=None,axis = 0,trapez = False,cumulative = False): ''' Turns an array A of length N (the function values in N points) and an array dF of length N-1 (the masses of the N-1 intervals) into an array of length N (the integral \int A dF at N points, with first entry 0) :...
def integral(A=None,dF=None,F=None,axis = 0,trapez = False,cumulative = False): ''' Turns an array A of length N (the function values in N points) and an array dF of length N-1 (the masses of the N-1 intervals) into an array of length N (the integral \int A dF at N points, with first entry 0) :...
[ "Turns", "an", "array", "A", "of", "length", "N", "(", "the", "function", "values", "in", "N", "points", ")", "and", "an", "array", "dF", "of", "length", "N", "-", "1", "(", "the", "masses", "of", "the", "N", "-", "1", "intervals", ")", "into", "...
soerenwolfers/swutil
python
https://github.com/soerenwolfers/swutil/blob/2d598f2deac8b7e20df95dbc68017e5ab5d6180c/swutil/np_tools.py#L109-L156
[ "def", "integral", "(", "A", "=", "None", ",", "dF", "=", "None", ",", "F", "=", "None", ",", "axis", "=", "0", ",", "trapez", "=", "False", ",", "cumulative", "=", "False", ")", ":", "ndim", "=", "max", "(", "v", ".", "ndim", "for", "v", "in...
2d598f2deac8b7e20df95dbc68017e5ab5d6180c
valid
toeplitz_multiplication
Multiply Toeplitz matrix with first row a and first column b with vector v Normal matrix multiplication would require storage and runtime O(n^2); embedding into a circulant matrix and using FFT yields O(log(n)n)
swutil/np_tools.py
def toeplitz_multiplication(a,b,v): ''' Multiply Toeplitz matrix with first row a and first column b with vector v Normal matrix multiplication would require storage and runtime O(n^2); embedding into a circulant matrix and using FFT yields O(log(n)n) ''' a = np.reshape(a,(-1)) b = np.r...
def toeplitz_multiplication(a,b,v): ''' Multiply Toeplitz matrix with first row a and first column b with vector v Normal matrix multiplication would require storage and runtime O(n^2); embedding into a circulant matrix and using FFT yields O(log(n)n) ''' a = np.reshape(a,(-1)) b = np.r...
[ "Multiply", "Toeplitz", "matrix", "with", "first", "row", "a", "and", "first", "column", "b", "with", "vector", "v", "Normal", "matrix", "multiplication", "would", "require", "storage", "and", "runtime", "O", "(", "n^2", ")", ";", "embedding", "into", "a", ...
soerenwolfers/swutil
python
https://github.com/soerenwolfers/swutil/blob/2d598f2deac8b7e20df95dbc68017e5ab5d6180c/swutil/np_tools.py#L158-L173
[ "def", "toeplitz_multiplication", "(", "a", ",", "b", ",", "v", ")", ":", "a", "=", "np", ".", "reshape", "(", "a", ",", "(", "-", "1", ")", ")", "b", "=", "np", ".", "reshape", "(", "b", ",", "(", "-", "1", ")", ")", "n", "=", "len", "("...
2d598f2deac8b7e20df95dbc68017e5ab5d6180c
valid
grid_evaluation
Evaluate function on given grid and return values in grid format Assume X and Y are 2-dimensional arrays containing x and y coordinates, respectively, of a two-dimensional grid, and f is a function that takes 1-d arrays with two entries. This function evaluates f on the grid points described by X ...
swutil/np_tools.py
def grid_evaluation(X, Y, f,vectorized=True): ''' Evaluate function on given grid and return values in grid format Assume X and Y are 2-dimensional arrays containing x and y coordinates, respectively, of a two-dimensional grid, and f is a function that takes 1-d arrays with two entries. This f...
def grid_evaluation(X, Y, f,vectorized=True): ''' Evaluate function on given grid and return values in grid format Assume X and Y are 2-dimensional arrays containing x and y coordinates, respectively, of a two-dimensional grid, and f is a function that takes 1-d arrays with two entries. This f...
[ "Evaluate", "function", "on", "given", "grid", "and", "return", "values", "in", "grid", "format", "Assume", "X", "and", "Y", "are", "2", "-", "dimensional", "arrays", "containing", "x", "and", "y", "coordinates", "respectively", "of", "a", "two", "-", "dim...
soerenwolfers/swutil
python
https://github.com/soerenwolfers/swutil/blob/2d598f2deac8b7e20df95dbc68017e5ab5d6180c/swutil/np_tools.py#L175-L196
[ "def", "grid_evaluation", "(", "X", ",", "Y", ",", "f", ",", "vectorized", "=", "True", ")", ":", "XX", "=", "np", ".", "reshape", "(", "np", ".", "concatenate", "(", "[", "X", "[", "...", ",", "None", "]", ",", "Y", "[", "...", ",", "None", ...
2d598f2deac8b7e20df95dbc68017e5ab5d6180c
valid
orthonormal_complement_basis
Return orthonormal basis of complement of vector. :param v: 1-dimensional numpy array :return: Matrix whose .dot() computes coefficients w.r.t. an orthonormal basis of the complement of v (i.e. whose row vectors form an orthonormal basis of the complement of v)
swutil/np_tools.py
def orthonormal_complement_basis(v:NDim(1)): ''' Return orthonormal basis of complement of vector. :param v: 1-dimensional numpy array :return: Matrix whose .dot() computes coefficients w.r.t. an orthonormal basis of the complement of v (i.e. whose row vectors form an orthonormal basis of...
def orthonormal_complement_basis(v:NDim(1)): ''' Return orthonormal basis of complement of vector. :param v: 1-dimensional numpy array :return: Matrix whose .dot() computes coefficients w.r.t. an orthonormal basis of the complement of v (i.e. whose row vectors form an orthonormal basis of...
[ "Return", "orthonormal", "basis", "of", "complement", "of", "vector", ".", ":", "param", "v", ":", "1", "-", "dimensional", "numpy", "array", ":", "return", ":", "Matrix", "whose", ".", "dot", "()", "computes", "coefficients", "w", ".", "r", ".", "t", ...
soerenwolfers/swutil
python
https://github.com/soerenwolfers/swutil/blob/2d598f2deac8b7e20df95dbc68017e5ab5d6180c/swutil/np_tools.py#L201-L210
[ "def", "orthonormal_complement_basis", "(", "v", ":", "NDim", "(", "1", ")", ")", ":", "_", ",", "_", ",", "V", "=", "np", ".", "linalg", ".", "svd", "(", "np", ".", "array", "(", "[", "v", "]", ")", ")", "return", "V", "[", "1", ":", "]" ]
2d598f2deac8b7e20df95dbc68017e5ab5d6180c
valid
weighted_median
Returns element such that sum of weights below and above are (roughly) equal :param values: Values whose median is sought :type values: List of reals :param weights: Weights of each value :type weights: List of positive reals :return: value of weighted median :rtype: Real
swutil/np_tools.py
def weighted_median(values, weights): ''' Returns element such that sum of weights below and above are (roughly) equal :param values: Values whose median is sought :type values: List of reals :param weights: Weights of each value :type weights: List of positive reals :return: value of w...
def weighted_median(values, weights): ''' Returns element such that sum of weights below and above are (roughly) equal :param values: Values whose median is sought :type values: List of reals :param weights: Weights of each value :type weights: List of positive reals :return: value of w...
[ "Returns", "element", "such", "that", "sum", "of", "weights", "below", "and", "above", "are", "(", "roughly", ")", "equal", ":", "param", "values", ":", "Values", "whose", "median", "is", "sought", ":", "type", "values", ":", "List", "of", "reals", ":", ...
soerenwolfers/swutil
python
https://github.com/soerenwolfers/swutil/blob/2d598f2deac8b7e20df95dbc68017e5ab5d6180c/swutil/np_tools.py#L212-L237
[ "def", "weighted_median", "(", "values", ",", "weights", ")", ":", "if", "len", "(", "values", ")", "==", "1", ":", "return", "values", "[", "0", "]", "if", "len", "(", "values", ")", "==", "0", ":", "raise", "ValueError", "(", "'Cannot take median of ...
2d598f2deac8b7e20df95dbc68017e5ab5d6180c
valid
log_calls
Decorator that logs function calls in their self.log
swutil/decorators.py
def log_calls(function): ''' Decorator that logs function calls in their self.log ''' def wrapper(self,*args,**kwargs): self.log.log(group=function.__name__,message='Enter') function(self,*args,**kwargs) self.log.log(group=function.__name__,message='Exit') return wrapper
def log_calls(function): ''' Decorator that logs function calls in their self.log ''' def wrapper(self,*args,**kwargs): self.log.log(group=function.__name__,message='Enter') function(self,*args,**kwargs) self.log.log(group=function.__name__,message='Exit') return wrapper
[ "Decorator", "that", "logs", "function", "calls", "in", "their", "self", ".", "log" ]
soerenwolfers/swutil
python
https://github.com/soerenwolfers/swutil/blob/2d598f2deac8b7e20df95dbc68017e5ab5d6180c/swutil/decorators.py#L8-L16
[ "def", "log_calls", "(", "function", ")", ":", "def", "wrapper", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "log", ".", "log", "(", "group", "=", "function", ".", "__name__", ",", "message", "=", "'Enter'", ")", ...
2d598f2deac8b7e20df95dbc68017e5ab5d6180c
valid
add_runtime
Decorator that adds a runtime profile object to the output
swutil/decorators.py
def add_runtime(function): ''' Decorator that adds a runtime profile object to the output ''' def wrapper(*args,**kwargs): pr=cProfile.Profile() pr.enable() output = function(*args,**kwargs) pr.disable() return pr,output return wrapper
def add_runtime(function): ''' Decorator that adds a runtime profile object to the output ''' def wrapper(*args,**kwargs): pr=cProfile.Profile() pr.enable() output = function(*args,**kwargs) pr.disable() return pr,output return wrapper
[ "Decorator", "that", "adds", "a", "runtime", "profile", "object", "to", "the", "output" ]
soerenwolfers/swutil
python
https://github.com/soerenwolfers/swutil/blob/2d598f2deac8b7e20df95dbc68017e5ab5d6180c/swutil/decorators.py#L18-L28
[ "def", "add_runtime", "(", "function", ")", ":", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "pr", "=", "cProfile", ".", "Profile", "(", ")", "pr", ".", "enable", "(", ")", "output", "=", "function", "(", "*", "args", "...
2d598f2deac8b7e20df95dbc68017e5ab5d6180c
valid
print_memory
Decorator that prints memory information at each call of the function
swutil/decorators.py
def print_memory(function): ''' Decorator that prints memory information at each call of the function ''' import memory_profiler def wrapper(*args,**kwargs): m = StringIO() temp_func = memory_profiler.profile(func = function,stream=m,precision=4) output = temp_func(*args,**kw...
def print_memory(function): ''' Decorator that prints memory information at each call of the function ''' import memory_profiler def wrapper(*args,**kwargs): m = StringIO() temp_func = memory_profiler.profile(func = function,stream=m,precision=4) output = temp_func(*args,**kw...
[ "Decorator", "that", "prints", "memory", "information", "at", "each", "call", "of", "the", "function" ]
soerenwolfers/swutil
python
https://github.com/soerenwolfers/swutil/blob/2d598f2deac8b7e20df95dbc68017e5ab5d6180c/swutil/decorators.py#L30-L42
[ "def", "print_memory", "(", "function", ")", ":", "import", "memory_profiler", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "m", "=", "StringIO", "(", ")", "temp_func", "=", "memory_profiler", ".", "profile", "(", "func", "=", ...
2d598f2deac8b7e20df95dbc68017e5ab5d6180c
valid
print_profile
Decorator that prints memory and runtime information at each call of the function
swutil/decorators.py
def print_profile(function): ''' Decorator that prints memory and runtime information at each call of the function ''' import memory_profiler def wrapper(*args,**kwargs): m=StringIO() pr=cProfile.Profile() pr.enable() temp_func = memory_profiler.profile(func=function,...
def print_profile(function): ''' Decorator that prints memory and runtime information at each call of the function ''' import memory_profiler def wrapper(*args,**kwargs): m=StringIO() pr=cProfile.Profile() pr.enable() temp_func = memory_profiler.profile(func=function,...
[ "Decorator", "that", "prints", "memory", "and", "runtime", "information", "at", "each", "call", "of", "the", "function" ]
soerenwolfers/swutil
python
https://github.com/soerenwolfers/swutil/blob/2d598f2deac8b7e20df95dbc68017e5ab5d6180c/swutil/decorators.py#L44-L61
[ "def", "print_profile", "(", "function", ")", ":", "import", "memory_profiler", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "m", "=", "StringIO", "(", ")", "pr", "=", "cProfile", ".", "Profile", "(", ")", "pr", ".", "enable...
2d598f2deac8b7e20df95dbc68017e5ab5d6180c
valid
declaration
Declare abstract function. Requires function to be empty except for docstring describing semantics. To apply function, first argument must come with implementation of semantics.
swutil/decorators.py
def declaration(function): ''' Declare abstract function. Requires function to be empty except for docstring describing semantics. To apply function, first argument must come with implementation of semantics. ''' function,name=_strip_function(function) if not function.__code__.co_code ...
def declaration(function): ''' Declare abstract function. Requires function to be empty except for docstring describing semantics. To apply function, first argument must come with implementation of semantics. ''' function,name=_strip_function(function) if not function.__code__.co_code ...
[ "Declare", "abstract", "function", ".", "Requires", "function", "to", "be", "empty", "except", "for", "docstring", "describing", "semantics", ".", "To", "apply", "function", "first", "argument", "must", "come", "with", "implementation", "of", "semantics", "." ]
soerenwolfers/swutil
python
https://github.com/soerenwolfers/swutil/blob/2d598f2deac8b7e20df95dbc68017e5ab5d6180c/swutil/decorators.py#L107-L120
[ "def", "declaration", "(", "function", ")", ":", "function", ",", "name", "=", "_strip_function", "(", "function", ")", "if", "not", "function", ".", "__code__", ".", "co_code", "in", "[", "empty_function", ".", "__code__", ".", "co_code", ",", "doc_string_o...
2d598f2deac8b7e20df95dbc68017e5ab5d6180c
valid
print_runtime
Decorator that prints running time information at each call of the function
swutil/decorators.py
def print_runtime(function): ''' Decorator that prints running time information at each call of the function ''' def wrapper(*args,**kwargs): pr=cProfile.Profile() pr.enable() output = function(*args,**kwargs) pr.disable() ps = pstats.Stats(pr) ps.sort_sta...
def print_runtime(function): ''' Decorator that prints running time information at each call of the function ''' def wrapper(*args,**kwargs): pr=cProfile.Profile() pr.enable() output = function(*args,**kwargs) pr.disable() ps = pstats.Stats(pr) ps.sort_sta...
[ "Decorator", "that", "prints", "running", "time", "information", "at", "each", "call", "of", "the", "function" ]
soerenwolfers/swutil
python
https://github.com/soerenwolfers/swutil/blob/2d598f2deac8b7e20df95dbc68017e5ab5d6180c/swutil/decorators.py#L162-L174
[ "def", "print_runtime", "(", "function", ")", ":", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "pr", "=", "cProfile", ".", "Profile", "(", ")", "pr", ".", "enable", "(", ")", "output", "=", "function", "(", "*", "args", ...
2d598f2deac8b7e20df95dbc68017e5ab5d6180c
valid
print_peak_memory
Print peak memory usage (in MB) of a function call :param func: Function to be called :param stream: Stream to write peak memory usage (defaults to stdout) https://stackoverflow.com/questions/9850995/tracking-maximum-memory-usage-by-a-python-function
swutil/decorators.py
def print_peak_memory(func,stream = None): """ Print peak memory usage (in MB) of a function call :param func: Function to be called :param stream: Stream to write peak memory usage (defaults to stdout) https://stackoverflow.com/questions/9850995/tracking-maximum-memory-usage-by-a-python...
def print_peak_memory(func,stream = None): """ Print peak memory usage (in MB) of a function call :param func: Function to be called :param stream: Stream to write peak memory usage (defaults to stdout) https://stackoverflow.com/questions/9850995/tracking-maximum-memory-usage-by-a-python...
[ "Print", "peak", "memory", "usage", "(", "in", "MB", ")", "of", "a", "function", "call", ":", "param", "func", ":", "Function", "to", "be", "called", ":", "param", "stream", ":", "Stream", "to", "write", "peak", "memory", "usage", "(", "defaults", "to"...
soerenwolfers/swutil
python
https://github.com/soerenwolfers/swutil/blob/2d598f2deac8b7e20df95dbc68017e5ab5d6180c/swutil/decorators.py#L176-L212
[ "def", "print_peak_memory", "(", "func", ",", "stream", "=", "None", ")", ":", "import", "time", "import", "psutil", "import", "os", "memory_denominator", "=", "1024", "**", "2", "memory_usage_refresh", "=", "0.05", "def", "wrapper", "(", "*", "args", ",", ...
2d598f2deac8b7e20df95dbc68017e5ab5d6180c
valid
validate
Make sure `arg` adheres to specification :param arg: Anything :param spec: Specification :type spec: Specification :return: Validated object
swutil/validation.py
def validate(arg, spec): ''' Make sure `arg` adheres to specification :param arg: Anything :param spec: Specification :type spec: Specification :return: Validated object ''' rejection_subreason = None if spec is None: return arg try: return spec._validat...
def validate(arg, spec): ''' Make sure `arg` adheres to specification :param arg: Anything :param spec: Specification :type spec: Specification :return: Validated object ''' rejection_subreason = None if spec is None: return arg try: return spec._validat...
[ "Make", "sure", "arg", "adheres", "to", "specification", ":", "param", "arg", ":", "Anything", ":", "param", "spec", ":", "Specification", ":", "type", "spec", ":", "Specification", ":", "return", ":", "Validated", "object" ]
soerenwolfers/swutil
python
https://github.com/soerenwolfers/swutil/blob/2d598f2deac8b7e20df95dbc68017e5ab5d6180c/swutil/validation.py#L127-L163
[ "def", "validate", "(", "arg", ",", "spec", ")", ":", "rejection_subreason", "=", "None", "if", "spec", "is", "None", ":", "return", "arg", "try", ":", "return", "spec", ".", "_validate", "(", "arg", ")", "except", "Exception", "as", "e", ":", "rejecti...
2d598f2deac8b7e20df95dbc68017e5ab5d6180c
valid
_validate_many
Similar to validate but validates multiple objects at once, each with their own specification. Fill objects that were specified but not provided with NotPassed or default values Apply `value_condition` to object dictionary as a whole
swutil/validation.py
def _validate_many(args, specs, defaults,passed_conditions,value_conditions, allow_unknowns,unknowns_spec): ''' Similar to validate but validates multiple objects at once, each with their own specification. Fill objects that were specified but not provided with NotPassed or default ...
def _validate_many(args, specs, defaults,passed_conditions,value_conditions, allow_unknowns,unknowns_spec): ''' Similar to validate but validates multiple objects at once, each with their own specification. Fill objects that were specified but not provided with NotPassed or default ...
[ "Similar", "to", "validate", "but", "validates", "multiple", "objects", "at", "once", "each", "with", "their", "own", "specification", ".", "Fill", "objects", "that", "were", "specified", "but", "not", "provided", "with", "NotPassed", "or", "default", "values", ...
soerenwolfers/swutil
python
https://github.com/soerenwolfers/swutil/blob/2d598f2deac8b7e20df95dbc68017e5ab5d6180c/swutil/validation.py#L165-L198
[ "def", "_validate_many", "(", "args", ",", "specs", ",", "defaults", ",", "passed_conditions", ",", "value_conditions", ",", "allow_unknowns", ",", "unknowns_spec", ")", ":", "validated_args", "=", "builtins", ".", "dict", "(", ")", "passed_but_not_specified", "="...
2d598f2deac8b7e20df95dbc68017e5ab5d6180c
valid
black_scholes
Return M Euler-Maruyama sample paths with N time steps of S_t, where dS_t = S_t*r*dt+S_t*sigma*dW_t S(0)=S0 :rtype: M x N x d array
swutil/stochastic_processes.py
def black_scholes(times,r,sigma,S0,d,M,dW=None): ''' Return M Euler-Maruyama sample paths with N time steps of S_t, where dS_t = S_t*r*dt+S_t*sigma*dW_t S(0)=S0 :rtype: M x N x d array ''' N=len(times) times = times.flatten() p0 = np.log(S0) if dW is None: d...
def black_scholes(times,r,sigma,S0,d,M,dW=None): ''' Return M Euler-Maruyama sample paths with N time steps of S_t, where dS_t = S_t*r*dt+S_t*sigma*dW_t S(0)=S0 :rtype: M x N x d array ''' N=len(times) times = times.flatten() p0 = np.log(S0) if dW is None: d...
[ "Return", "M", "Euler", "-", "Maruyama", "sample", "paths", "with", "N", "time", "steps", "of", "S_t", "where", "dS_t", "=", "S_t", "*", "r", "*", "dt", "+", "S_t", "*", "sigma", "*", "dW_t", "S", "(", "0", ")", "=", "S0", ":", "rtype", ":", "M...
soerenwolfers/swutil
python
https://github.com/soerenwolfers/swutil/blob/2d598f2deac8b7e20df95dbc68017e5ab5d6180c/swutil/stochastic_processes.py#L10-L31
[ "def", "black_scholes", "(", "times", ",", "r", ",", "sigma", ",", "S0", ",", "d", ",", "M", ",", "dW", "=", "None", ")", ":", "N", "=", "len", "(", "times", ")", "times", "=", "times", ".", "flatten", "(", ")", "p0", "=", "np", ".", "log", ...
2d598f2deac8b7e20df95dbc68017e5ab5d6180c
valid
heston
Return M Euler-Maruyama sample paths with N time steps of (S_t,v_t), where (S_t,v_t) follows the Heston model of mathematical finance :rtype: M x N x d array
swutil/stochastic_processes.py
def heston(times,mu,rho,kappa,theta,xi,S0,nu0,d,M,nu_1d=True): ''' Return M Euler-Maruyama sample paths with N time steps of (S_t,v_t), where (S_t,v_t) follows the Heston model of mathematical finance :rtype: M x N x d array ''' d_nu = 1 if nu_1d else d nu = np.zeros((M,len(times),d_nu)...
def heston(times,mu,rho,kappa,theta,xi,S0,nu0,d,M,nu_1d=True): ''' Return M Euler-Maruyama sample paths with N time steps of (S_t,v_t), where (S_t,v_t) follows the Heston model of mathematical finance :rtype: M x N x d array ''' d_nu = 1 if nu_1d else d nu = np.zeros((M,len(times),d_nu)...
[ "Return", "M", "Euler", "-", "Maruyama", "sample", "paths", "with", "N", "time", "steps", "of", "(", "S_t", "v_t", ")", "where", "(", "S_t", "v_t", ")", "follows", "the", "Heston", "model", "of", "mathematical", "finance" ]
soerenwolfers/swutil
python
https://github.com/soerenwolfers/swutil/blob/2d598f2deac8b7e20df95dbc68017e5ab5d6180c/swutil/stochastic_processes.py#L33-L61
[ "def", "heston", "(", "times", ",", "mu", ",", "rho", ",", "kappa", ",", "theta", ",", "xi", ",", "S0", ",", "nu0", ",", "d", ",", "M", ",", "nu_1d", "=", "True", ")", ":", "d_nu", "=", "1", "if", "nu_1d", "else", "d", "nu", "=", "np", ".",...
2d598f2deac8b7e20df95dbc68017e5ab5d6180c
valid
fBrown
Sample fractional Brownian motion with differentiability index H on interval [0,T] (H=1/2 yields standard Brownian motion) :param H: Differentiability, larger than 0 :param T: Final time :param N: Number of time steps :param M: Number of samples :param dW: Driving noise, optional
swutil/stochastic_processes.py
def fBrown(H,T,N,M,dW = None,cholesky = False): ''' Sample fractional Brownian motion with differentiability index H on interval [0,T] (H=1/2 yields standard Brownian motion) :param H: Differentiability, larger than 0 :param T: Final time :param N: Number of time steps :param M: Number...
def fBrown(H,T,N,M,dW = None,cholesky = False): ''' Sample fractional Brownian motion with differentiability index H on interval [0,T] (H=1/2 yields standard Brownian motion) :param H: Differentiability, larger than 0 :param T: Final time :param N: Number of time steps :param M: Number...
[ "Sample", "fractional", "Brownian", "motion", "with", "differentiability", "index", "H", "on", "interval", "[", "0", "T", "]", "(", "H", "=", "1", "/", "2", "yields", "standard", "Brownian", "motion", ")", ":", "param", "H", ":", "Differentiability", "larg...
soerenwolfers/swutil
python
https://github.com/soerenwolfers/swutil/blob/2d598f2deac8b7e20df95dbc68017e5ab5d6180c/swutil/stochastic_processes.py#L64-L102
[ "def", "fBrown", "(", "H", ",", "T", ",", "N", ",", "M", ",", "dW", "=", "None", ",", "cholesky", "=", "False", ")", ":", "alpha", "=", "0.5", "-", "H", "times", "=", "np", ".", "linspace", "(", "0", ",", "T", ",", "N", ")", "dt", "=", "T...
2d598f2deac8b7e20df95dbc68017e5ab5d6180c
valid
r_bergomi
Return M Euler-Maruyama sample paths with N time steps of (S_t,v_t), where (S_t,v_t) follows the rBergomi model of mathematical finance :rtype: M x N x d array
swutil/stochastic_processes.py
def r_bergomi(H,T,eta,xi,rho,S0,r,N,M,dW=None,dW_orth=None,cholesky = False,return_v=False): ''' Return M Euler-Maruyama sample paths with N time steps of (S_t,v_t), where (S_t,v_t) follows the rBergomi model of mathematical finance :rtype: M x N x d array ''' times = np.linspace(0, T, N) ...
def r_bergomi(H,T,eta,xi,rho,S0,r,N,M,dW=None,dW_orth=None,cholesky = False,return_v=False): ''' Return M Euler-Maruyama sample paths with N time steps of (S_t,v_t), where (S_t,v_t) follows the rBergomi model of mathematical finance :rtype: M x N x d array ''' times = np.linspace(0, T, N) ...
[ "Return", "M", "Euler", "-", "Maruyama", "sample", "paths", "with", "N", "time", "steps", "of", "(", "S_t", "v_t", ")", "where", "(", "S_t", "v_t", ")", "follows", "the", "rBergomi", "model", "of", "mathematical", "finance" ]
soerenwolfers/swutil
python
https://github.com/soerenwolfers/swutil/blob/2d598f2deac8b7e20df95dbc68017e5ab5d6180c/swutil/stochastic_processes.py#L104-L125
[ "def", "r_bergomi", "(", "H", ",", "T", ",", "eta", ",", "xi", ",", "rho", ",", "S0", ",", "r", ",", "N", ",", "M", ",", "dW", "=", "None", ",", "dW_orth", "=", "None", ",", "cholesky", "=", "False", ",", "return_v", "=", "False", ")", ":", ...
2d598f2deac8b7e20df95dbc68017e5ab5d6180c
valid
unique
https://stackoverflow.com/questions/480214/how-do-you-remove-duplicates-from-a-list-in-whilst-preserving-order
swutil/collections.py
def unique(seq): ''' https://stackoverflow.com/questions/480214/how-do-you-remove-duplicates-from-a-list-in-whilst-preserving-order ''' has = [] return [x for x in seq if not (x in has or has.append(x))]
def unique(seq): ''' https://stackoverflow.com/questions/480214/how-do-you-remove-duplicates-from-a-list-in-whilst-preserving-order ''' has = [] return [x for x in seq if not (x in has or has.append(x))]
[ "https", ":", "//", "stackoverflow", ".", "com", "/", "questions", "/", "480214", "/", "how", "-", "do", "-", "you", "-", "remove", "-", "duplicates", "-", "from", "-", "a", "-", "list", "-", "in", "-", "whilst", "-", "preserving", "-", "order" ]
soerenwolfers/swutil
python
https://github.com/soerenwolfers/swutil/blob/2d598f2deac8b7e20df95dbc68017e5ab5d6180c/swutil/collections.py#L5-L10
[ "def", "unique", "(", "seq", ")", ":", "has", "=", "[", "]", "return", "[", "x", "for", "x", "in", "seq", "if", "not", "(", "x", "in", "has", "or", "has", ".", "append", "(", "x", ")", ")", "]" ]
2d598f2deac8b7e20df95dbc68017e5ab5d6180c
valid
ModelMixin.get_default_fields
get all fields of model, execpt id
easyui/mixins/model_mixins.py
def get_default_fields(self): """ get all fields of model, execpt id """ field_names = self._meta.get_all_field_names() if 'id' in field_names: field_names.remove('id') return field_names
def get_default_fields(self): """ get all fields of model, execpt id """ field_names = self._meta.get_all_field_names() if 'id' in field_names: field_names.remove('id') return field_names
[ "get", "all", "fields", "of", "model", "execpt", "id" ]
xu2243051/easyui-menu
python
https://github.com/xu2243051/easyui-menu/blob/4da0b50cf2d3ddb0f1ec7a4da65fd3c4339f8dfb/easyui/mixins/model_mixins.py#L14-L22
[ "def", "get_default_fields", "(", "self", ")", ":", "field_names", "=", "self", ".", "_meta", ".", "get_all_field_names", "(", ")", "if", "'id'", "in", "field_names", ":", "field_names", ".", "remove", "(", "'id'", ")", "return", "field_names" ]
4da0b50cf2d3ddb0f1ec7a4da65fd3c4339f8dfb
valid
ModelMixin.get_field_value
返回显示的值,而不是单纯的数据库中的值 field 是model中的field type value_verbose 为True,返回数据的显示数据,会转换为choice的内容, 如果value_verbose 为False, 返回数据的实际值
easyui/mixins/model_mixins.py
def get_field_value(self, field, value_verbose=True): """ 返回显示的值,而不是单纯的数据库中的值 field 是model中的field type value_verbose 为True,返回数据的显示数据,会转换为choice的内容, 如果value_verbose 为False, 返回数据的实际值 """ if not value_verbose: """ value_verbose == false, retu...
def get_field_value(self, field, value_verbose=True): """ 返回显示的值,而不是单纯的数据库中的值 field 是model中的field type value_verbose 为True,返回数据的显示数据,会转换为choice的内容, 如果value_verbose 为False, 返回数据的实际值 """ if not value_verbose: """ value_verbose == false, retu...
[ "返回显示的值,而不是单纯的数据库中的值", "field", "是model中的field", "type", "value_verbose", "为True,返回数据的显示数据,会转换为choice的内容,", "如果value_verbose", "为False,", "返回数据的实际值" ]
xu2243051/easyui-menu
python
https://github.com/xu2243051/easyui-menu/blob/4da0b50cf2d3ddb0f1ec7a4da65fd3c4339f8dfb/easyui/mixins/model_mixins.py#L24-L48
[ "def", "get_field_value", "(", "self", ",", "field", ",", "value_verbose", "=", "True", ")", ":", "if", "not", "value_verbose", ":", "\"\"\"\n value_verbose == false, return raw value\n \"\"\"", "value", "=", "field", ".", "_get_val_from_obj", "(", ...
4da0b50cf2d3ddb0f1ec7a4da65fd3c4339f8dfb
valid
ModelMixin.get_fields
返回字段名及其对应值的列表 field_verbose 为True,返回定义中的字段的verbose_name, False返回其name value_verbose 为True,返回数据的显示数据,会转换为choice的内容,为False, 返回数据的实际值 fields 指定了要显示的字段 extra_fields 指定了要特殊处理的非field,比如是函数 remove_fields 指定了不显示的字段
easyui/mixins/model_mixins.py
def get_fields(self, field_verbose=True, value_verbose=True, fields=[], extra_fields=[], remove_fields = []): ''' 返回字段名及其对应值的列表 field_verbose 为True,返回定义中的字段的verbose_name, False返回其name value_verbose 为True,返回数据的显示数据,会转换为choice的内容,为False, 返回数据的实际值 fields 指定了要显示的字段 extra_fiel...
def get_fields(self, field_verbose=True, value_verbose=True, fields=[], extra_fields=[], remove_fields = []): ''' 返回字段名及其对应值的列表 field_verbose 为True,返回定义中的字段的verbose_name, False返回其name value_verbose 为True,返回数据的显示数据,会转换为choice的内容,为False, 返回数据的实际值 fields 指定了要显示的字段 extra_fiel...
[ "返回字段名及其对应值的列表", "field_verbose", "为True,返回定义中的字段的verbose_name,", "False返回其name", "value_verbose", "为True,返回数据的显示数据,会转换为choice的内容,为False,", "返回数据的实际值", "fields", "指定了要显示的字段", "extra_fields", "指定了要特殊处理的非field,比如是函数", "remove_fields", "指定了不显示的字段" ]
xu2243051/easyui-menu
python
https://github.com/xu2243051/easyui-menu/blob/4da0b50cf2d3ddb0f1ec7a4da65fd3c4339f8dfb/easyui/mixins/model_mixins.py#L51-L84
[ "def", "get_fields", "(", "self", ",", "field_verbose", "=", "True", ",", "value_verbose", "=", "True", ",", "fields", "=", "[", "]", ",", "extra_fields", "=", "[", "]", ",", "remove_fields", "=", "[", "]", ")", ":", "field_list", "=", "[", "]", "for...
4da0b50cf2d3ddb0f1ec7a4da65fd3c4339f8dfb
valid
get_url
通过menu_id,获取对应的URL eg. /easyui/MenuListView/
easyui/views.py
def get_url(request): """ 通过menu_id,获取对应的URL eg. /easyui/MenuListView/ """ menu_id = request.GET.get('menu_id') m_object = Menu.objects.get(pk=menu_id) namespace = m_object.namespace viewname = m_object.viewname url_string = '%s:%s' %(namespace, viewname) url = reverse(url_strin...
def get_url(request): """ 通过menu_id,获取对应的URL eg. /easyui/MenuListView/ """ menu_id = request.GET.get('menu_id') m_object = Menu.objects.get(pk=menu_id) namespace = m_object.namespace viewname = m_object.viewname url_string = '%s:%s' %(namespace, viewname) url = reverse(url_strin...
[ "通过menu_id,获取对应的URL", "eg", ".", "/", "easyui", "/", "MenuListView", "/" ]
xu2243051/easyui-menu
python
https://github.com/xu2243051/easyui-menu/blob/4da0b50cf2d3ddb0f1ec7a4da65fd3c4339f8dfb/easyui/views.py#L27-L40
[ "def", "get_url", "(", "request", ")", ":", "menu_id", "=", "request", ".", "GET", ".", "get", "(", "'menu_id'", ")", "m_object", "=", "Menu", ".", "objects", ".", "get", "(", "pk", "=", "menu_id", ")", "namespace", "=", "m_object", ".", "namespace", ...
4da0b50cf2d3ddb0f1ec7a4da65fd3c4339f8dfb
valid
AjaxUpdateView.post
Handles POST requests only argument: row_index HTML中第几行的标记,原值返回 app_label model_name pk app_label + model_name + pk 可以获取一个object method object + method 得到要调用的方法 其它参数,html和method中同时定义, 在上面的方法中使用
easyui/views.py
def post(self, request, *args, **kwargs): """ Handles POST requests only argument: row_index HTML中第几行的标记,原值返回 app_label model_name pk app_label + model_name + pk 可以获取一个object method object + method 得到要调用的方法 其它参数,html和met...
def post(self, request, *args, **kwargs): """ Handles POST requests only argument: row_index HTML中第几行的标记,原值返回 app_label model_name pk app_label + model_name + pk 可以获取一个object method object + method 得到要调用的方法 其它参数,html和met...
[ "Handles", "POST", "requests", "only", "argument", ":", "row_index", "HTML中第几行的标记,原值返回", "app_label", "model_name", "pk", "app_label", "+", "model_name", "+", "pk", "可以获取一个object", "method", "object", "+", "method", "得到要调用的方法", "其它参数,html和method中同时定义", "在上面的方法中使用" ]
xu2243051/easyui-menu
python
https://github.com/xu2243051/easyui-menu/blob/4da0b50cf2d3ddb0f1ec7a4da65fd3c4339f8dfb/easyui/views.py#L53-L93
[ "def", "post", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "query_dict", "=", "dict", "(", "self", ".", "request", ".", "POST", ".", "items", "(", ")", ")", "# row_index原值返回,在datagrid对应行显示结果 ", "row_index", "=", "q...
4da0b50cf2d3ddb0f1ec7a4da65fd3c4339f8dfb
valid
MenuListView.get_menu_checked
获取用户或者用户组checked的菜单列表 usermenu_form.html 中定义 usermenu 这两个model的定义类似,比如menus_checked和menus_show groupmenu @return eg. ['1', '8', '9', '10' ] 获取用户或者用户组的check_ids,会给出app_label, model_name, pk eg. /easyui/menulistview/?app_label=easyui&model_name=UserMenu&pk=1
easyui/views.py
def get_menu_checked(self, request): """ 获取用户或者用户组checked的菜单列表 usermenu_form.html 中定义 usermenu 这两个model的定义类似,比如menus_checked和menus_show groupmenu @return eg. ['1', '8', '9', '10' ] 获取用户或者用户组的check_ids,会给出app_label, model_name, pk eg. /easyui/menulistview/?app_la...
def get_menu_checked(self, request): """ 获取用户或者用户组checked的菜单列表 usermenu_form.html 中定义 usermenu 这两个model的定义类似,比如menus_checked和menus_show groupmenu @return eg. ['1', '8', '9', '10' ] 获取用户或者用户组的check_ids,会给出app_label, model_name, pk eg. /easyui/menulistview/?app_la...
[ "获取用户或者用户组checked的菜单列表", "usermenu_form", ".", "html", "中定义", "usermenu", "这两个model的定义类似,比如menus_checked和menus_show", "groupmenu" ]
xu2243051/easyui-menu
python
https://github.com/xu2243051/easyui-menu/blob/4da0b50cf2d3ddb0f1ec7a4da65fd3c4339f8dfb/easyui/views.py#L156-L177
[ "def", "get_menu_checked", "(", "self", ",", "request", ")", ":", "checked_id", "=", "[", "]", "qd", "=", "request", ".", "GET", "query_dict", "=", "dict", "(", "qd", ".", "items", "(", ")", ")", "if", "query_dict", ":", "#object = get_object(**query_dict)...
4da0b50cf2d3ddb0f1ec7a4da65fd3c4339f8dfb
valid
DownloaderBase.fetch
Verify if the file is already downloaded and complete. If they don't exists or if are not complete, use homura download function to fetch files. Return a list with the path of the downloaded file and the size of the remote file.
lc8_download/lc8.py
def fetch(self, url, path, filename): """Verify if the file is already downloaded and complete. If they don't exists or if are not complete, use homura download function to fetch files. Return a list with the path of the downloaded file and the size of the remote file. """ ...
def fetch(self, url, path, filename): """Verify if the file is already downloaded and complete. If they don't exists or if are not complete, use homura download function to fetch files. Return a list with the path of the downloaded file and the size of the remote file. """ ...
[ "Verify", "if", "the", "file", "is", "already", "downloaded", "and", "complete", ".", "If", "they", "don", "t", "exists", "or", "if", "are", "not", "complete", "use", "homura", "download", "function", "to", "fetch", "files", ".", "Return", "a", "list", "...
cenima-ibama/lc8_download
python
https://github.com/cenima-ibama/lc8_download/blob/d366e8b42b143597c71663ccb838bf8375c8d817/lc8_download/lc8.py#L44-L65
[ "def", "fetch", "(", "self", ",", "url", ",", "path", ",", "filename", ")", ":", "logger", ".", "debug", "(", "'initializing download in '", ",", "url", ")", "remote_file_size", "=", "self", ".", "get_remote_file_size", "(", "url", ")", "if", "exists", "("...
d366e8b42b143597c71663ccb838bf8375c8d817
valid
DownloaderBase.validate_bands
Validate bands parameter.
lc8_download/lc8.py
def validate_bands(self, bands): """Validate bands parameter.""" if not isinstance(bands, list): logger.error('Parameter bands must be a "list"') raise TypeError('Parameter bands must be a "list"') valid_bands = list(range(1, 12)) + ['BQA'] for band in bands: ...
def validate_bands(self, bands): """Validate bands parameter.""" if not isinstance(bands, list): logger.error('Parameter bands must be a "list"') raise TypeError('Parameter bands must be a "list"') valid_bands = list(range(1, 12)) + ['BQA'] for band in bands: ...
[ "Validate", "bands", "parameter", "." ]
cenima-ibama/lc8_download
python
https://github.com/cenima-ibama/lc8_download/blob/d366e8b42b143597c71663ccb838bf8375c8d817/lc8_download/lc8.py#L76-L85
[ "def", "validate_bands", "(", "self", ",", "bands", ")", ":", "if", "not", "isinstance", "(", "bands", ",", "list", ")", ":", "logger", ".", "error", "(", "'Parameter bands must be a \"list\"'", ")", "raise", "TypeError", "(", "'Parameter bands must be a \"list\"'...
d366e8b42b143597c71663ccb838bf8375c8d817
valid
GoogleDownloader.validate_sceneInfo
Check scene name and whether remote file exists. Raises WrongSceneNameError if the scene name is wrong.
lc8_download/lc8.py
def validate_sceneInfo(self): """Check scene name and whether remote file exists. Raises WrongSceneNameError if the scene name is wrong. """ if self.sceneInfo.prefix not in self.__satellitesMap: logger.error('Google Downloader: Prefix of %s (%s) is invalid' % ...
def validate_sceneInfo(self): """Check scene name and whether remote file exists. Raises WrongSceneNameError if the scene name is wrong. """ if self.sceneInfo.prefix not in self.__satellitesMap: logger.error('Google Downloader: Prefix of %s (%s) is invalid' % ...
[ "Check", "scene", "name", "and", "whether", "remote", "file", "exists", ".", "Raises", "WrongSceneNameError", "if", "the", "scene", "name", "is", "wrong", "." ]
cenima-ibama/lc8_download
python
https://github.com/cenima-ibama/lc8_download/blob/d366e8b42b143597c71663ccb838bf8375c8d817/lc8_download/lc8.py#L117-L125
[ "def", "validate_sceneInfo", "(", "self", ")", ":", "if", "self", ".", "sceneInfo", ".", "prefix", "not", "in", "self", ".", "__satellitesMap", ":", "logger", ".", "error", "(", "'Google Downloader: Prefix of %s (%s) is invalid'", "%", "(", "self", ".", "sceneIn...
d366e8b42b143597c71663ccb838bf8375c8d817
valid
GoogleDownloader.download
Download remote .tar.bz file.
lc8_download/lc8.py
def download(self, bands, download_dir=None, metadata=False): """Download remote .tar.bz file.""" super(GoogleDownloader, self).validate_bands(bands) pattern = re.compile('^[^\s]+_(.+)\.tiff?', re.I) image_list = [] band_list = ['B%i' % (i,) if isinstance(i, int) else i for i in ...
def download(self, bands, download_dir=None, metadata=False): """Download remote .tar.bz file.""" super(GoogleDownloader, self).validate_bands(bands) pattern = re.compile('^[^\s]+_(.+)\.tiff?', re.I) image_list = [] band_list = ['B%i' % (i,) if isinstance(i, int) else i for i in ...
[ "Download", "remote", ".", "tar", ".", "bz", "file", "." ]
cenima-ibama/lc8_download
python
https://github.com/cenima-ibama/lc8_download/blob/d366e8b42b143597c71663ccb838bf8375c8d817/lc8_download/lc8.py#L131-L165
[ "def", "download", "(", "self", ",", "bands", ",", "download_dir", "=", "None", ",", "metadata", "=", "False", ")", ":", "super", "(", "GoogleDownloader", ",", "self", ")", ".", "validate_bands", "(", "bands", ")", "pattern", "=", "re", ".", "compile", ...
d366e8b42b143597c71663ccb838bf8375c8d817
valid
AWSDownloader.validate_sceneInfo
Check whether sceneInfo is valid to download from AWS Storage.
lc8_download/lc8.py
def validate_sceneInfo(self): """Check whether sceneInfo is valid to download from AWS Storage.""" if self.sceneInfo.prefix not in self.__prefixesValid: raise WrongSceneNameError('AWS: Prefix of %s (%s) is invalid' % (self.sceneInfo.name, self.sceneInfo.prefix))
def validate_sceneInfo(self): """Check whether sceneInfo is valid to download from AWS Storage.""" if self.sceneInfo.prefix not in self.__prefixesValid: raise WrongSceneNameError('AWS: Prefix of %s (%s) is invalid' % (self.sceneInfo.name, self.sceneInfo.prefix))
[ "Check", "whether", "sceneInfo", "is", "valid", "to", "download", "from", "AWS", "Storage", "." ]
cenima-ibama/lc8_download
python
https://github.com/cenima-ibama/lc8_download/blob/d366e8b42b143597c71663ccb838bf8375c8d817/lc8_download/lc8.py#L194-L198
[ "def", "validate_sceneInfo", "(", "self", ")", ":", "if", "self", ".", "sceneInfo", ".", "prefix", "not", "in", "self", ".", "__prefixesValid", ":", "raise", "WrongSceneNameError", "(", "'AWS: Prefix of %s (%s) is invalid'", "%", "(", "self", ".", "sceneInfo", "...
d366e8b42b143597c71663ccb838bf8375c8d817
valid
AWSDownloader.remote_file_exists
Verify whether the file (scene) exists on AWS Storage.
lc8_download/lc8.py
def remote_file_exists(self): """Verify whether the file (scene) exists on AWS Storage.""" url = join(self.base_url, 'index.html') return super(AWSDownloader, self).remote_file_exists(url)
def remote_file_exists(self): """Verify whether the file (scene) exists on AWS Storage.""" url = join(self.base_url, 'index.html') return super(AWSDownloader, self).remote_file_exists(url)
[ "Verify", "whether", "the", "file", "(", "scene", ")", "exists", "on", "AWS", "Storage", "." ]
cenima-ibama/lc8_download
python
https://github.com/cenima-ibama/lc8_download/blob/d366e8b42b143597c71663ccb838bf8375c8d817/lc8_download/lc8.py#L200-L203
[ "def", "remote_file_exists", "(", "self", ")", ":", "url", "=", "join", "(", "self", ".", "base_url", ",", "'index.html'", ")", "return", "super", "(", "AWSDownloader", ",", "self", ")", ".", "remote_file_exists", "(", "url", ")" ]
d366e8b42b143597c71663ccb838bf8375c8d817
valid
AWSDownloader.download
Download each specified band and metadata.
lc8_download/lc8.py
def download(self, bands, download_dir=None, metadata=False): """Download each specified band and metadata.""" super(AWSDownloader, self).validate_bands(bands) if download_dir is None: download_dir = DOWNLOAD_DIR dest_dir = check_create_folder(join(download_dir, self.sceneIn...
def download(self, bands, download_dir=None, metadata=False): """Download each specified band and metadata.""" super(AWSDownloader, self).validate_bands(bands) if download_dir is None: download_dir = DOWNLOAD_DIR dest_dir = check_create_folder(join(download_dir, self.sceneIn...
[ "Download", "each", "specified", "band", "and", "metadata", "." ]
cenima-ibama/lc8_download
python
https://github.com/cenima-ibama/lc8_download/blob/d366e8b42b143597c71663ccb838bf8375c8d817/lc8_download/lc8.py#L205-L227
[ "def", "download", "(", "self", ",", "bands", ",", "download_dir", "=", "None", ",", "metadata", "=", "False", ")", ":", "super", "(", "AWSDownloader", ",", "self", ")", ".", "validate_bands", "(", "bands", ")", "if", "download_dir", "is", "None", ":", ...
d366e8b42b143597c71663ccb838bf8375c8d817
valid
open_archive
Open an archive on a filesystem. This function tries to mimick the behaviour of `fs.open_fs` as closely as possible: it accepts either a FS URL or a filesystem instance, and will close all resources it had to open. Arguments: fs_url (FS or text_type): a FS URL, or a filesystem inst...
fs/archive/opener.py
def open_archive(fs_url, archive): """Open an archive on a filesystem. This function tries to mimick the behaviour of `fs.open_fs` as closely as possible: it accepts either a FS URL or a filesystem instance, and will close all resources it had to open. Arguments: fs_url (FS or text_type): ...
def open_archive(fs_url, archive): """Open an archive on a filesystem. This function tries to mimick the behaviour of `fs.open_fs` as closely as possible: it accepts either a FS URL or a filesystem instance, and will close all resources it had to open. Arguments: fs_url (FS or text_type): ...
[ "Open", "an", "archive", "on", "a", "filesystem", "." ]
althonos/fs.archive
python
https://github.com/althonos/fs.archive/blob/a09bb5da56da6b96aca3e20841fa86dea7c5b79a/fs/archive/opener.py#L18-L89
[ "def", "open_archive", "(", "fs_url", ",", "archive", ")", ":", "it", "=", "pkg_resources", ".", "iter_entry_points", "(", "'fs.archive.open_archive'", ")", "entry_point", "=", "next", "(", "(", "ep", "for", "ep", "in", "it", "if", "archive", ".", "endswith"...
a09bb5da56da6b96aca3e20841fa86dea7c5b79a
valid
iso_name_slugify
Slugify a name in the ISO-9660 way. Example: >>> slugify('épatant') "_patant"
fs/archive/isofs/_utils.py
def iso_name_slugify(name): """Slugify a name in the ISO-9660 way. Example: >>> slugify('épatant') "_patant" """ name = name.encode('ascii', 'replace').replace(b'?', b'_') return name.decode('ascii')
def iso_name_slugify(name): """Slugify a name in the ISO-9660 way. Example: >>> slugify('épatant') "_patant" """ name = name.encode('ascii', 'replace').replace(b'?', b'_') return name.decode('ascii')
[ "Slugify", "a", "name", "in", "the", "ISO", "-", "9660", "way", "." ]
althonos/fs.archive
python
https://github.com/althonos/fs.archive/blob/a09bb5da56da6b96aca3e20841fa86dea7c5b79a/fs/archive/isofs/_utils.py#L11-L19
[ "def", "iso_name_slugify", "(", "name", ")", ":", "name", "=", "name", ".", "encode", "(", "'ascii'", ",", "'replace'", ")", ".", "replace", "(", "b'?'", ",", "b'_'", ")", "return", "name", ".", "decode", "(", "'ascii'", ")" ]
a09bb5da56da6b96aca3e20841fa86dea7c5b79a
valid
iso_name_increment
Increment an ISO name to avoid name collision. Example: >>> iso_name_increment('foo.txt') 'foo1.txt' >>> iso_name_increment('bar10') 'bar11' >>> iso_name_increment('bar99', max_length=5) 'ba100'
fs/archive/isofs/_utils.py
def iso_name_increment(name, is_dir=False, max_length=8): """Increment an ISO name to avoid name collision. Example: >>> iso_name_increment('foo.txt') 'foo1.txt' >>> iso_name_increment('bar10') 'bar11' >>> iso_name_increment('bar99', max_length=5) 'ba100' """...
def iso_name_increment(name, is_dir=False, max_length=8): """Increment an ISO name to avoid name collision. Example: >>> iso_name_increment('foo.txt') 'foo1.txt' >>> iso_name_increment('bar10') 'bar11' >>> iso_name_increment('bar99', max_length=5) 'ba100' """...
[ "Increment", "an", "ISO", "name", "to", "avoid", "name", "collision", "." ]
althonos/fs.archive
python
https://github.com/althonos/fs.archive/blob/a09bb5da56da6b96aca3e20841fa86dea7c5b79a/fs/archive/isofs/_utils.py#L22-L54
[ "def", "iso_name_increment", "(", "name", ",", "is_dir", "=", "False", ",", "max_length", "=", "8", ")", ":", "# Split the extension if needed", "if", "not", "is_dir", "and", "'.'", "in", "name", ":", "name", ",", "ext", "=", "name", ".", "rsplit", "(", ...
a09bb5da56da6b96aca3e20841fa86dea7c5b79a
valid
iso_path_slugify
Slugify a path, maintaining a map with the previously slugified paths. The path table is used to prevent slugified names from collisioning, using the `iso_name_increment` function to deduplicate slugs. Example: >>> path_table = {'/': '/'} >>> iso_path_slugify('/ébc.txt', path_table) ...
fs/archive/isofs/_utils.py
def iso_path_slugify(path, path_table, is_dir=False, strict=True): """Slugify a path, maintaining a map with the previously slugified paths. The path table is used to prevent slugified names from collisioning, using the `iso_name_increment` function to deduplicate slugs. Example: >>> path_tabl...
def iso_path_slugify(path, path_table, is_dir=False, strict=True): """Slugify a path, maintaining a map with the previously slugified paths. The path table is used to prevent slugified names from collisioning, using the `iso_name_increment` function to deduplicate slugs. Example: >>> path_tabl...
[ "Slugify", "a", "path", "maintaining", "a", "map", "with", "the", "previously", "slugified", "paths", "." ]
althonos/fs.archive
python
https://github.com/althonos/fs.archive/blob/a09bb5da56da6b96aca3e20841fa86dea7c5b79a/fs/archive/isofs/_utils.py#L57-L93
[ "def", "iso_path_slugify", "(", "path", ",", "path_table", ",", "is_dir", "=", "False", ",", "strict", "=", "True", ")", ":", "# Split the path to extract the parent and basename", "parent", ",", "base", "=", "split", "(", "path", ")", "# Get the parent in slugified...
a09bb5da56da6b96aca3e20841fa86dea7c5b79a
valid
EasyUIListMixin.get_querydict
这个函数跟 self.method有关 self.method 暂时没用, querydict都是POST的
easyui/mixins/easyui_mixins.py
def get_querydict(self): """ 这个函数跟 self.method有关 self.method 暂时没用, querydict都是POST的 """ if self.method: querydict = getattr(self.request, self.method.upper()) else: querydict = getattr(self.request, 'POST'.upper()) # copy make querydict ...
def get_querydict(self): """ 这个函数跟 self.method有关 self.method 暂时没用, querydict都是POST的 """ if self.method: querydict = getattr(self.request, self.method.upper()) else: querydict = getattr(self.request, 'POST'.upper()) # copy make querydict ...
[ "这个函数跟", "self", ".", "method有关", "self", ".", "method", "暂时没用", "querydict都是POST的" ]
xu2243051/easyui-menu
python
https://github.com/xu2243051/easyui-menu/blob/4da0b50cf2d3ddb0f1ec7a4da65fd3c4339f8dfb/easyui/mixins/easyui_mixins.py#L85-L97
[ "def", "get_querydict", "(", "self", ")", ":", "if", "self", ".", "method", ":", "querydict", "=", "getattr", "(", "self", ".", "request", ",", "self", ".", "method", ".", "upper", "(", ")", ")", "else", ":", "querydict", "=", "getattr", "(", "self",...
4da0b50cf2d3ddb0f1ec7a4da65fd3c4339f8dfb
valid
EasyUIListMixin.get_filter_dict
处理过滤字段 rows 一页显示多少行 page 第几页, 1开始 order desc, asc sort 指定排序的字段 order_by(sort) querydict 中的字段名和格式需要可以直接查询
easyui/mixins/easyui_mixins.py
def get_filter_dict(self): ''' 处理过滤字段 rows 一页显示多少行 page 第几页, 1开始 order desc, asc sort 指定排序的字段 order_by(sort) querydict 中的字段名和格式需要可以直接查询 ''' querydict = self.get_querydict() # post ,在cookie中设置了csrfmiddlewaretoken if qu...
def get_filter_dict(self): ''' 处理过滤字段 rows 一页显示多少行 page 第几页, 1开始 order desc, asc sort 指定排序的字段 order_by(sort) querydict 中的字段名和格式需要可以直接查询 ''' querydict = self.get_querydict() # post ,在cookie中设置了csrfmiddlewaretoken if qu...
[ "处理过滤字段", "rows", "一页显示多少行", "page", "第几页", "1开始", "order", "desc", "asc", "sort", "指定排序的字段", "order_by", "(", "sort", ")", "querydict", "中的字段名和格式需要可以直接查询" ]
xu2243051/easyui-menu
python
https://github.com/xu2243051/easyui-menu/blob/4da0b50cf2d3ddb0f1ec7a4da65fd3c4339f8dfb/easyui/mixins/easyui_mixins.py#L101-L149
[ "def", "get_filter_dict", "(", "self", ")", ":", "querydict", "=", "self", ".", "get_querydict", "(", ")", "# post ,在cookie中设置了csrfmiddlewaretoken", "if", "querydict", ".", "has_key", "(", "'csrfmiddlewaretoken'", ")", ":", "querydict", ".", "pop", "(", "'csrfmidd...
4da0b50cf2d3ddb0f1ec7a4da65fd3c4339f8dfb
valid
EasyUIListMixin.get_slice_start
返回queryset切片的头
easyui/mixins/easyui_mixins.py
def get_slice_start(self): """ 返回queryset切片的头 """ value = None if self.easyui_page: value = (self.easyui_page -1) * self.easyui_rows return value
def get_slice_start(self): """ 返回queryset切片的头 """ value = None if self.easyui_page: value = (self.easyui_page -1) * self.easyui_rows return value
[ "返回queryset切片的头" ]
xu2243051/easyui-menu
python
https://github.com/xu2243051/easyui-menu/blob/4da0b50cf2d3ddb0f1ec7a4da65fd3c4339f8dfb/easyui/mixins/easyui_mixins.py#L151-L158
[ "def", "get_slice_start", "(", "self", ")", ":", "value", "=", "None", "if", "self", ".", "easyui_page", ":", "value", "=", "(", "self", ".", "easyui_page", "-", "1", ")", "*", "self", ".", "easyui_rows", "return", "value" ]
4da0b50cf2d3ddb0f1ec7a4da65fd3c4339f8dfb
valid
EasyUIListMixin.get_slice_end
返回queryset切片的尾巴
easyui/mixins/easyui_mixins.py
def get_slice_end(self): """ 返回queryset切片的尾巴 """ value = None if self.easyui_page: value = self.easyui_page * self.easyui_rows return value
def get_slice_end(self): """ 返回queryset切片的尾巴 """ value = None if self.easyui_page: value = self.easyui_page * self.easyui_rows return value
[ "返回queryset切片的尾巴" ]
xu2243051/easyui-menu
python
https://github.com/xu2243051/easyui-menu/blob/4da0b50cf2d3ddb0f1ec7a4da65fd3c4339f8dfb/easyui/mixins/easyui_mixins.py#L160-L167
[ "def", "get_slice_end", "(", "self", ")", ":", "value", "=", "None", "if", "self", ".", "easyui_page", ":", "value", "=", "self", ".", "easyui_page", "*", "self", ".", "easyui_rows", "return", "value" ]
4da0b50cf2d3ddb0f1ec7a4da65fd3c4339f8dfb
valid
EasyUIListMixin.get_queryset
queryset
easyui/mixins/easyui_mixins.py
def get_queryset(self): """ queryset """ filter_dict = self.get_filter_dict() queryset = super(EasyUIListMixin, self).get_queryset() queryset = queryset.filter(**filter_dict) if self.easyui_order: # 如果指定了排序字段,返回排序的queryset queryset = quer...
def get_queryset(self): """ queryset """ filter_dict = self.get_filter_dict() queryset = super(EasyUIListMixin, self).get_queryset() queryset = queryset.filter(**filter_dict) if self.easyui_order: # 如果指定了排序字段,返回排序的queryset queryset = quer...
[ "queryset" ]
xu2243051/easyui-menu
python
https://github.com/xu2243051/easyui-menu/blob/4da0b50cf2d3ddb0f1ec7a4da65fd3c4339f8dfb/easyui/mixins/easyui_mixins.py#L169-L180
[ "def", "get_queryset", "(", "self", ")", ":", "filter_dict", "=", "self", ".", "get_filter_dict", "(", ")", "queryset", "=", "super", "(", "EasyUIListMixin", ",", "self", ")", ".", "get_queryset", "(", ")", "queryset", "=", "queryset", ".", "filter", "(", ...
4da0b50cf2d3ddb0f1ec7a4da65fd3c4339f8dfb
valid
EasyUIListMixin.get_limit_queryset
返回分页之后的queryset
easyui/mixins/easyui_mixins.py
def get_limit_queryset(self): """ 返回分页之后的queryset """ queryset = self.get_queryset() limit_queryset = queryset.all()[self.get_slice_start() :self.get_slice_end()] #等增加排序 return limit_queryset
def get_limit_queryset(self): """ 返回分页之后的queryset """ queryset = self.get_queryset() limit_queryset = queryset.all()[self.get_slice_start() :self.get_slice_end()] #等增加排序 return limit_queryset
[ "返回分页之后的queryset" ]
xu2243051/easyui-menu
python
https://github.com/xu2243051/easyui-menu/blob/4da0b50cf2d3ddb0f1ec7a4da65fd3c4339f8dfb/easyui/mixins/easyui_mixins.py#L183-L189
[ "def", "get_limit_queryset", "(", "self", ")", ":", "queryset", "=", "self", ".", "get_queryset", "(", ")", "limit_queryset", "=", "queryset", ".", "all", "(", ")", "[", "self", ".", "get_slice_start", "(", ")", ":", "self", ".", "get_slice_end", "(", ")...
4da0b50cf2d3ddb0f1ec7a4da65fd3c4339f8dfb
valid
EasyUIListMixin.get_easyui_context
初始化一个空的context
easyui/mixins/easyui_mixins.py
def get_easyui_context(self, **kwargs): """ 初始化一个空的context """ context = {} queryset = self.get_queryset() limit_queryset = self.get_limit_queryset() data = model_serialize(limit_queryset, self.extra_fields, self.remove_fields) count = queryset.count() ...
def get_easyui_context(self, **kwargs): """ 初始化一个空的context """ context = {} queryset = self.get_queryset() limit_queryset = self.get_limit_queryset() data = model_serialize(limit_queryset, self.extra_fields, self.remove_fields) count = queryset.count() ...
[ "初始化一个空的context" ]
xu2243051/easyui-menu
python
https://github.com/xu2243051/easyui-menu/blob/4da0b50cf2d3ddb0f1ec7a4da65fd3c4339f8dfb/easyui/mixins/easyui_mixins.py#L191-L203
[ "def", "get_easyui_context", "(", "self", ",", "*", "*", "kwargs", ")", ":", "context", "=", "{", "}", "queryset", "=", "self", ".", "get_queryset", "(", ")", "limit_queryset", "=", "self", ".", "get_limit_queryset", "(", ")", "data", "=", "model_serialize...
4da0b50cf2d3ddb0f1ec7a4da65fd3c4339f8dfb
valid
register_views
app_name APP名 view_filename views 所在的文件 urlpatterns url中已经存在的urlpatterns return urlpatterns 只导入View结尾的,是类的视图
easyui/utils.py
def register_views(app_name, view_filename, urlpatterns=None): """ app_name APP名 view_filename views 所在的文件 urlpatterns url中已经存在的urlpatterns return urlpatterns 只导入View结尾的,是类的视图 """ app_module = __import__(app_name) view_module = getattr(app_module, view_filename) v...
def register_views(app_name, view_filename, urlpatterns=None): """ app_name APP名 view_filename views 所在的文件 urlpatterns url中已经存在的urlpatterns return urlpatterns 只导入View结尾的,是类的视图 """ app_module = __import__(app_name) view_module = getattr(app_module, view_filename) v...
[ "app_name", "APP名", "view_filename", "views", "所在的文件", "urlpatterns", "url中已经存在的urlpatterns" ]
xu2243051/easyui-menu
python
https://github.com/xu2243051/easyui-menu/blob/4da0b50cf2d3ddb0f1ec7a4da65fd3c4339f8dfb/easyui/utils.py#L21-L48
[ "def", "register_views", "(", "app_name", ",", "view_filename", ",", "urlpatterns", "=", "None", ")", ":", "app_module", "=", "__import__", "(", "app_name", ")", "view_module", "=", "getattr", "(", "app_module", ",", "view_filename", ")", "views", "=", "dir", ...
4da0b50cf2d3ddb0f1ec7a4da65fd3c4339f8dfb
valid
EasyUIDatagridView.get_template_names
datagrid的默认模板
easyui/mixins/view_mixins.py
def get_template_names(self): """ datagrid的默认模板 """ names = super(EasyUIDatagridView, self).get_template_names() names.append('easyui/datagrid.html') return names
def get_template_names(self): """ datagrid的默认模板 """ names = super(EasyUIDatagridView, self).get_template_names() names.append('easyui/datagrid.html') return names
[ "datagrid的默认模板" ]
xu2243051/easyui-menu
python
https://github.com/xu2243051/easyui-menu/blob/4da0b50cf2d3ddb0f1ec7a4da65fd3c4339f8dfb/easyui/mixins/view_mixins.py#L21-L27
[ "def", "get_template_names", "(", "self", ")", ":", "names", "=", "super", "(", "EasyUIDatagridView", ",", "self", ")", ".", "get_template_names", "(", ")", "names", ".", "append", "(", "'easyui/datagrid.html'", ")", "return", "names" ]
4da0b50cf2d3ddb0f1ec7a4da65fd3c4339f8dfb
valid
EasyUICreateView.get_template_names
datagrid的默认模板
easyui/mixins/view_mixins.py
def get_template_names(self): """ datagrid的默认模板 """ names = super(EasyUICreateView, self).get_template_names() names.append('easyui/form.html') return names
def get_template_names(self): """ datagrid的默认模板 """ names = super(EasyUICreateView, self).get_template_names() names.append('easyui/form.html') return names
[ "datagrid的默认模板" ]
xu2243051/easyui-menu
python
https://github.com/xu2243051/easyui-menu/blob/4da0b50cf2d3ddb0f1ec7a4da65fd3c4339f8dfb/easyui/mixins/view_mixins.py#L35-L41
[ "def", "get_template_names", "(", "self", ")", ":", "names", "=", "super", "(", "EasyUICreateView", ",", "self", ")", ".", "get_template_names", "(", ")", "names", ".", "append", "(", "'easyui/form.html'", ")", "return", "names" ]
4da0b50cf2d3ddb0f1ec7a4da65fd3c4339f8dfb
valid
EasyUIUpdateView.get_template_names
datagrid的默认模板
easyui/mixins/view_mixins.py
def get_template_names(self): """ datagrid的默认模板 """ names = super(EasyUIUpdateView, self).get_template_names() names.append('easyui/form.html') return names
def get_template_names(self): """ datagrid的默认模板 """ names = super(EasyUIUpdateView, self).get_template_names() names.append('easyui/form.html') return names
[ "datagrid的默认模板" ]
xu2243051/easyui-menu
python
https://github.com/xu2243051/easyui-menu/blob/4da0b50cf2d3ddb0f1ec7a4da65fd3c4339f8dfb/easyui/mixins/view_mixins.py#L50-L56
[ "def", "get_template_names", "(", "self", ")", ":", "names", "=", "super", "(", "EasyUIUpdateView", ",", "self", ")", ".", "get_template_names", "(", ")", "names", ".", "append", "(", "'easyui/form.html'", ")", "return", "names" ]
4da0b50cf2d3ddb0f1ec7a4da65fd3c4339f8dfb
valid
EasyUIDeleteView.get_template_names
datagrid的默认模板
easyui/mixins/view_mixins.py
def get_template_names(self): """ datagrid的默认模板 """ names = super(EasyUIDeleteView, self).get_template_names() names.append('easyui/confirm_delete.html') return names
def get_template_names(self): """ datagrid的默认模板 """ names = super(EasyUIDeleteView, self).get_template_names() names.append('easyui/confirm_delete.html') return names
[ "datagrid的默认模板" ]
xu2243051/easyui-menu
python
https://github.com/xu2243051/easyui-menu/blob/4da0b50cf2d3ddb0f1ec7a4da65fd3c4339f8dfb/easyui/mixins/view_mixins.py#L65-L71
[ "def", "get_template_names", "(", "self", ")", ":", "names", "=", "super", "(", "EasyUIDeleteView", ",", "self", ")", ".", "get_template_names", "(", ")", "names", ".", "append", "(", "'easyui/confirm_delete.html'", ")", "return", "names" ]
4da0b50cf2d3ddb0f1ec7a4da65fd3c4339f8dfb
valid
CommandDatagridView.get_template_names
datagrid的默认模板
easyui/mixins/view_mixins.py
def get_template_names(self): """ datagrid的默认模板 """ names = super(CommandDatagridView, self).get_template_names() names.append('easyui/command_datagrid.html') return names
def get_template_names(self): """ datagrid的默认模板 """ names = super(CommandDatagridView, self).get_template_names() names.append('easyui/command_datagrid.html') return names
[ "datagrid的默认模板" ]
xu2243051/easyui-menu
python
https://github.com/xu2243051/easyui-menu/blob/4da0b50cf2d3ddb0f1ec7a4da65fd3c4339f8dfb/easyui/mixins/view_mixins.py#L79-L85
[ "def", "get_template_names", "(", "self", ")", ":", "names", "=", "super", "(", "CommandDatagridView", ",", "self", ")", ".", "get_template_names", "(", ")", "names", ".", "append", "(", "'easyui/command_datagrid.html'", ")", "return", "names" ]
4da0b50cf2d3ddb0f1ec7a4da65fd3c4339f8dfb
valid
LoginRequiredMixin.dispatch
增加了权限控制,当self存在model和permission_required时,才会检查权限
easyui/mixins/permission_mixins.py
def dispatch(self, request, *args, **kwargs): """ 增加了权限控制,当self存在model和permission_required时,才会检查权限 """ if getattr(self, 'model', None) and self.permission_required: app_label = self.model._meta.app_label model_name = self.model.__name__.lower() permiss...
def dispatch(self, request, *args, **kwargs): """ 增加了权限控制,当self存在model和permission_required时,才会检查权限 """ if getattr(self, 'model', None) and self.permission_required: app_label = self.model._meta.app_label model_name = self.model.__name__.lower() permiss...
[ "增加了权限控制,当self存在model和permission_required时,才会检查权限" ]
xu2243051/easyui-menu
python
https://github.com/xu2243051/easyui-menu/blob/4da0b50cf2d3ddb0f1ec7a4da65fd3c4339f8dfb/easyui/mixins/permission_mixins.py#L25-L41
[ "def", "dispatch", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "getattr", "(", "self", ",", "'model'", ",", "None", ")", "and", "self", ".", "permission_required", ":", "app_label", "=", "self", ".", "model...
4da0b50cf2d3ddb0f1ec7a4da65fd3c4339f8dfb
valid
writable_path
Test whether a path can be written to.
fs/archive/_utils.py
def writable_path(path): """Test whether a path can be written to. """ if os.path.exists(path): return os.access(path, os.W_OK) try: with open(path, 'w'): pass except (OSError, IOError): return False else: os.remove(path) return True
def writable_path(path): """Test whether a path can be written to. """ if os.path.exists(path): return os.access(path, os.W_OK) try: with open(path, 'w'): pass except (OSError, IOError): return False else: os.remove(path) return True
[ "Test", "whether", "a", "path", "can", "be", "written", "to", "." ]
althonos/fs.archive
python
https://github.com/althonos/fs.archive/blob/a09bb5da56da6b96aca3e20841fa86dea7c5b79a/fs/archive/_utils.py#L98-L110
[ "def", "writable_path", "(", "path", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "return", "os", ".", "access", "(", "path", ",", "os", ".", "W_OK", ")", "try", ":", "with", "open", "(", "path", ",", "'w'", ")", ":"...
a09bb5da56da6b96aca3e20841fa86dea7c5b79a
valid
writable_stream
Test whether a stream can be written to.
fs/archive/_utils.py
def writable_stream(handle): """Test whether a stream can be written to. """ if isinstance(handle, io.IOBase) and sys.version_info >= (3, 5): return handle.writable() try: handle.write(b'') except (io.UnsupportedOperation, IOError): return False else: return True
def writable_stream(handle): """Test whether a stream can be written to. """ if isinstance(handle, io.IOBase) and sys.version_info >= (3, 5): return handle.writable() try: handle.write(b'') except (io.UnsupportedOperation, IOError): return False else: return True
[ "Test", "whether", "a", "stream", "can", "be", "written", "to", "." ]
althonos/fs.archive
python
https://github.com/althonos/fs.archive/blob/a09bb5da56da6b96aca3e20841fa86dea7c5b79a/fs/archive/_utils.py#L113-L123
[ "def", "writable_stream", "(", "handle", ")", ":", "if", "isinstance", "(", "handle", ",", "io", ".", "IOBase", ")", "and", "sys", ".", "version_info", ">=", "(", "3", ",", "5", ")", ":", "return", "handle", ".", "writable", "(", ")", "try", ":", "...
a09bb5da56da6b96aca3e20841fa86dea7c5b79a
valid
QuadContourGenerator.from_curvilinear
Construct a contour generator from a curvilinear grid. Note ---- This is an alias for the default constructor. Parameters ---------- x : array_like x coordinates of each point in `z`. Must be the same size as `z`. y : array_like y coordi...
contours/quad.py
def from_curvilinear(cls, x, y, z, formatter=numpy_formatter): """Construct a contour generator from a curvilinear grid. Note ---- This is an alias for the default constructor. Parameters ---------- x : array_like x coordinates of each point in `z`. ...
def from_curvilinear(cls, x, y, z, formatter=numpy_formatter): """Construct a contour generator from a curvilinear grid. Note ---- This is an alias for the default constructor. Parameters ---------- x : array_like x coordinates of each point in `z`. ...
[ "Construct", "a", "contour", "generator", "from", "a", "curvilinear", "grid", "." ]
ccarocean/python-contours
python
https://github.com/ccarocean/python-contours/blob/d154a679a2ea6a324c3308c1d087d88d0eb79622/contours/quad.py#L114-L141
[ "def", "from_curvilinear", "(", "cls", ",", "x", ",", "y", ",", "z", ",", "formatter", "=", "numpy_formatter", ")", ":", "return", "cls", "(", "x", ",", "y", ",", "z", ",", "formatter", ")" ]
d154a679a2ea6a324c3308c1d087d88d0eb79622
valid
QuadContourGenerator.from_rectilinear
Construct a contour generator from a rectilinear grid. Parameters ---------- x : array_like x coordinates of each column of `z`. Must be the same length as the number of columns in `z`. (len(x) == z.shape[1]) y : array_like y coordinates of each row...
contours/quad.py
def from_rectilinear(cls, x, y, z, formatter=numpy_formatter): """Construct a contour generator from a rectilinear grid. Parameters ---------- x : array_like x coordinates of each column of `z`. Must be the same length as the number of columns in `z`. (len(x) =...
def from_rectilinear(cls, x, y, z, formatter=numpy_formatter): """Construct a contour generator from a rectilinear grid. Parameters ---------- x : array_like x coordinates of each column of `z`. Must be the same length as the number of columns in `z`. (len(x) =...
[ "Construct", "a", "contour", "generator", "from", "a", "rectilinear", "grid", "." ]
ccarocean/python-contours
python
https://github.com/ccarocean/python-contours/blob/d154a679a2ea6a324c3308c1d087d88d0eb79622/contours/quad.py#L144-L194
[ "def", "from_rectilinear", "(", "cls", ",", "x", ",", "y", ",", "z", ",", "formatter", "=", "numpy_formatter", ")", ":", "x", "=", "np", ".", "asarray", "(", "x", ",", "dtype", "=", "np", ".", "float64", ")", "y", "=", "np", ".", "asarray", "(", ...
d154a679a2ea6a324c3308c1d087d88d0eb79622
valid
QuadContourGenerator.from_uniform
Construct a contour generator from a uniform grid. NOTE ---- The default `origin` and `step` values is equivalent to calling :meth:`matplotlib.axes.Axes.contour` with only the `z` argument. Parameters ---------- z : array_like The 2-dimensional unifo...
contours/quad.py
def from_uniform( cls, z, origin=(0, 0), step=(1, 1), formatter=numpy_formatter): """Construct a contour generator from a uniform grid. NOTE ---- The default `origin` and `step` values is equivalent to calling :meth:`matplotlib.axes.Axes.contour` with only the `z` ar...
def from_uniform( cls, z, origin=(0, 0), step=(1, 1), formatter=numpy_formatter): """Construct a contour generator from a uniform grid. NOTE ---- The default `origin` and `step` values is equivalent to calling :meth:`matplotlib.axes.Axes.contour` with only the `z` ar...
[ "Construct", "a", "contour", "generator", "from", "a", "uniform", "grid", "." ]
ccarocean/python-contours
python
https://github.com/ccarocean/python-contours/blob/d154a679a2ea6a324c3308c1d087d88d0eb79622/contours/quad.py#L197-L247
[ "def", "from_uniform", "(", "cls", ",", "z", ",", "origin", "=", "(", "0", ",", "0", ")", ",", "step", "=", "(", "1", ",", "1", ")", ",", "formatter", "=", "numpy_formatter", ")", ":", "z", "=", "np", ".", "ma", ".", "asarray", "(", "z", ",",...
d154a679a2ea6a324c3308c1d087d88d0eb79622
valid
SphinxSearchPlugin.options
Sphinx config file that can optionally take the following python template string arguments: ``database_name`` ``database_password`` ``database_username`` ``database_host`` ``database_port`` ``sphinx_search_data_dir`` ``searchd_log_dir``
nosedjango/plugins/sphinxsearch_plugin.py
def options(self, parser, env=None): """ Sphinx config file that can optionally take the following python template string arguments: ``database_name`` ``database_password`` ``database_username`` ``database_host`` ``database_port`` ``sphinx_search_...
def options(self, parser, env=None): """ Sphinx config file that can optionally take the following python template string arguments: ``database_name`` ``database_password`` ``database_username`` ``database_host`` ``database_port`` ``sphinx_search_...
[ "Sphinx", "config", "file", "that", "can", "optionally", "take", "the", "following", "python", "template", "string", "arguments", ":" ]
nosedjango/nosedjango
python
https://github.com/nosedjango/nosedjango/blob/cd4d06857c88291769bc38e5c9573f43b7ffcd6a/nosedjango/plugins/sphinxsearch_plugin.py#L31-L51
[ "def", "options", "(", "self", ",", "parser", ",", "env", "=", "None", ")", ":", "if", "env", "is", "None", ":", "env", "=", "os", ".", "environ", "parser", ".", "add_option", "(", "'--sphinx-config-tpl'", ",", "help", "=", "'Path to the Sphinx configurati...
cd4d06857c88291769bc38e5c9573f43b7ffcd6a
valid
SphinxSearchPlugin._wait_for_connection
Wait until we can make a socket connection to sphinx.
nosedjango/plugins/sphinxsearch_plugin.py
def _wait_for_connection(self, port): """ Wait until we can make a socket connection to sphinx. """ connected = False max_tries = 10 num_tries = 0 wait_time = 0.5 while not connected or num_tries >= max_tries: time.sleep(wait_time) ...
def _wait_for_connection(self, port): """ Wait until we can make a socket connection to sphinx. """ connected = False max_tries = 10 num_tries = 0 wait_time = 0.5 while not connected or num_tries >= max_tries: time.sleep(wait_time) ...
[ "Wait", "until", "we", "can", "make", "a", "socket", "connection", "to", "sphinx", "." ]
nosedjango/nosedjango
python
https://github.com/nosedjango/nosedjango/blob/cd4d06857c88291769bc38e5c9573f43b7ffcd6a/nosedjango/plugins/sphinxsearch_plugin.py#L151-L174
[ "def", "_wait_for_connection", "(", "self", ",", "port", ")", ":", "connected", "=", "False", "max_tries", "=", "10", "num_tries", "=", "0", "wait_time", "=", "0.5", "while", "not", "connected", "or", "num_tries", ">=", "max_tries", ":", "time", ".", "slee...
cd4d06857c88291769bc38e5c9573f43b7ffcd6a
valid
Plugin.get_unique_token
Get a unique token for usage in differentiating test runs that need to run in parallel.
nosedjango/plugins/base_plugin.py
def get_unique_token(self): """ Get a unique token for usage in differentiating test runs that need to run in parallel. """ if self._unique_token is None: self._unique_token = self._random_token() return self._unique_token
def get_unique_token(self): """ Get a unique token for usage in differentiating test runs that need to run in parallel. """ if self._unique_token is None: self._unique_token = self._random_token() return self._unique_token
[ "Get", "a", "unique", "token", "for", "usage", "in", "differentiating", "test", "runs", "that", "need", "to", "run", "in", "parallel", "." ]
nosedjango/nosedjango
python
https://github.com/nosedjango/nosedjango/blob/cd4d06857c88291769bc38e5c9573f43b7ffcd6a/nosedjango/plugins/base_plugin.py#L12-L20
[ "def", "get_unique_token", "(", "self", ")", ":", "if", "self", ".", "_unique_token", "is", "None", ":", "self", ".", "_unique_token", "=", "self", ".", "_random_token", "(", ")", "return", "self", ".", "_unique_token" ]
cd4d06857c88291769bc38e5c9573f43b7ffcd6a
valid
Plugin._random_token
Generates a random token, using the url-safe base64 alphabet. The "bits" argument specifies the bits of randomness to use.
nosedjango/plugins/base_plugin.py
def _random_token(self, bits=128): """ Generates a random token, using the url-safe base64 alphabet. The "bits" argument specifies the bits of randomness to use. """ alphabet = string.ascii_letters + string.digits + '-_' # alphabet length is 64, so each letter provides lg...
def _random_token(self, bits=128): """ Generates a random token, using the url-safe base64 alphabet. The "bits" argument specifies the bits of randomness to use. """ alphabet = string.ascii_letters + string.digits + '-_' # alphabet length is 64, so each letter provides lg...
[ "Generates", "a", "random", "token", "using", "the", "url", "-", "safe", "base64", "alphabet", ".", "The", "bits", "argument", "specifies", "the", "bits", "of", "randomness", "to", "use", "." ]
nosedjango/nosedjango
python
https://github.com/nosedjango/nosedjango/blob/cd4d06857c88291769bc38e5c9573f43b7ffcd6a/nosedjango/plugins/base_plugin.py#L22-L30
[ "def", "_random_token", "(", "self", ",", "bits", "=", "128", ")", ":", "alphabet", "=", "string", ".", "ascii_letters", "+", "string", ".", "digits", "+", "'-_'", "# alphabet length is 64, so each letter provides lg(64) = 6 bits", "num_letters", "=", "int", "(", ...
cd4d06857c88291769bc38e5c9573f43b7ffcd6a
valid
Poll.url
Returns the url of the poll. If the poll has not been submitted yet, an empty string is returned instead.
strawpoll/poll.py
def url(self): """Returns the url of the poll. If the poll has not been submitted yet, an empty string is returned instead. """ if self.id is None: return '' return '{}/{}'.format(strawpoll.API._BASE_URL, self.id)
def url(self): """Returns the url of the poll. If the poll has not been submitted yet, an empty string is returned instead. """ if self.id is None: return '' return '{}/{}'.format(strawpoll.API._BASE_URL, self.id)
[ "Returns", "the", "url", "of", "the", "poll", ".", "If", "the", "poll", "has", "not", "been", "submitted", "yet", "an", "empty", "string", "is", "returned", "instead", "." ]
PapyrusThePlant/strawpoll.py
python
https://github.com/PapyrusThePlant/strawpoll.py/blob/bce8a8d89d2d9d44c86431b5993b4da196bdd8eb/strawpoll/poll.py#L68-L74
[ "def", "url", "(", "self", ")", ":", "if", "self", ".", "id", "is", "None", ":", "return", "''", "return", "'{}/{}'", ".", "format", "(", "strawpoll", ".", "API", ".", "_BASE_URL", ",", "self", ".", "id", ")" ]
bce8a8d89d2d9d44c86431b5993b4da196bdd8eb
valid
API.get_poll
Retrieves a poll from strawpoll. :param arg: Either the ID of the poll or its strawpoll url. :param request_policy: Overrides :attr:`API.requests_policy` for that \ request. :type request_policy: Optional[:class:`RequestsPolicy`] :raises HTTPException: Requesting the poll faile...
strawpoll/api.py
def get_poll(self, arg, *, request_policy=None): """Retrieves a poll from strawpoll. :param arg: Either the ID of the poll or its strawpoll url. :param request_policy: Overrides :attr:`API.requests_policy` for that \ request. :type request_policy: Optional[:class:`RequestsPolicy...
def get_poll(self, arg, *, request_policy=None): """Retrieves a poll from strawpoll. :param arg: Either the ID of the poll or its strawpoll url. :param request_policy: Overrides :attr:`API.requests_policy` for that \ request. :type request_policy: Optional[:class:`RequestsPolicy...
[ "Retrieves", "a", "poll", "from", "strawpoll", "." ]
PapyrusThePlant/strawpoll.py
python
https://github.com/PapyrusThePlant/strawpoll.py/blob/bce8a8d89d2d9d44c86431b5993b4da196bdd8eb/strawpoll/api.py#L38-L59
[ "def", "get_poll", "(", "self", ",", "arg", ",", "*", ",", "request_policy", "=", "None", ")", ":", "if", "isinstance", "(", "arg", ",", "str", ")", ":", "# Maybe we received an url to parse", "match", "=", "self", ".", "_url_re", ".", "match", "(", "arg...
bce8a8d89d2d9d44c86431b5993b4da196bdd8eb
valid
API.submit_poll
Submits a poll on strawpoll. :param poll: The poll to submit. :type poll: :class:`Poll` :param request_policy: Overrides :attr:`API.requests_policy` for that \ request. :type request_policy: Optional[:class:`RequestsPolicy`] :raises ExistingPoll: This poll instance has ...
strawpoll/api.py
def submit_poll(self, poll, *, request_policy=None): """Submits a poll on strawpoll. :param poll: The poll to submit. :type poll: :class:`Poll` :param request_policy: Overrides :attr:`API.requests_policy` for that \ request. :type request_policy: Optional[:class:`Request...
def submit_poll(self, poll, *, request_policy=None): """Submits a poll on strawpoll. :param poll: The poll to submit. :type poll: :class:`Poll` :param request_policy: Overrides :attr:`API.requests_policy` for that \ request. :type request_policy: Optional[:class:`Request...
[ "Submits", "a", "poll", "on", "strawpoll", "." ]
PapyrusThePlant/strawpoll.py
python
https://github.com/PapyrusThePlant/strawpoll.py/blob/bce8a8d89d2d9d44c86431b5993b4da196bdd8eb/strawpoll/api.py#L61-L95
[ "def", "submit_poll", "(", "self", ",", "poll", ",", "*", ",", "request_policy", "=", "None", ")", ":", "if", "poll", ".", "id", "is", "not", "None", ":", "raise", "ExistingPoll", "(", ")", "options", "=", "poll", ".", "options", "data", "=", "{", ...
bce8a8d89d2d9d44c86431b5993b4da196bdd8eb
valid
numpy_formatter
`NumPy`_ style contour formatter. Contours are returned as a list of Nx2 arrays containing the x and y vertices of the contour line. For filled contours the direction of vertices matters: * CCW (ACW): The vertices give the exterior of a contour polygon. * CW: The vertices give a hole of a contour...
contours/core.py
def numpy_formatter(_, vertices, codes=None): """`NumPy`_ style contour formatter. Contours are returned as a list of Nx2 arrays containing the x and y vertices of the contour line. For filled contours the direction of vertices matters: * CCW (ACW): The vertices give the exterior of a contour pol...
def numpy_formatter(_, vertices, codes=None): """`NumPy`_ style contour formatter. Contours are returned as a list of Nx2 arrays containing the x and y vertices of the contour line. For filled contours the direction of vertices matters: * CCW (ACW): The vertices give the exterior of a contour pol...
[ "NumPy", "_", "style", "contour", "formatter", "." ]
ccarocean/python-contours
python
https://github.com/ccarocean/python-contours/blob/d154a679a2ea6a324c3308c1d087d88d0eb79622/contours/core.py#L80-L105
[ "def", "numpy_formatter", "(", "_", ",", "vertices", ",", "codes", "=", "None", ")", ":", "if", "codes", "is", "None", ":", "return", "vertices", "numpy_vertices", "=", "[", "]", "for", "vertices_", ",", "codes_", "in", "zip", "(", "vertices", ",", "co...
d154a679a2ea6a324c3308c1d087d88d0eb79622
valid
matlab_formatter
`MATLAB`_ style contour formatter. Contours are returned as a single Nx2, `MATLAB`_ style, contour array. There are two types of rows in this format: * Header: The first element of a header row is the level of the contour (the lower level for filled contours) and the second element is the numb...
contours/core.py
def matlab_formatter(level, vertices, codes=None): """`MATLAB`_ style contour formatter. Contours are returned as a single Nx2, `MATLAB`_ style, contour array. There are two types of rows in this format: * Header: The first element of a header row is the level of the contour (the lower level for...
def matlab_formatter(level, vertices, codes=None): """`MATLAB`_ style contour formatter. Contours are returned as a single Nx2, `MATLAB`_ style, contour array. There are two types of rows in this format: * Header: The first element of a header row is the level of the contour (the lower level for...
[ "MATLAB", "_", "style", "contour", "formatter", "." ]
ccarocean/python-contours
python
https://github.com/ccarocean/python-contours/blob/d154a679a2ea6a324c3308c1d087d88d0eb79622/contours/core.py#L108-L148
[ "def", "matlab_formatter", "(", "level", ",", "vertices", ",", "codes", "=", "None", ")", ":", "vertices", "=", "numpy_formatter", "(", "level", ",", "vertices", ",", "codes", ")", "if", "codes", "is", "not", "None", ":", "level", "=", "level", "[", "0...
d154a679a2ea6a324c3308c1d087d88d0eb79622
valid
shapely_formatter
`Shapely`_ style contour formatter. Contours are returned as a list of :class:`shapely.geometry.LineString`, :class:`shapely.geometry.LinearRing`, and :class:`shapely.geometry.Point` geometry elements. Filled contours return a list of :class:`shapely.geometry.Polygon` elements instead. .. not...
contours/core.py
def shapely_formatter(_, vertices, codes=None): """`Shapely`_ style contour formatter. Contours are returned as a list of :class:`shapely.geometry.LineString`, :class:`shapely.geometry.LinearRing`, and :class:`shapely.geometry.Point` geometry elements. Filled contours return a list of :class:`shap...
def shapely_formatter(_, vertices, codes=None): """`Shapely`_ style contour formatter. Contours are returned as a list of :class:`shapely.geometry.LineString`, :class:`shapely.geometry.LinearRing`, and :class:`shapely.geometry.Point` geometry elements. Filled contours return a list of :class:`shap...
[ "Shapely", "_", "style", "contour", "formatter", "." ]
ccarocean/python-contours
python
https://github.com/ccarocean/python-contours/blob/d154a679a2ea6a324c3308c1d087d88d0eb79622/contours/core.py#L151-L210
[ "def", "shapely_formatter", "(", "_", ",", "vertices", ",", "codes", "=", "None", ")", ":", "elements", "=", "[", "]", "if", "codes", "is", "None", ":", "for", "vertices_", "in", "vertices", ":", "if", "np", ".", "all", "(", "vertices_", "[", "0", ...
d154a679a2ea6a324c3308c1d087d88d0eb79622
valid
ContourMixin.contour
Get contour lines at the given level. Parameters ---------- level : numbers.Number The data level to calculate the contour lines for. Returns ------- : The result of the :attr:`formatter` called on the contour at the given `level`.
contours/core.py
def contour(self, level): """Get contour lines at the given level. Parameters ---------- level : numbers.Number The data level to calculate the contour lines for. Returns ------- : The result of the :attr:`formatter` called on the contour...
def contour(self, level): """Get contour lines at the given level. Parameters ---------- level : numbers.Number The data level to calculate the contour lines for. Returns ------- : The result of the :attr:`formatter` called on the contour...
[ "Get", "contour", "lines", "at", "the", "given", "level", "." ]
ccarocean/python-contours
python
https://github.com/ccarocean/python-contours/blob/d154a679a2ea6a324c3308c1d087d88d0eb79622/contours/core.py#L239-L259
[ "def", "contour", "(", "self", ",", "level", ")", ":", "if", "not", "isinstance", "(", "level", ",", "numbers", ".", "Number", ")", ":", "raise", "TypeError", "(", "(", "\"'_level' must be of type 'numbers.Number' but is \"", "\"'{:s}'\"", ")", ".", "format", ...
d154a679a2ea6a324c3308c1d087d88d0eb79622
valid
ContourMixin.filled_contour
Get contour polygons between the given levels. Parameters ---------- min : numbers.Number or None The minimum data level of the contour polygon. If :obj:`None`, ``numpy.finfo(numpy.float64).min`` will be used. max : numbers.Number or None The maximum...
contours/core.py
def filled_contour(self, min=None, max=None): """Get contour polygons between the given levels. Parameters ---------- min : numbers.Number or None The minimum data level of the contour polygon. If :obj:`None`, ``numpy.finfo(numpy.float64).min`` will be used. ...
def filled_contour(self, min=None, max=None): """Get contour polygons between the given levels. Parameters ---------- min : numbers.Number or None The minimum data level of the contour polygon. If :obj:`None`, ``numpy.finfo(numpy.float64).min`` will be used. ...
[ "Get", "contour", "polygons", "between", "the", "given", "levels", "." ]
ccarocean/python-contours
python
https://github.com/ccarocean/python-contours/blob/d154a679a2ea6a324c3308c1d087d88d0eb79622/contours/core.py#L261-L288
[ "def", "filled_contour", "(", "self", ",", "min", "=", "None", ",", "max", "=", "None", ")", ":", "# pylint: disable=redefined-builtin,redefined-outer-name", "# Get the contour vertices.", "if", "min", "is", "None", ":", "min", "=", "np", ".", "finfo", "(", "np"...
d154a679a2ea6a324c3308c1d087d88d0eb79622