repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
noahbenson/pimms
pimms/calculation.py
calc_tr
def calc_tr(calc_fn, *args, **kwargs): ''' calc_tr(calc_fn, ...) yields a copy of calc_fn in which the afferent and efferent values of the function have been translated. The translation is found from merging the list of 0 or more dictionary arguments given left-to-right followed by the keyword argum...
python
def calc_tr(calc_fn, *args, **kwargs): ''' calc_tr(calc_fn, ...) yields a copy of calc_fn in which the afferent and efferent values of the function have been translated. The translation is found from merging the list of 0 or more dictionary arguments given left-to-right followed by the keyword argum...
[ "def", "calc_tr", "(", "calc_fn", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "is_calc", "(", "calc_fn", ")", ":", "calc_fn", "=", "calc", "(", "calc_fn", ")", "return", "calc_fn", ".", "tr", "(", "*", "args", ",", "*", "*",...
calc_tr(calc_fn, ...) yields a copy of calc_fn in which the afferent and efferent values of the function have been translated. The translation is found from merging the list of 0 or more dictionary arguments given left-to-right followed by the keyword arguments. If the calc_fn that is given is not a @...
[ "calc_tr", "(", "calc_fn", "...", ")", "yields", "a", "copy", "of", "calc_fn", "in", "which", "the", "afferent", "and", "efferent", "values", "of", "the", "function", "have", "been", "translated", ".", "The", "translation", "is", "found", "from", "merging", ...
9051b86d6b858a7a13511b72c48dc21bc903dab2
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/calculation.py#L771-L780
train
A function that returns a copy of the given calc_fn with the given arguments translated.
noahbenson/pimms
pimms/calculation.py
plan_tr
def plan_tr(p, *args, **kwargs): ''' plan_tr(p, ...) yields a copy of plan p in which the afferent and efferent values of its functions have been translated. The translation is found from merging the list of 0 or more dictionary arguments given left-to-right followed by the keyword arguments. If the...
python
def plan_tr(p, *args, **kwargs): ''' plan_tr(p, ...) yields a copy of plan p in which the afferent and efferent values of its functions have been translated. The translation is found from merging the list of 0 or more dictionary arguments given left-to-right followed by the keyword arguments. If the...
[ "def", "plan_tr", "(", "p", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "is_plan", "(", "p", ")", ":", "p", "=", "plan", "(", "p", ")", "return", "p", ".", "tr", "(", "*", "args", ",", "*", "*", "kwargs", ")" ]
plan_tr(p, ...) yields a copy of plan p in which the afferent and efferent values of its functions have been translated. The translation is found from merging the list of 0 or more dictionary arguments given left-to-right followed by the keyword arguments. If the plan that is given is not a plan objec...
[ "plan_tr", "(", "p", "...", ")", "yields", "a", "copy", "of", "plan", "p", "in", "which", "the", "afferent", "and", "efferent", "values", "of", "its", "functions", "have", "been", "translated", ".", "The", "translation", "is", "found", "from", "merging", ...
9051b86d6b858a7a13511b72c48dc21bc903dab2
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/calculation.py#L781-L790
train
Returns a copy of a plan p with the given arguments translated.
noahbenson/pimms
pimms/calculation.py
imap_tr
def imap_tr(imap, *args, **kwargs): ''' imap_tr(m, ...) yields a copy of the immutable map m in which the keywords have been translated according to the given arguments. Arguments may be any number of dictionaries followed by any number of keyword arguments, all of which are merged left-to-right the...
python
def imap_tr(imap, *args, **kwargs): ''' imap_tr(m, ...) yields a copy of the immutable map m in which the keywords have been translated according to the given arguments. Arguments may be any number of dictionaries followed by any number of keyword arguments, all of which are merged left-to-right the...
[ "def", "imap_tr", "(", "imap", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "is_imap", "(", "imap", ")", ":", "raise", "TypeError", "(", "'IMap object required of imap_tr'", ")", "return", "imap", ".", "tr", "(", "*", "args", ",", ...
imap_tr(m, ...) yields a copy of the immutable map m in which the keywords have been translated according to the given arguments. Arguments may be any number of dictionaries followed by any number of keyword arguments, all of which are merged left-to-right then used as the translation.
[ "imap_tr", "(", "m", "...", ")", "yields", "a", "copy", "of", "the", "immutable", "map", "m", "in", "which", "the", "keywords", "have", "been", "translated", "according", "to", "the", "given", "arguments", ".", "Arguments", "may", "be", "any", "number", ...
9051b86d6b858a7a13511b72c48dc21bc903dab2
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/calculation.py#L791-L800
train
Returns a copy of the immutable map m with the given arguments translated.
noahbenson/pimms
pimms/calculation.py
Calc.set_meta
def set_meta(self, meta_data): ''' node.set_meta(meta) yields a calculation node identical to the given node except that its meta_data attribute has been set to the given dictionary meta. If meta is not persistent, it is cast to a persistent dictionary first. ''' if not (...
python
def set_meta(self, meta_data): ''' node.set_meta(meta) yields a calculation node identical to the given node except that its meta_data attribute has been set to the given dictionary meta. If meta is not persistent, it is cast to a persistent dictionary first. ''' if not (...
[ "def", "set_meta", "(", "self", ",", "meta_data", ")", ":", "if", "not", "(", "isinstance", "(", "meta_data", ",", "ps", ".", "PMap", ")", "or", "isinstance", "(", "meta_data", ",", "IMap", ")", ")", ":", "meta_data", "=", "ps", ".", "pmap", "(", "...
node.set_meta(meta) yields a calculation node identical to the given node except that its meta_data attribute has been set to the given dictionary meta. If meta is not persistent, it is cast to a persistent dictionary first.
[ "node", ".", "set_meta", "(", "meta", ")", "yields", "a", "calculation", "node", "identical", "to", "the", "given", "node", "except", "that", "its", "meta_data", "attribute", "has", "been", "set", "to", "the", "given", "dictionary", "meta", ".", "If", "met...
9051b86d6b858a7a13511b72c48dc21bc903dab2
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/calculation.py#L104-L114
train
Sets the meta_data attribute of the current node to the given dictionary meta.
noahbenson/pimms
pimms/calculation.py
Calc.set_defaults
def set_defaults(self, *args, **kwargs): ''' node.set_defaults(a=b...) yields a new calculation node identical to the given node except with the default values matching the given key-value pairs. Arguments are collapsed left-to right with later arguments overwriting earlier arguments. ...
python
def set_defaults(self, *args, **kwargs): ''' node.set_defaults(a=b...) yields a new calculation node identical to the given node except with the default values matching the given key-value pairs. Arguments are collapsed left-to right with later arguments overwriting earlier arguments. ...
[ "def", "set_defaults", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "args", "=", "merge", "(", "self", ".", "defaults", ",", "args", ",", "kwargs", ")", "new_cnode", "=", "copy", ".", "copy", "(", "self", ")", "object", ".", ...
node.set_defaults(a=b...) yields a new calculation node identical to the given node except with the default values matching the given key-value pairs. Arguments are collapsed left-to right with later arguments overwriting earlier arguments.
[ "node", ".", "set_defaults", "(", "a", "=", "b", "...", ")", "yields", "a", "new", "calculation", "node", "identical", "to", "the", "given", "node", "except", "with", "the", "default", "values", "matching", "the", "given", "key", "-", "value", "pairs", "...
9051b86d6b858a7a13511b72c48dc21bc903dab2
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/calculation.py#L115-L124
train
A method that sets the default values of the given key - value pairs for the given node.
noahbenson/pimms
pimms/calculation.py
Calc.discard_defaults
def discard_defaults(self, *args): ''' node.discard_defaults(a, b...) yields a new calculation node identical to the given node except that the default values for the given afferent parameters named by the arguments a, b, etc. have been removed. In the new node that is returned, these pa...
python
def discard_defaults(self, *args): ''' node.discard_defaults(a, b...) yields a new calculation node identical to the given node except that the default values for the given afferent parameters named by the arguments a, b, etc. have been removed. In the new node that is returned, these pa...
[ "def", "discard_defaults", "(", "self", ",", "*", "args", ")", ":", "rms", "=", "set", "(", "arg", "for", "aa", "in", "args", "for", "arg", "in", "(", "[", "aa", "]", "if", "isinstance", "(", "aa", ",", "six", ".", "string_types", ")", "else", "a...
node.discard_defaults(a, b...) yields a new calculation node identical to the given node except that the default values for the given afferent parameters named by the arguments a, b, etc. have been removed. In the new node that is returned, these parameters will be required.
[ "node", ".", "discard_defaults", "(", "a", "b", "...", ")", "yields", "a", "new", "calculation", "node", "identical", "to", "the", "given", "node", "except", "that", "the", "default", "values", "for", "the", "given", "afferent", "parameters", "named", "by", ...
9051b86d6b858a7a13511b72c48dc21bc903dab2
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/calculation.py#L125-L136
train
Returns a new node with the given defaults removed.
noahbenson/pimms
pimms/calculation.py
Calc.remove_defaults
def remove_defaults(self, *args): ''' node.remove_defaults(a, b...) is identical to node.discard_defaults(a, b...) except that it raises a KeyError if any of the given arguments are not already defaults. ''' rms = set(arg for aa in args for arg in ([aa] if isinstance(aa, six.stri...
python
def remove_defaults(self, *args): ''' node.remove_defaults(a, b...) is identical to node.discard_defaults(a, b...) except that it raises a KeyError if any of the given arguments are not already defaults. ''' rms = set(arg for aa in args for arg in ([aa] if isinstance(aa, six.stri...
[ "def", "remove_defaults", "(", "self", ",", "*", "args", ")", ":", "rms", "=", "set", "(", "arg", "for", "aa", "in", "args", "for", "arg", "in", "(", "[", "aa", "]", "if", "isinstance", "(", "aa", ",", "six", ".", "string_types", ")", "else", "aa...
node.remove_defaults(a, b...) is identical to node.discard_defaults(a, b...) except that it raises a KeyError if any of the given arguments are not already defaults.
[ "node", ".", "remove_defaults", "(", "a", "b", "...", ")", "is", "identical", "to", "node", ".", "discard_defaults", "(", "a", "b", "...", ")", "except", "that", "it", "raises", "a", "KeyError", "if", "any", "of", "the", "given", "arguments", "are", "n...
9051b86d6b858a7a13511b72c48dc21bc903dab2
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/calculation.py#L137-L146
train
This method is identical to node. remove_defaults except that it raises a KeyError if any of the given arguments are not already defaults.
noahbenson/pimms
pimms/calculation.py
Calc.tr
def tr(self, *args, **kwargs): ''' calc_fn.tr(...) yields a copy of calc_fn in which the afferent and efferent values of the function have been translated. The translation is found from merging the list of 0 or more dictionary arguments given left-to-right followed by the keyword argumen...
python
def tr(self, *args, **kwargs): ''' calc_fn.tr(...) yields a copy of calc_fn in which the afferent and efferent values of the function have been translated. The translation is found from merging the list of 0 or more dictionary arguments given left-to-right followed by the keyword argumen...
[ "def", "tr", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "d", "=", "merge", "(", "args", ",", "kwargs", ")", "# make a copy", "translation", "=", "copy", ".", "copy", "(", "self", ")", "object", ".", "__setattr__", "(", "trans...
calc_fn.tr(...) yields a copy of calc_fn in which the afferent and efferent values of the function have been translated. The translation is found from merging the list of 0 or more dictionary arguments given left-to-right followed by the keyword arguments.
[ "calc_fn", ".", "tr", "(", "...", ")", "yields", "a", "copy", "of", "calc_fn", "in", "which", "the", "afferent", "and", "efferent", "values", "of", "the", "function", "have", "been", "translated", ".", "The", "translation", "is", "found", "from", "merging"...
9051b86d6b858a7a13511b72c48dc21bc903dab2
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/calculation.py#L147-L176
train
This method returns a copy of calc_fn in which the afferent and efferent values of the function have been translated. The function is called by the function method with the given arguments and keyword arguments. The function is called by the function method with the same arguments.
noahbenson/pimms
pimms/calculation.py
Plan._check
def _check(self, calc_dict, changes=None): ''' cplan._check(calc_dict) should be called only by the calc_dict object itself. The check method makes sure that all of the proactive methods on the calc_dict are run; if the optional keyword argument changes is given, then checks are only run...
python
def _check(self, calc_dict, changes=None): ''' cplan._check(calc_dict) should be called only by the calc_dict object itself. The check method makes sure that all of the proactive methods on the calc_dict are run; if the optional keyword argument changes is given, then checks are only run...
[ "def", "_check", "(", "self", ",", "calc_dict", ",", "changes", "=", "None", ")", ":", "if", "changes", "is", "None", ":", "changes", "=", "self", ".", "afferents", "# run the zero-reqs", "for", "req", "in", "self", ".", "initializers", ":", "calc_dict", ...
cplan._check(calc_dict) should be called only by the calc_dict object itself. The check method makes sure that all of the proactive methods on the calc_dict are run; if the optional keyword argument changes is given, then checks are only run for the list of changes given.
[ "cplan", ".", "_check", "(", "calc_dict", ")", "should", "be", "called", "only", "by", "the", "calc_dict", "object", "itself", ".", "The", "check", "method", "makes", "sure", "that", "all", "of", "the", "proactive", "methods", "on", "the", "calc_dict", "ar...
9051b86d6b858a7a13511b72c48dc21bc903dab2
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/calculation.py#L329-L348
train
This method is called by the cplan. _check method.
noahbenson/pimms
pimms/calculation.py
Plan.set
def set(self, **kwargs): ''' cplan.set(a=b...) yields a new caclulation plan identical to cplan except such that the calculation pieces specified by the arguments have been replaced with the given calculations instead. ''' return Plan(reduce(lambda m,u: m.set(u[0],u[1]), ...
python
def set(self, **kwargs): ''' cplan.set(a=b...) yields a new caclulation plan identical to cplan except such that the calculation pieces specified by the arguments have been replaced with the given calculations instead. ''' return Plan(reduce(lambda m,u: m.set(u[0],u[1]), ...
[ "def", "set", "(", "self", ",", "*", "*", "kwargs", ")", ":", "return", "Plan", "(", "reduce", "(", "lambda", "m", ",", "u", ":", "m", ".", "set", "(", "u", "[", "0", "]", ",", "u", "[", "1", "]", ")", ",", "six", ".", "iteritems", "(", "...
cplan.set(a=b...) yields a new caclulation plan identical to cplan except such that the calculation pieces specified by the arguments have been replaced with the given calculations instead.
[ "cplan", ".", "set", "(", "a", "=", "b", "...", ")", "yields", "a", "new", "caclulation", "plan", "identical", "to", "cplan", "except", "such", "that", "the", "calculation", "pieces", "specified", "by", "the", "arguments", "have", "been", "replaced", "with...
9051b86d6b858a7a13511b72c48dc21bc903dab2
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/calculation.py#L350-L356
train
Returns a new caclulation plan with the given set parameters replaced with the given calculations.
noahbenson/pimms
pimms/calculation.py
Plan.discard
def discard(self, *args): ''' cplan.discard(...) yields a new calculation plan identical to cplan except without any of the calculation steps listed in the arguments. ''' return Plan(reduce(lambda m,k: m.discard(k), args, self.nodes))
python
def discard(self, *args): ''' cplan.discard(...) yields a new calculation plan identical to cplan except without any of the calculation steps listed in the arguments. ''' return Plan(reduce(lambda m,k: m.discard(k), args, self.nodes))
[ "def", "discard", "(", "self", ",", "*", "args", ")", ":", "return", "Plan", "(", "reduce", "(", "lambda", "m", ",", "k", ":", "m", ".", "discard", "(", "k", ")", ",", "args", ",", "self", ".", "nodes", ")", ")" ]
cplan.discard(...) yields a new calculation plan identical to cplan except without any of the calculation steps listed in the arguments.
[ "cplan", ".", "discard", "(", "...", ")", "yields", "a", "new", "calculation", "plan", "identical", "to", "cplan", "except", "without", "any", "of", "the", "calculation", "steps", "listed", "in", "the", "arguments", "." ]
9051b86d6b858a7a13511b72c48dc21bc903dab2
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/calculation.py#L357-L362
train
Returns a new calculation plan with all the elements in the given list discarded.
noahbenson/pimms
pimms/calculation.py
Plan.remove
def remove(self, *args): ''' cplan.remove(...) yields a new calculation plan identical to cplan except without any of the calculation steps listed in the arguments. An exception is raised if any keys are not found in the calc-plan. ''' return Plan(reduce(lambda m,k: m.rem...
python
def remove(self, *args): ''' cplan.remove(...) yields a new calculation plan identical to cplan except without any of the calculation steps listed in the arguments. An exception is raised if any keys are not found in the calc-plan. ''' return Plan(reduce(lambda m,k: m.rem...
[ "def", "remove", "(", "self", ",", "*", "args", ")", ":", "return", "Plan", "(", "reduce", "(", "lambda", "m", ",", "k", ":", "m", ".", "remove", "(", "k", ")", ",", "args", ",", "self", ".", "nodes", ")", ")" ]
cplan.remove(...) yields a new calculation plan identical to cplan except without any of the calculation steps listed in the arguments. An exception is raised if any keys are not found in the calc-plan.
[ "cplan", ".", "remove", "(", "...", ")", "yields", "a", "new", "calculation", "plan", "identical", "to", "cplan", "except", "without", "any", "of", "the", "calculation", "steps", "listed", "in", "the", "arguments", ".", "An", "exception", "is", "raised", "...
9051b86d6b858a7a13511b72c48dc21bc903dab2
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/calculation.py#L363-L369
train
Returns a new calculation plan with all of the given keys removed.
noahbenson/pimms
pimms/calculation.py
Plan.set_defaults
def set_defaults(self, *args, **kwargs): ''' cplan.set_defaults(a=b...) yields a new caclulation plan identical to cplan except such that the calculation default values specified by the arguments have been replaced with the given values instead. E.g., cplan.set_defaults(a=1) would return...
python
def set_defaults(self, *args, **kwargs): ''' cplan.set_defaults(a=b...) yields a new caclulation plan identical to cplan except such that the calculation default values specified by the arguments have been replaced with the given values instead. E.g., cplan.set_defaults(a=1) would return...
[ "def", "set_defaults", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "d", "=", "merge", "(", "args", ",", "kwargs", ")", "# make a copy of this object's nodes with translations...", "nodes", "=", "ps", ".", "pmap", "(", "{", "k", ":", ...
cplan.set_defaults(a=b...) yields a new caclulation plan identical to cplan except such that the calculation default values specified by the arguments have been replaced with the given values instead. E.g., cplan.set_defaults(a=1) would return a new plan with a default value for a=1.
[ "cplan", ".", "set_defaults", "(", "a", "=", "b", "...", ")", "yields", "a", "new", "caclulation", "plan", "identical", "to", "cplan", "except", "such", "that", "the", "calculation", "default", "values", "specified", "by", "the", "arguments", "have", "been",...
9051b86d6b858a7a13511b72c48dc21bc903dab2
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/calculation.py#L370-L381
train
Set the default values of the caclulation plan to the given values.
noahbenson/pimms
pimms/calculation.py
Plan.discard_defaults
def discard_defaults(self, *args): ''' cplan.discard_defaults(a, b...) yields a new caclulation plan identical to cplan except without default values for any of the given parameter names. ''' # make a copy of this object's nodes with translations... nodes = ps.pmap({k:v....
python
def discard_defaults(self, *args): ''' cplan.discard_defaults(a, b...) yields a new caclulation plan identical to cplan except without default values for any of the given parameter names. ''' # make a copy of this object's nodes with translations... nodes = ps.pmap({k:v....
[ "def", "discard_defaults", "(", "self", ",", "*", "args", ")", ":", "# make a copy of this object's nodes with translations...", "nodes", "=", "ps", ".", "pmap", "(", "{", "k", ":", "v", ".", "discard_defaults", "(", "*", "args", ")", "for", "(", "k", ",", ...
cplan.discard_defaults(a, b...) yields a new caclulation plan identical to cplan except without default values for any of the given parameter names.
[ "cplan", ".", "discard_defaults", "(", "a", "b", "...", ")", "yields", "a", "new", "caclulation", "plan", "identical", "to", "cplan", "except", "without", "default", "values", "for", "any", "of", "the", "given", "parameter", "names", "." ]
9051b86d6b858a7a13511b72c48dc21bc903dab2
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/calculation.py#L382-L390
train
Returns a new caclulation plan with no default values for any of the given parameter names.
noahbenson/pimms
pimms/calculation.py
Plan.remove_defaults
def remove_defaults(self, *args): ''' cplan.remove_defaults(a, b...) yields a new caclulation plan identical to cplan except without default values for any of the given parameter names. An exception is raised if any default value given is not found in cplan. ''' for arg ...
python
def remove_defaults(self, *args): ''' cplan.remove_defaults(a, b...) yields a new caclulation plan identical to cplan except without default values for any of the given parameter names. An exception is raised if any default value given is not found in cplan. ''' for arg ...
[ "def", "remove_defaults", "(", "self", ",", "*", "args", ")", ":", "for", "arg", "in", "args", ":", "if", "arg", "not", "in", "self", ".", "defaults", ":", "raise", "KeyError", "(", "'{0}'", ".", "format", "(", "arg", ")", ")", "return", "self", "....
cplan.remove_defaults(a, b...) yields a new caclulation plan identical to cplan except without default values for any of the given parameter names. An exception is raised if any default value given is not found in cplan.
[ "cplan", ".", "remove_defaults", "(", "a", "b", "...", ")", "yields", "a", "new", "caclulation", "plan", "identical", "to", "cplan", "except", "without", "default", "values", "for", "any", "of", "the", "given", "parameter", "names", ".", "An", "exception", ...
9051b86d6b858a7a13511b72c48dc21bc903dab2
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/calculation.py#L391-L400
train
This method is used to remove default values from caclulation plan.
noahbenson/pimms
pimms/calculation.py
Plan.forget
def forget(self, node=None, cache_directory=None): ''' plan.forget() clears the in-memory memoized cache for the plan and returns the cache dict prior to clearing. ''' #plan.forget(node) clears only the cache for the given node (which may be a node name) and # all node...
python
def forget(self, node=None, cache_directory=None): ''' plan.forget() clears the in-memory memoized cache for the plan and returns the cache dict prior to clearing. ''' #plan.forget(node) clears only the cache for the given node (which may be a node name) and # all node...
[ "def", "forget", "(", "self", ",", "node", "=", "None", ",", "cache_directory", "=", "None", ")", ":", "#plan.forget(node) clears only the cache for the given node (which may be a node name) and", "# all nodes that depend on it; plan.forget(None) is equivalent to plan.forget()", "#p...
plan.forget() clears the in-memory memoized cache for the plan and returns the cache dict prior to clearing.
[ "plan", ".", "forget", "()", "clears", "the", "in", "-", "memory", "memoized", "cache", "for", "the", "plan", "and", "returns", "the", "cache", "dict", "prior", "to", "clearing", "." ]
9051b86d6b858a7a13511b72c48dc21bc903dab2
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/calculation.py#L413-L425
train
Forget the cache for a given node and delete all directories that depend on it.
noahbenson/pimms
pimms/calculation.py
IMap._cache
def _cache(cpath, arg): ''' IMap._cache(cpath, arg) is an internally-called method that saves the dict of arguments to cache files in the given cpath directory. ''' if not os.path.isdir(cpath): os.makedirs(cpath) for (k,v) in six.iteritems(arg): save(os.path...
python
def _cache(cpath, arg): ''' IMap._cache(cpath, arg) is an internally-called method that saves the dict of arguments to cache files in the given cpath directory. ''' if not os.path.isdir(cpath): os.makedirs(cpath) for (k,v) in six.iteritems(arg): save(os.path...
[ "def", "_cache", "(", "cpath", ",", "arg", ")", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "cpath", ")", ":", "os", ".", "makedirs", "(", "cpath", ")", "for", "(", "k", ",", "v", ")", "in", "six", ".", "iteritems", "(", "arg", ")...
IMap._cache(cpath, arg) is an internally-called method that saves the dict of arguments to cache files in the given cpath directory.
[ "IMap", ".", "_cache", "(", "cpath", "arg", ")", "is", "an", "internally", "-", "called", "method", "that", "saves", "the", "dict", "of", "arguments", "to", "cache", "files", "in", "the", "given", "cpath", "directory", "." ]
9051b86d6b858a7a13511b72c48dc21bc903dab2
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/calculation.py#L495-L503
train
IMap. _cache method saves the dict of arguments to cache files in the given cpath directory.
noahbenson/pimms
pimms/calculation.py
IMap._uncache
def _uncache(self, cpath, node, ureg): ''' calc._uncache(cpath, uret) is an internally called function that handles loading of cached data from disk given the afferent parameters. ''' # load the results, one at a time; all errors can just be allowed to raise upward since ...
python
def _uncache(self, cpath, node, ureg): ''' calc._uncache(cpath, uret) is an internally called function that handles loading of cached data from disk given the afferent parameters. ''' # load the results, one at a time; all errors can just be allowed to raise upward since ...
[ "def", "_uncache", "(", "self", ",", "cpath", ",", "node", ",", "ureg", ")", ":", "# load the results, one at a time; all errors can just be allowed to raise upward since", "# this is always called from in a try block (in __call__)", "result", "=", "{", "}", "for", "eff", "in...
calc._uncache(cpath, uret) is an internally called function that handles loading of cached data from disk given the afferent parameters.
[ "calc", ".", "_uncache", "(", "cpath", "uret", ")", "is", "an", "internally", "called", "function", "that", "handles", "loading", "of", "cached", "data", "from", "disk", "given", "the", "afferent", "parameters", "." ]
9051b86d6b858a7a13511b72c48dc21bc903dab2
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/calculation.py#L504-L514
train
This is a private method that handles loading of cached data from disk given the afferent parameters. It returns a dictionary that associates the result with the cached version of the data.
noahbenson/pimms
pimms/calculation.py
IMap._run_node
def _run_node(self, node): ''' calc_dict._run_node(node) calculates the results of the given calculation node in the calc_dict's calculation plan and caches the results in the calc_dict. This should only be called by calc_dict itself internally. ''' #print IMap.indent, ('...
python
def _run_node(self, node): ''' calc_dict._run_node(node) calculates the results of the given calculation node in the calc_dict's calculation plan and caches the results in the calc_dict. This should only be called by calc_dict itself internally. ''' #print IMap.indent, ('...
[ "def", "_run_node", "(", "self", ",", "node", ")", ":", "#print IMap.indent, ('Node: %s' % node.name) #dbg", "#IMap.indent = ' ' + IMap.indent #dbg", "#", "# We need to pause here and handle caching, if needed.", "res", "=", "None", "if", "(", "'memoize'", "in", "self", ".",...
calc_dict._run_node(node) calculates the results of the given calculation node in the calc_dict's calculation plan and caches the results in the calc_dict. This should only be called by calc_dict itself internally.
[ "calc_dict", ".", "_run_node", "(", "node", ")", "calculates", "the", "results", "of", "the", "given", "calculation", "node", "in", "the", "calc_dict", "s", "calculation", "plan", "and", "caches", "the", "results", "in", "the", "calc_dict", ".", "This", "sho...
9051b86d6b858a7a13511b72c48dc21bc903dab2
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/calculation.py#L516-L573
train
This method is called by calc_dict. _run_node to calculate the results of the given calculation node in the calc_dict and caches the results in the calc_dict.
noahbenson/pimms
pimms/calculation.py
IMap.set
def set(self, *args, **kwargs): ''' d.set(...) yields a copy of the IMap object d; the ... may be replaced with either nothing (in which case d is returned) or a list of 0 or more dictionaries followed by a lsit of zero or more keyword arguments. These dictionaries and keywords arguments...
python
def set(self, *args, **kwargs): ''' d.set(...) yields a copy of the IMap object d; the ... may be replaced with either nothing (in which case d is returned) or a list of 0 or more dictionaries followed by a lsit of zero or more keyword arguments. These dictionaries and keywords arguments...
[ "def", "set", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "args", "=", "merge", "(", "args", ",", "kwargs", ")", "if", "len", "(", "args", ")", "==", "0", ":", "return", "self", "affs", "=", "self", ".", "afferents", "pln"...
d.set(...) yields a copy of the IMap object d; the ... may be replaced with either nothing (in which case d is returned) or a list of 0 or more dictionaries followed by a lsit of zero or more keyword arguments. These dictionaries and keywords arguments are merged left-to-right; the result may co...
[ "d", ".", "set", "(", "...", ")", "yields", "a", "copy", "of", "the", "IMap", "object", "d", ";", "the", "...", "may", "be", "replaced", "with", "either", "nothing", "(", "in", "which", "case", "d", "is", "returned", ")", "or", "a", "list", "of", ...
9051b86d6b858a7a13511b72c48dc21bc903dab2
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/calculation.py#L577-L600
train
Sets the values of the keys in the current object to the values of the given keys.
noahbenson/pimms
pimms/calculation.py
IMap.tr
def tr(self, *args, **kwargs): ''' imap.tr(...) yields a copy of the immutable map imap in which both the plan and the keys of the new map have been translated according to the translation given in the arguments list. The translation is found from merging the list of 0 or more dictionary...
python
def tr(self, *args, **kwargs): ''' imap.tr(...) yields a copy of the immutable map imap in which both the plan and the keys of the new map have been translated according to the translation given in the arguments list. The translation is found from merging the list of 0 or more dictionary...
[ "def", "tr", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "d", "=", "merge_args", "(", "args", ",", "kwargs", ")", "# make a copy of the plan first:", "new_plan", "=", "self", ".", "plan", ".", "tr", "(", "d", ")", "# now use that ...
imap.tr(...) yields a copy of the immutable map imap in which both the plan and the keys of the new map have been translated according to the translation given in the arguments list. The translation is found from merging the list of 0 or more dictionary arguments given left-to-right followed by ...
[ "imap", ".", "tr", "(", "...", ")", "yields", "a", "copy", "of", "the", "immutable", "map", "imap", "in", "which", "both", "the", "plan", "and", "the", "keys", "of", "the", "new", "map", "have", "been", "translated", "according", "to", "the", "translat...
9051b86d6b858a7a13511b72c48dc21bc903dab2
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/calculation.py#L601-L612
train
Returns a copy of the immutable map plan with the keys of translated according to the given arguments.
bradmontgomery/django-blargg
blargg/models.py
generate_entry_tags
def generate_entry_tags(sender, instance, created, raw, using, **kwargs): """Generate the M2M ``Tag``s for an ``Entry`` right after it has been saved.""" Tag.objects.create_tags(instance)
python
def generate_entry_tags(sender, instance, created, raw, using, **kwargs): """Generate the M2M ``Tag``s for an ``Entry`` right after it has been saved.""" Tag.objects.create_tags(instance)
[ "def", "generate_entry_tags", "(", "sender", ",", "instance", ",", "created", ",", "raw", ",", "using", ",", "*", "*", "kwargs", ")", ":", "Tag", ".", "objects", ".", "create_tags", "(", "instance", ")" ]
Generate the M2M ``Tag``s for an ``Entry`` right after it has been saved.
[ "Generate", "the", "M2M", "Tag", "s", "for", "an", "Entry", "right", "after", "it", "has", "been", "saved", "." ]
5d683e04723889a0d1c6d6cf1a67a3d431a2e617
https://github.com/bradmontgomery/django-blargg/blob/5d683e04723889a0d1c6d6cf1a67a3d431a2e617/blargg/models.py#L247-L250
train
Generate the M2M Tag s for an Entry right after it has been saved.
bradmontgomery/django-blargg
blargg/models.py
entry_stats
def entry_stats(entries, top_n=10): """Calculates stats for the given ``QuerySet`` of ``Entry``s.""" wc = Counter() # A Word counter for content in entries.values_list("rendered_content", flat=True): # Do a little cleanup content = strip_tags(content) # remove all html tags conten...
python
def entry_stats(entries, top_n=10): """Calculates stats for the given ``QuerySet`` of ``Entry``s.""" wc = Counter() # A Word counter for content in entries.values_list("rendered_content", flat=True): # Do a little cleanup content = strip_tags(content) # remove all html tags conten...
[ "def", "entry_stats", "(", "entries", ",", "top_n", "=", "10", ")", ":", "wc", "=", "Counter", "(", ")", "# A Word counter", "for", "content", "in", "entries", ".", "values_list", "(", "\"rendered_content\"", ",", "flat", "=", "True", ")", ":", "# Do a lit...
Calculates stats for the given ``QuerySet`` of ``Entry``s.
[ "Calculates", "stats", "for", "the", "given", "QuerySet", "of", "Entry", "s", "." ]
5d683e04723889a0d1c6d6cf1a67a3d431a2e617
https://github.com/bradmontgomery/django-blargg/blob/5d683e04723889a0d1c6d6cf1a67a3d431a2e617/blargg/models.py#L258-L274
train
Calculates stats for the given QuerySet of Entry s.
bradmontgomery/django-blargg
blargg/models.py
TagManager.create_tags
def create_tags(self, entry): """Inspects an ``Entry`` instance, and builds associates ``Tag`` objects based on the values in the ``Entry``'s ``tag_string``.""" tag_list = [t.lower().strip() for t in entry.tag_string.split(',')] for t in tag_list: tag, created = self.get_or_c...
python
def create_tags(self, entry): """Inspects an ``Entry`` instance, and builds associates ``Tag`` objects based on the values in the ``Entry``'s ``tag_string``.""" tag_list = [t.lower().strip() for t in entry.tag_string.split(',')] for t in tag_list: tag, created = self.get_or_c...
[ "def", "create_tags", "(", "self", ",", "entry", ")", ":", "tag_list", "=", "[", "t", ".", "lower", "(", ")", ".", "strip", "(", ")", "for", "t", "in", "entry", ".", "tag_string", ".", "split", "(", "','", ")", "]", "for", "t", "in", "tag_list", ...
Inspects an ``Entry`` instance, and builds associates ``Tag`` objects based on the values in the ``Entry``'s ``tag_string``.
[ "Inspects", "an", "Entry", "instance", "and", "builds", "associates", "Tag", "objects", "based", "on", "the", "values", "in", "the", "Entry", "s", "tag_string", "." ]
5d683e04723889a0d1c6d6cf1a67a3d431a2e617
https://github.com/bradmontgomery/django-blargg/blob/5d683e04723889a0d1c6d6cf1a67a3d431a2e617/blargg/models.py#L33-L39
train
Inspects an Entry instance and builds associates Tag objects based on the values in the entry s tag_string.
bradmontgomery/django-blargg
blargg/models.py
Entry._create_date_slug
def _create_date_slug(self): """Prefixes the slug with the ``published_on`` date.""" if not self.pk: # haven't saved this yet, so use today's date d = utc_now() elif self.published and self.published_on: # use the actual published on date d = self....
python
def _create_date_slug(self): """Prefixes the slug with the ``published_on`` date.""" if not self.pk: # haven't saved this yet, so use today's date d = utc_now() elif self.published and self.published_on: # use the actual published on date d = self....
[ "def", "_create_date_slug", "(", "self", ")", ":", "if", "not", "self", ".", "pk", ":", "# haven't saved this yet, so use today's date", "d", "=", "utc_now", "(", ")", "elif", "self", ".", "published", "and", "self", ".", "published_on", ":", "# use the actual p...
Prefixes the slug with the ``published_on`` date.
[ "Prefixes", "the", "slug", "with", "the", "published_on", "date", "." ]
5d683e04723889a0d1c6d6cf1a67a3d431a2e617
https://github.com/bradmontgomery/django-blargg/blob/5d683e04723889a0d1c6d6cf1a67a3d431a2e617/blargg/models.py#L126-L137
train
Create the date_slug attribute.
bradmontgomery/django-blargg
blargg/models.py
Entry._render_content
def _render_content(self): """Renders the content according to the ``content_format``.""" if self.content_format == "rst" and docutils_publish is not None: doc_parts = docutils_publish( source=self.raw_content, writer_name="html4css1" ) ...
python
def _render_content(self): """Renders the content according to the ``content_format``.""" if self.content_format == "rst" and docutils_publish is not None: doc_parts = docutils_publish( source=self.raw_content, writer_name="html4css1" ) ...
[ "def", "_render_content", "(", "self", ")", ":", "if", "self", ".", "content_format", "==", "\"rst\"", "and", "docutils_publish", "is", "not", "None", ":", "doc_parts", "=", "docutils_publish", "(", "source", "=", "self", ".", "raw_content", ",", "writer_name"...
Renders the content according to the ``content_format``.
[ "Renders", "the", "content", "according", "to", "the", "content_format", "." ]
5d683e04723889a0d1c6d6cf1a67a3d431a2e617
https://github.com/bradmontgomery/django-blargg/blob/5d683e04723889a0d1c6d6cf1a67a3d431a2e617/blargg/models.py#L139-L154
train
Renders the content according to the content_format.
bradmontgomery/django-blargg
blargg/models.py
Entry.save
def save(self, *args, **kwargs): """Auto-generate a slug from the name.""" self._create_slug() self._create_date_slug() self._render_content() # Call ``_set_published`` the *first* time this Entry is published. # NOTE: if this is unpublished, and then republished, this m...
python
def save(self, *args, **kwargs): """Auto-generate a slug from the name.""" self._create_slug() self._create_date_slug() self._render_content() # Call ``_set_published`` the *first* time this Entry is published. # NOTE: if this is unpublished, and then republished, this m...
[ "def", "save", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_create_slug", "(", ")", "self", ".", "_create_date_slug", "(", ")", "self", ".", "_render_content", "(", ")", "# Call ``_set_published`` the *first* time this Entry...
Auto-generate a slug from the name.
[ "Auto", "-", "generate", "a", "slug", "from", "the", "name", "." ]
5d683e04723889a0d1c6d6cf1a67a3d431a2e617
https://github.com/bradmontgomery/django-blargg/blob/5d683e04723889a0d1c6d6cf1a67a3d431a2e617/blargg/models.py#L163-L181
train
Auto - generate a slug from the name.
bradmontgomery/django-blargg
blargg/models.py
Entry.get_absolute_url_with_date
def get_absolute_url_with_date(self): """URL based on the entry's date & slug.""" pub_date = self.published_on if pub_date and settings.USE_TZ: # If TZ is enabled, convert all of these dates from UTC to whatever # the project's timezone is set as. Ideally, we'd pull this...
python
def get_absolute_url_with_date(self): """URL based on the entry's date & slug.""" pub_date = self.published_on if pub_date and settings.USE_TZ: # If TZ is enabled, convert all of these dates from UTC to whatever # the project's timezone is set as. Ideally, we'd pull this...
[ "def", "get_absolute_url_with_date", "(", "self", ")", ":", "pub_date", "=", "self", ".", "published_on", "if", "pub_date", "and", "settings", ".", "USE_TZ", ":", "# If TZ is enabled, convert all of these dates from UTC to whatever", "# the project's timezone is set as. Ideally...
URL based on the entry's date & slug.
[ "URL", "based", "on", "the", "entry", "s", "date", "&", "slug", "." ]
5d683e04723889a0d1c6d6cf1a67a3d431a2e617
https://github.com/bradmontgomery/django-blargg/blob/5d683e04723889a0d1c6d6cf1a67a3d431a2e617/blargg/models.py#L187-L207
train
Returns the absolute URL based on the entry s date & slug.
bradmontgomery/django-blargg
blargg/models.py
Entry.tag_list
def tag_list(self): """Return a plain python list containing all of this Entry's tags.""" tags = [tag.strip() for tag in self.tag_string.split(",")] return sorted(filter(None, tags))
python
def tag_list(self): """Return a plain python list containing all of this Entry's tags.""" tags = [tag.strip() for tag in self.tag_string.split(",")] return sorted(filter(None, tags))
[ "def", "tag_list", "(", "self", ")", ":", "tags", "=", "[", "tag", ".", "strip", "(", ")", "for", "tag", "in", "self", ".", "tag_string", ".", "split", "(", "\",\"", ")", "]", "return", "sorted", "(", "filter", "(", "None", ",", "tags", ")", ")" ...
Return a plain python list containing all of this Entry's tags.
[ "Return", "a", "plain", "python", "list", "containing", "all", "of", "this", "Entry", "s", "tags", "." ]
5d683e04723889a0d1c6d6cf1a67a3d431a2e617
https://github.com/bradmontgomery/django-blargg/blob/5d683e04723889a0d1c6d6cf1a67a3d431a2e617/blargg/models.py#L220-L223
train
Return a plain python list containing all of this Entry s tags.
bradmontgomery/django-blargg
blargg/models.py
Entry.crossposted_content
def crossposted_content(self): """Content to be cross-posted on other sites. This method adds an additional line of content with a link back to the original site as well as the `#end` tag. This signals the end blog content according to: https://support.google.com/blogger/answer/41452?hl=...
python
def crossposted_content(self): """Content to be cross-posted on other sites. This method adds an additional line of content with a link back to the original site as well as the `#end` tag. This signals the end blog content according to: https://support.google.com/blogger/answer/41452?hl=...
[ "def", "crossposted_content", "(", "self", ")", ":", "url", "=", "\"http://{0}{1}\"", ".", "format", "(", "self", ".", "site", ".", "domain", ",", "self", ".", "get_absolute_url", "(", ")", ")", "origin", "=", "(", "'<p><em>This entry was originally published at...
Content to be cross-posted on other sites. This method adds an additional line of content with a link back to the original site as well as the `#end` tag. This signals the end blog content according to: https://support.google.com/blogger/answer/41452?hl=en
[ "Content", "to", "be", "cross", "-", "posted", "on", "other", "sites", ".", "This", "method", "adds", "an", "additional", "line", "of", "content", "with", "a", "link", "back", "to", "the", "original", "site", "as", "well", "as", "the", "#end", "tag", "...
5d683e04723889a0d1c6d6cf1a67a3d431a2e617
https://github.com/bradmontgomery/django-blargg/blob/5d683e04723889a0d1c6d6cf1a67a3d431a2e617/blargg/models.py#L231-L243
train
Content to be cross - posted on other sites.
DeV1doR/aioethereum
aioethereum/management/personal.py
PersonalMixin.personal_unlockAccount
def personal_unlockAccount(self, address, passphrase=None, duration=None): """https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_unlockaccount :param address: Account address :type address: str :param passphrase: Passphrase of account (optional) :type passphr...
python
def personal_unlockAccount(self, address, passphrase=None, duration=None): """https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_unlockaccount :param address: Account address :type address: str :param passphrase: Passphrase of account (optional) :type passphr...
[ "def", "personal_unlockAccount", "(", "self", ",", "address", ",", "passphrase", "=", "None", ",", "duration", "=", "None", ")", ":", "return", "(", "yield", "from", "self", ".", "rpc_call", "(", "'personal_unlockAccount'", ",", "[", "address", ",", "passphr...
https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_unlockaccount :param address: Account address :type address: str :param passphrase: Passphrase of account (optional) :type passphrase: str :param duration: Duration to be unlocked (optional) :type du...
[ "https", ":", "//", "github", ".", "com", "/", "ethereum", "/", "go", "-", "ethereum", "/", "wiki", "/", "Management", "-", "APIs#personal_unlockaccount" ]
85eb46550d862b3ccc309914ea871ca1c7b42157
https://github.com/DeV1doR/aioethereum/blob/85eb46550d862b3ccc309914ea871ca1c7b42157/aioethereum/management/personal.py#L57-L72
train
Unlocks the personal account with the given address.
DeV1doR/aioethereum
aioethereum/management/personal.py
PersonalMixin.personal_sign
def personal_sign(self, message, account, password=None): """https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_sign :param message: Message for sign :type message: str :param account: Account address :type account: str :param password: Password of a...
python
def personal_sign(self, message, account, password=None): """https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_sign :param message: Message for sign :type message: str :param account: Account address :type account: str :param password: Password of a...
[ "def", "personal_sign", "(", "self", ",", "message", ",", "account", ",", "password", "=", "None", ")", ":", "return", "(", "yield", "from", "self", ".", "rpc_call", "(", "'personal_sign'", ",", "[", "message", ",", "account", ",", "password", "]", ")", ...
https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_sign :param message: Message for sign :type message: str :param account: Account address :type account: str :param password: Password of account (optional) :type password: str :return: signa...
[ "https", ":", "//", "github", ".", "com", "/", "ethereum", "/", "go", "-", "ethereum", "/", "wiki", "/", "Management", "-", "APIs#personal_sign" ]
85eb46550d862b3ccc309914ea871ca1c7b42157
https://github.com/DeV1doR/aioethereum/blob/85eb46550d862b3ccc309914ea871ca1c7b42157/aioethereum/management/personal.py#L126-L142
train
Signs a message for the specified account.
striglia/stockfighter
stockfighter/stockfighter.py
Stockfighter.heartbeat
def heartbeat(self): """Check The API Is Up. https://starfighter.readme.io/docs/heartbeat """ url = urljoin(self.base_url, 'heartbeat') return self.session.get(url).json()['ok']
python
def heartbeat(self): """Check The API Is Up. https://starfighter.readme.io/docs/heartbeat """ url = urljoin(self.base_url, 'heartbeat') return self.session.get(url).json()['ok']
[ "def", "heartbeat", "(", "self", ")", ":", "url", "=", "urljoin", "(", "self", ".", "base_url", ",", "'heartbeat'", ")", "return", "self", ".", "session", ".", "get", "(", "url", ")", ".", "json", "(", ")", "[", "'ok'", "]" ]
Check The API Is Up. https://starfighter.readme.io/docs/heartbeat
[ "Check", "The", "API", "Is", "Up", "." ]
df908f5919d6f861601cd00c906a049d04253d47
https://github.com/striglia/stockfighter/blob/df908f5919d6f861601cd00c906a049d04253d47/stockfighter/stockfighter.py#L24-L30
train
Check The API Is Up.
striglia/stockfighter
stockfighter/stockfighter.py
Stockfighter.venue_healthcheck
def venue_healthcheck(self): """Check A Venue Is Up. https://starfighter.readme.io/docs/venue-healthcheck """ url = urljoin(self.base_url, 'venues/TESTEX/heartbeat') return self.session.get(url).json()['ok']
python
def venue_healthcheck(self): """Check A Venue Is Up. https://starfighter.readme.io/docs/venue-healthcheck """ url = urljoin(self.base_url, 'venues/TESTEX/heartbeat') return self.session.get(url).json()['ok']
[ "def", "venue_healthcheck", "(", "self", ")", ":", "url", "=", "urljoin", "(", "self", ".", "base_url", ",", "'venues/TESTEX/heartbeat'", ")", "return", "self", ".", "session", ".", "get", "(", "url", ")", ".", "json", "(", ")", "[", "'ok'", "]" ]
Check A Venue Is Up. https://starfighter.readme.io/docs/venue-healthcheck
[ "Check", "A", "Venue", "Is", "Up", "." ]
df908f5919d6f861601cd00c906a049d04253d47
https://github.com/striglia/stockfighter/blob/df908f5919d6f861601cd00c906a049d04253d47/stockfighter/stockfighter.py#L32-L38
train
Check A Venue Is Up.
striglia/stockfighter
stockfighter/stockfighter.py
Stockfighter.venue_stocks
def venue_stocks(self): """List the stocks available for trading on the venue. https://starfighter.readme.io/docs/list-stocks-on-venue """ url = urljoin(self.base_url, 'venues/{0}/stocks'.format(self.venue)) return self.session.get(url).json()
python
def venue_stocks(self): """List the stocks available for trading on the venue. https://starfighter.readme.io/docs/list-stocks-on-venue """ url = urljoin(self.base_url, 'venues/{0}/stocks'.format(self.venue)) return self.session.get(url).json()
[ "def", "venue_stocks", "(", "self", ")", ":", "url", "=", "urljoin", "(", "self", ".", "base_url", ",", "'venues/{0}/stocks'", ".", "format", "(", "self", ".", "venue", ")", ")", "return", "self", ".", "session", ".", "get", "(", "url", ")", ".", "js...
List the stocks available for trading on the venue. https://starfighter.readme.io/docs/list-stocks-on-venue
[ "List", "the", "stocks", "available", "for", "trading", "on", "the", "venue", "." ]
df908f5919d6f861601cd00c906a049d04253d47
https://github.com/striglia/stockfighter/blob/df908f5919d6f861601cd00c906a049d04253d47/stockfighter/stockfighter.py#L40-L46
train
List the stocks available for trading on the venue.
striglia/stockfighter
stockfighter/stockfighter.py
Stockfighter.orderbook_for_stock
def orderbook_for_stock(self, stock): """Get the orderbook for a particular stock. https://starfighter.readme.io/docs/get-orderbook-for-stock """ url_fragment = 'venues/{venue}/stocks/{stock}'.format( venue=self.venue, stock=stock, ) url = urljoin...
python
def orderbook_for_stock(self, stock): """Get the orderbook for a particular stock. https://starfighter.readme.io/docs/get-orderbook-for-stock """ url_fragment = 'venues/{venue}/stocks/{stock}'.format( venue=self.venue, stock=stock, ) url = urljoin...
[ "def", "orderbook_for_stock", "(", "self", ",", "stock", ")", ":", "url_fragment", "=", "'venues/{venue}/stocks/{stock}'", ".", "format", "(", "venue", "=", "self", ".", "venue", ",", "stock", "=", "stock", ",", ")", "url", "=", "urljoin", "(", "self", "."...
Get the orderbook for a particular stock. https://starfighter.readme.io/docs/get-orderbook-for-stock
[ "Get", "the", "orderbook", "for", "a", "particular", "stock", "." ]
df908f5919d6f861601cd00c906a049d04253d47
https://github.com/striglia/stockfighter/blob/df908f5919d6f861601cd00c906a049d04253d47/stockfighter/stockfighter.py#L48-L58
train
Get the orderbook for a particular stock.
striglia/stockfighter
stockfighter/stockfighter.py
Stockfighter.place_new_order
def place_new_order(self, stock, price, qty, direction, order_type): """Place an order for a stock. https://starfighter.readme.io/docs/place-new-order """ url_fragment = 'venues/{venue}/stocks/{stock}/orders'.format( venue=self.venue, stock=stock, ) ...
python
def place_new_order(self, stock, price, qty, direction, order_type): """Place an order for a stock. https://starfighter.readme.io/docs/place-new-order """ url_fragment = 'venues/{venue}/stocks/{stock}/orders'.format( venue=self.venue, stock=stock, ) ...
[ "def", "place_new_order", "(", "self", ",", "stock", ",", "price", ",", "qty", ",", "direction", ",", "order_type", ")", ":", "url_fragment", "=", "'venues/{venue}/stocks/{stock}/orders'", ".", "format", "(", "venue", "=", "self", ".", "venue", ",", "stock", ...
Place an order for a stock. https://starfighter.readme.io/docs/place-new-order
[ "Place", "an", "order", "for", "a", "stock", "." ]
df908f5919d6f861601cd00c906a049d04253d47
https://github.com/striglia/stockfighter/blob/df908f5919d6f861601cd00c906a049d04253d47/stockfighter/stockfighter.py#L60-L80
train
Place a new order for a stock.
striglia/stockfighter
stockfighter/stockfighter.py
Stockfighter.status_for_order
def status_for_order(self, order_id, stock): """Status For An Existing Order https://starfighter.readme.io/docs/status-for-an-existing-order """ url_fragment = 'venues/{venue}/stocks/{stock}/orders/{order_id}'.format( venue=self.venue, stock=stock, or...
python
def status_for_order(self, order_id, stock): """Status For An Existing Order https://starfighter.readme.io/docs/status-for-an-existing-order """ url_fragment = 'venues/{venue}/stocks/{stock}/orders/{order_id}'.format( venue=self.venue, stock=stock, or...
[ "def", "status_for_order", "(", "self", ",", "order_id", ",", "stock", ")", ":", "url_fragment", "=", "'venues/{venue}/stocks/{stock}/orders/{order_id}'", ".", "format", "(", "venue", "=", "self", ".", "venue", ",", "stock", "=", "stock", ",", "order_id", "=", ...
Status For An Existing Order https://starfighter.readme.io/docs/status-for-an-existing-order
[ "Status", "For", "An", "Existing", "Order" ]
df908f5919d6f861601cd00c906a049d04253d47
https://github.com/striglia/stockfighter/blob/df908f5919d6f861601cd00c906a049d04253d47/stockfighter/stockfighter.py#L94-L105
train
Status for an existing order.
striglia/stockfighter
stockfighter/stockfighter.py
Stockfighter.cancel_order
def cancel_order(self, order_id, stock): """Cancel An Order https://starfighter.readme.io/docs/cancel-an-order """ url_fragment = 'venues/{venue}/stocks/{stock}/orders/{order_id}'.format( venue=self.venue, stock=stock, order_id=order_id, ) ...
python
def cancel_order(self, order_id, stock): """Cancel An Order https://starfighter.readme.io/docs/cancel-an-order """ url_fragment = 'venues/{venue}/stocks/{stock}/orders/{order_id}'.format( venue=self.venue, stock=stock, order_id=order_id, ) ...
[ "def", "cancel_order", "(", "self", ",", "order_id", ",", "stock", ")", ":", "url_fragment", "=", "'venues/{venue}/stocks/{stock}/orders/{order_id}'", ".", "format", "(", "venue", "=", "self", ".", "venue", ",", "stock", "=", "stock", ",", "order_id", "=", "or...
Cancel An Order https://starfighter.readme.io/docs/cancel-an-order
[ "Cancel", "An", "Order" ]
df908f5919d6f861601cd00c906a049d04253d47
https://github.com/striglia/stockfighter/blob/df908f5919d6f861601cd00c906a049d04253d47/stockfighter/stockfighter.py#L107-L118
train
Cancel an order in a given stock
striglia/stockfighter
stockfighter/stockfighter.py
Stockfighter.status_for_all_orders
def status_for_all_orders(self): """Status for all orders https://starfighter.readme.io/docs/status-for-all-orders """ url_fragment = 'venues/{venue}/accounts/{account}/orders'.format( venue=self.venue, account=self.account, ) url = urljoin(self.b...
python
def status_for_all_orders(self): """Status for all orders https://starfighter.readme.io/docs/status-for-all-orders """ url_fragment = 'venues/{venue}/accounts/{account}/orders'.format( venue=self.venue, account=self.account, ) url = urljoin(self.b...
[ "def", "status_for_all_orders", "(", "self", ")", ":", "url_fragment", "=", "'venues/{venue}/accounts/{account}/orders'", ".", "format", "(", "venue", "=", "self", ".", "venue", ",", "account", "=", "self", ".", "account", ",", ")", "url", "=", "urljoin", "(",...
Status for all orders https://starfighter.readme.io/docs/status-for-all-orders
[ "Status", "for", "all", "orders" ]
df908f5919d6f861601cd00c906a049d04253d47
https://github.com/striglia/stockfighter/blob/df908f5919d6f861601cd00c906a049d04253d47/stockfighter/stockfighter.py#L120-L130
train
Status for all orders
striglia/stockfighter
stockfighter/stockfighter.py
Stockfighter.status_for_all_orders_in_a_stock
def status_for_all_orders_in_a_stock(self, stock): """Status for all orders in a stock https://starfighter.readme.io/docs/status-for-all-orders-in-a-stock """ url_fragment = 'venues/{venue}/accounts/{account}/stocks/{stock}/orders'.format( stock=stock, venue=self...
python
def status_for_all_orders_in_a_stock(self, stock): """Status for all orders in a stock https://starfighter.readme.io/docs/status-for-all-orders-in-a-stock """ url_fragment = 'venues/{venue}/accounts/{account}/stocks/{stock}/orders'.format( stock=stock, venue=self...
[ "def", "status_for_all_orders_in_a_stock", "(", "self", ",", "stock", ")", ":", "url_fragment", "=", "'venues/{venue}/accounts/{account}/stocks/{stock}/orders'", ".", "format", "(", "stock", "=", "stock", ",", "venue", "=", "self", ".", "venue", ",", "account", "=",...
Status for all orders in a stock https://starfighter.readme.io/docs/status-for-all-orders-in-a-stock
[ "Status", "for", "all", "orders", "in", "a", "stock" ]
df908f5919d6f861601cd00c906a049d04253d47
https://github.com/striglia/stockfighter/blob/df908f5919d6f861601cd00c906a049d04253d47/stockfighter/stockfighter.py#L132-L143
train
Status for all orders in a stock
tweekmonster/moult
moult/frameworks/django.py
scan_django_settings
def scan_django_settings(values, imports): '''Recursively scans Django settings for values that appear to be imported modules. ''' if isinstance(values, (str, bytes)): if utils.is_import_str(values): imports.add(values) elif isinstance(values, dict): for k, v in values.it...
python
def scan_django_settings(values, imports): '''Recursively scans Django settings for values that appear to be imported modules. ''' if isinstance(values, (str, bytes)): if utils.is_import_str(values): imports.add(values) elif isinstance(values, dict): for k, v in values.it...
[ "def", "scan_django_settings", "(", "values", ",", "imports", ")", ":", "if", "isinstance", "(", "values", ",", "(", "str", ",", "bytes", ")", ")", ":", "if", "utils", ".", "is_import_str", "(", "values", ")", ":", "imports", ".", "add", "(", "values",...
Recursively scans Django settings for values that appear to be imported modules.
[ "Recursively", "scans", "Django", "settings", "for", "values", "that", "appear", "to", "be", "imported", "modules", "." ]
38d3a3b9002336219897ebe263ca1d8dcadbecf5
https://github.com/tweekmonster/moult/blob/38d3a3b9002336219897ebe263ca1d8dcadbecf5/moult/frameworks/django.py#L21-L37
train
Recursively scans Django settings for values that appear to be imported modules.
tweekmonster/moult
moult/frameworks/django.py
handle_django_settings
def handle_django_settings(filename): '''Attempts to load a Django project and get package dependencies from settings. Tested using Django 1.4 and 1.8. Not sure if some nuances are missed in the other versions. ''' old_sys_path = sys.path[:] dirpath = os.path.dirname(filename) project =...
python
def handle_django_settings(filename): '''Attempts to load a Django project and get package dependencies from settings. Tested using Django 1.4 and 1.8. Not sure if some nuances are missed in the other versions. ''' old_sys_path = sys.path[:] dirpath = os.path.dirname(filename) project =...
[ "def", "handle_django_settings", "(", "filename", ")", ":", "old_sys_path", "=", "sys", ".", "path", "[", ":", "]", "dirpath", "=", "os", ".", "path", ".", "dirname", "(", "filename", ")", "project", "=", "os", ".", "path", ".", "basename", "(", "dirpa...
Attempts to load a Django project and get package dependencies from settings. Tested using Django 1.4 and 1.8. Not sure if some nuances are missed in the other versions.
[ "Attempts", "to", "load", "a", "Django", "project", "and", "get", "package", "dependencies", "from", "settings", "." ]
38d3a3b9002336219897ebe263ca1d8dcadbecf5
https://github.com/tweekmonster/moult/blob/38d3a3b9002336219897ebe263ca1d8dcadbecf5/moult/frameworks/django.py#L40-L132
train
Attempts to load a Django project and get package dependencies from django. conf.
Dullage/starlingbank
starlingbank/__init__.py
_url
def _url(endpoint: str, sandbox: bool=False) -> str: """Build a URL from the API's base URLs.""" if sandbox is True: url = BASE_URL_SANDBOX else: url = BASE_URL return "{0}{1}".format(url, endpoint)
python
def _url(endpoint: str, sandbox: bool=False) -> str: """Build a URL from the API's base URLs.""" if sandbox is True: url = BASE_URL_SANDBOX else: url = BASE_URL return "{0}{1}".format(url, endpoint)
[ "def", "_url", "(", "endpoint", ":", "str", ",", "sandbox", ":", "bool", "=", "False", ")", "->", "str", ":", "if", "sandbox", "is", "True", ":", "url", "=", "BASE_URL_SANDBOX", "else", ":", "url", "=", "BASE_URL", "return", "\"{0}{1}\"", ".", "format"...
Build a URL from the API's base URLs.
[ "Build", "a", "URL", "from", "the", "API", "s", "base", "URLs", "." ]
9495456980d5d6d85c4e999a17dc69481067af09
https://github.com/Dullage/starlingbank/blob/9495456980d5d6d85c4e999a17dc69481067af09/starlingbank/__init__.py#L12-L18
train
Build a URL from the API s base URLs.
Dullage/starlingbank
starlingbank/__init__.py
SavingsGoal.update
def update(self, goal: Dict=None) -> None: """Update a single savings goals data.""" if goal is None: endpoint = "/account/{0}/savings-goals/{1}".format( self._account_uid, self.uid ) response = get( _url(endpoint, self...
python
def update(self, goal: Dict=None) -> None: """Update a single savings goals data.""" if goal is None: endpoint = "/account/{0}/savings-goals/{1}".format( self._account_uid, self.uid ) response = get( _url(endpoint, self...
[ "def", "update", "(", "self", ",", "goal", ":", "Dict", "=", "None", ")", "->", "None", ":", "if", "goal", "is", "None", ":", "endpoint", "=", "\"/account/{0}/savings-goals/{1}\"", ".", "format", "(", "self", ".", "_account_uid", ",", "self", ".", "uid",...
Update a single savings goals data.
[ "Update", "a", "single", "savings", "goals", "data", "." ]
9495456980d5d6d85c4e999a17dc69481067af09
https://github.com/Dullage/starlingbank/blob/9495456980d5d6d85c4e999a17dc69481067af09/starlingbank/__init__.py#L37-L61
train
Update a single savings goals data.
Dullage/starlingbank
starlingbank/__init__.py
SavingsGoal.deposit
def deposit(self, deposit_minor_units: int) -> None: """Add funds to a savings goal.""" endpoint = "/account/{0}/savings-goals/{1}/add-money/{2}".format( self._account_uid, self.uid, uuid4() ) body = { "amount": { "currency...
python
def deposit(self, deposit_minor_units: int) -> None: """Add funds to a savings goal.""" endpoint = "/account/{0}/savings-goals/{1}/add-money/{2}".format( self._account_uid, self.uid, uuid4() ) body = { "amount": { "currency...
[ "def", "deposit", "(", "self", ",", "deposit_minor_units", ":", "int", ")", "->", "None", ":", "endpoint", "=", "\"/account/{0}/savings-goals/{1}/add-money/{2}\"", ".", "format", "(", "self", ".", "_account_uid", ",", "self", ".", "uid", ",", "uuid4", "(", ")"...
Add funds to a savings goal.
[ "Add", "funds", "to", "a", "savings", "goal", "." ]
9495456980d5d6d85c4e999a17dc69481067af09
https://github.com/Dullage/starlingbank/blob/9495456980d5d6d85c4e999a17dc69481067af09/starlingbank/__init__.py#L63-L85
train
Add funds to a savings goal.
Dullage/starlingbank
starlingbank/__init__.py
SavingsGoal.get_image
def get_image(self, filename: str=None) -> None: """Download the photo associated with a Savings Goal.""" if filename is None: filename = "{0}.png".format(self.name) endpoint = "/account/{0}/savings-goals/{1}/photo".format( self._account_uid, self.uid ...
python
def get_image(self, filename: str=None) -> None: """Download the photo associated with a Savings Goal.""" if filename is None: filename = "{0}.png".format(self.name) endpoint = "/account/{0}/savings-goals/{1}/photo".format( self._account_uid, self.uid ...
[ "def", "get_image", "(", "self", ",", "filename", ":", "str", "=", "None", ")", "->", "None", ":", "if", "filename", "is", "None", ":", "filename", "=", "\"{0}.png\"", ".", "format", "(", "self", ".", "name", ")", "endpoint", "=", "\"/account/{0}/savings...
Download the photo associated with a Savings Goal.
[ "Download", "the", "photo", "associated", "with", "a", "Savings", "Goal", "." ]
9495456980d5d6d85c4e999a17dc69481067af09
https://github.com/Dullage/starlingbank/blob/9495456980d5d6d85c4e999a17dc69481067af09/starlingbank/__init__.py#L111-L129
train
Download the photo associated with a Savings Goal.
Dullage/starlingbank
starlingbank/__init__.py
StarlingAccount.update_account_data
def update_account_data(self) -> None: """Get basic information for the account.""" response = get( _url( "/accounts/{0}/identifiers".format(self._account_uid), self._sandbox ), headers=self._auth_headers ) response.rais...
python
def update_account_data(self) -> None: """Get basic information for the account.""" response = get( _url( "/accounts/{0}/identifiers".format(self._account_uid), self._sandbox ), headers=self._auth_headers ) response.rais...
[ "def", "update_account_data", "(", "self", ")", "->", "None", ":", "response", "=", "get", "(", "_url", "(", "\"/accounts/{0}/identifiers\"", ".", "format", "(", "self", ".", "_account_uid", ")", ",", "self", ".", "_sandbox", ")", ",", "headers", "=", "sel...
Get basic information for the account.
[ "Get", "basic", "information", "for", "the", "account", "." ]
9495456980d5d6d85c4e999a17dc69481067af09
https://github.com/Dullage/starlingbank/blob/9495456980d5d6d85c4e999a17dc69481067af09/starlingbank/__init__.py#L135-L151
train
Update the account data with the account information.
Dullage/starlingbank
starlingbank/__init__.py
StarlingAccount.update_balance_data
def update_balance_data(self) -> None: """Get the latest balance information for the account.""" response = get( _url( "/accounts/{0}/balance".format(self._account_uid), self._sandbox ), headers=self._auth_headers ) resp...
python
def update_balance_data(self) -> None: """Get the latest balance information for the account.""" response = get( _url( "/accounts/{0}/balance".format(self._account_uid), self._sandbox ), headers=self._auth_headers ) resp...
[ "def", "update_balance_data", "(", "self", ")", "->", "None", ":", "response", "=", "get", "(", "_url", "(", "\"/accounts/{0}/balance\"", ".", "format", "(", "self", ".", "_account_uid", ")", ",", "self", ".", "_sandbox", ")", ",", "headers", "=", "self", ...
Get the latest balance information for the account.
[ "Get", "the", "latest", "balance", "information", "for", "the", "account", "." ]
9495456980d5d6d85c4e999a17dc69481067af09
https://github.com/Dullage/starlingbank/blob/9495456980d5d6d85c4e999a17dc69481067af09/starlingbank/__init__.py#L153-L170
train
Update the internal state of the object with the latest balance information.
Dullage/starlingbank
starlingbank/__init__.py
StarlingAccount.update_savings_goal_data
def update_savings_goal_data(self) -> None: """Get the latest savings goal information for the account.""" response = get( _url( "/account/{0}/savings-goals".format(self._account_uid), self._sandbox ), headers=self._auth_headers ...
python
def update_savings_goal_data(self) -> None: """Get the latest savings goal information for the account.""" response = get( _url( "/account/{0}/savings-goals".format(self._account_uid), self._sandbox ), headers=self._auth_headers ...
[ "def", "update_savings_goal_data", "(", "self", ")", "->", "None", ":", "response", "=", "get", "(", "_url", "(", "\"/account/{0}/savings-goals\"", ".", "format", "(", "self", ".", "_account_uid", ")", ",", "self", ".", "_sandbox", ")", ",", "headers", "=", ...
Get the latest savings goal information for the account.
[ "Get", "the", "latest", "savings", "goal", "information", "for", "the", "account", "." ]
9495456980d5d6d85c4e999a17dc69481067af09
https://github.com/Dullage/starlingbank/blob/9495456980d5d6d85c4e999a17dc69481067af09/starlingbank/__init__.py#L172-L206
train
Update the savings goal data for the account.
mintchaos/django_inlines
django_inlines/templatetags/inlines.py
process_inlines
def process_inlines(parser, token): """ Searches through the provided content and applies inlines where ever they are found. Syntax:: {% process_inlines entry.body [in template_dir] [as varname] } Examples:: {% process_inlines entry.body %} {% process_inlines entry.body ...
python
def process_inlines(parser, token): """ Searches through the provided content and applies inlines where ever they are found. Syntax:: {% process_inlines entry.body [in template_dir] [as varname] } Examples:: {% process_inlines entry.body %} {% process_inlines entry.body ...
[ "def", "process_inlines", "(", "parser", ",", "token", ")", ":", "args", "=", "token", ".", "split_contents", "(", ")", "if", "not", "len", "(", "args", ")", "in", "(", "2", ",", "4", ",", "6", ")", ":", "raise", "template", ".", "TemplateSyntaxError...
Searches through the provided content and applies inlines where ever they are found. Syntax:: {% process_inlines entry.body [in template_dir] [as varname] } Examples:: {% process_inlines entry.body %} {% process_inlines entry.body as body %} {% process_inlines entry.bod...
[ "Searches", "through", "the", "provided", "content", "and", "applies", "inlines", "where", "ever", "they", "are", "found", "." ]
1912e508d04884713a6c44a068c21fbd217d478a
https://github.com/mintchaos/django_inlines/blob/1912e508d04884713a6c44a068c21fbd217d478a/django_inlines/templatetags/inlines.py#L40-L80
train
Processes the inlines of the content of the current page.
DeV1doR/aioethereum
aioethereum/management/admin.py
AdminMixin.admin_startRPC
def admin_startRPC(self, host='localhost', port=8545, cors=None, apis=None): """https://github.com/ethereum/go-ethereum/wiki/Management-APIs#admin_startrpc :param host: Network interface to open the listener socket (optional) :type host: str :param port: Network port to open the listen...
python
def admin_startRPC(self, host='localhost', port=8545, cors=None, apis=None): """https://github.com/ethereum/go-ethereum/wiki/Management-APIs#admin_startrpc :param host: Network interface to open the listener socket (optional) :type host: str :param port: Network port to open the listen...
[ "def", "admin_startRPC", "(", "self", ",", "host", "=", "'localhost'", ",", "port", "=", "8545", ",", "cors", "=", "None", ",", "apis", "=", "None", ")", ":", "if", "cors", "is", "None", ":", "cors", "=", "[", "]", "if", "apis", "is", "None", ":"...
https://github.com/ethereum/go-ethereum/wiki/Management-APIs#admin_startrpc :param host: Network interface to open the listener socket (optional) :type host: str :param port: Network port to open the listener socket (optional) :type port: int :param cors: Cross-origin resource...
[ "https", ":", "//", "github", ".", "com", "/", "ethereum", "/", "go", "-", "ethereum", "/", "wiki", "/", "Management", "-", "APIs#admin_startrpc" ]
85eb46550d862b3ccc309914ea871ca1c7b42157
https://github.com/DeV1doR/aioethereum/blob/85eb46550d862b3ccc309914ea871ca1c7b42157/aioethereum/management/admin.py#L53-L77
train
Start an admin_startRPC RPC.
DeV1doR/aioethereum
aioethereum/management/admin.py
AdminMixin.admin_startWS
def admin_startWS(self, host='localhost', port=8546, cors=None, apis=None): """https://github.com/ethereum/go-ethereum/wiki/Management-APIs#admin_startws :param host: Network interface to open the listener socket (optional) :type host: str :param port: Network port to open the listener...
python
def admin_startWS(self, host='localhost', port=8546, cors=None, apis=None): """https://github.com/ethereum/go-ethereum/wiki/Management-APIs#admin_startws :param host: Network interface to open the listener socket (optional) :type host: str :param port: Network port to open the listener...
[ "def", "admin_startWS", "(", "self", ",", "host", "=", "'localhost'", ",", "port", "=", "8546", ",", "cors", "=", "None", ",", "apis", "=", "None", ")", ":", "if", "cors", "is", "None", ":", "cors", "=", "[", "]", "if", "apis", "is", "None", ":",...
https://github.com/ethereum/go-ethereum/wiki/Management-APIs#admin_startws :param host: Network interface to open the listener socket (optional) :type host: str :param port: Network port to open the listener socket (optional) :type port: int :param cors: Cross-origin resource ...
[ "https", ":", "//", "github", ".", "com", "/", "ethereum", "/", "go", "-", "ethereum", "/", "wiki", "/", "Management", "-", "APIs#admin_startws" ]
85eb46550d862b3ccc309914ea871ca1c7b42157
https://github.com/DeV1doR/aioethereum/blob/85eb46550d862b3ccc309914ea871ca1c7b42157/aioethereum/management/admin.py#L80-L104
train
Open the listener socket and start the admin session.
klichukb/django-migrate-sql
migrate_sql/graph.py
build_current_graph
def build_current_graph(): """ Read current state of SQL items from the current project state. Returns: (SQLStateGraph) Current project state graph. """ graph = SQLStateGraph() for app_name, config in apps.app_configs.items(): try: module = import_module( ...
python
def build_current_graph(): """ Read current state of SQL items from the current project state. Returns: (SQLStateGraph) Current project state graph. """ graph = SQLStateGraph() for app_name, config in apps.app_configs.items(): try: module = import_module( ...
[ "def", "build_current_graph", "(", ")", ":", "graph", "=", "SQLStateGraph", "(", ")", "for", "app_name", ",", "config", "in", "apps", ".", "app_configs", ".", "items", "(", ")", ":", "try", ":", "module", "=", "import_module", "(", "'.'", ".", "join", ...
Read current state of SQL items from the current project state. Returns: (SQLStateGraph) Current project state graph.
[ "Read", "current", "state", "of", "SQL", "items", "from", "the", "current", "project", "state", "." ]
be48ff2c9283404e3d951128c459c3496d1ba25d
https://github.com/klichukb/django-migrate-sql/blob/be48ff2c9283404e3d951128c459c3496d1ba25d/migrate_sql/graph.py#L100-L122
train
Builds the current state of SQL items from the current project state.
klichukb/django-migrate-sql
migrate_sql/graph.py
SQLStateGraph.build_graph
def build_graph(self): """ Read lazy dependency list and build graph. """ for child, parents in self.dependencies.items(): if child not in self.nodes: raise NodeNotFoundError( "App %s SQL item dependencies reference nonexistent child node %...
python
def build_graph(self): """ Read lazy dependency list and build graph. """ for child, parents in self.dependencies.items(): if child not in self.nodes: raise NodeNotFoundError( "App %s SQL item dependencies reference nonexistent child node %...
[ "def", "build_graph", "(", "self", ")", ":", "for", "child", ",", "parents", "in", "self", ".", "dependencies", ".", "items", "(", ")", ":", "if", "child", "not", "in", "self", ".", "nodes", ":", "raise", "NodeNotFoundError", "(", "\"App %s SQL item depend...
Read lazy dependency list and build graph.
[ "Read", "lazy", "dependency", "list", "and", "build", "graph", "." ]
be48ff2c9283404e3d951128c459c3496d1ba25d
https://github.com/klichukb/django-migrate-sql/blob/be48ff2c9283404e3d951128c459c3496d1ba25d/migrate_sql/graph.py#L54-L77
train
Read lazy dependency list and build graph.
ngmarchant/oasis
oasis/passive.py
PassiveSampler.reset
def reset(self): """Resets the sampler to its initial state Note ---- This will destroy the label cache and history of estimates. """ self._TP = np.zeros(self._n_class) self._FP = np.zeros(self._n_class) self._FN = np.zeros(self._n_class) self._TN...
python
def reset(self): """Resets the sampler to its initial state Note ---- This will destroy the label cache and history of estimates. """ self._TP = np.zeros(self._n_class) self._FP = np.zeros(self._n_class) self._FN = np.zeros(self._n_class) self._TN...
[ "def", "reset", "(", "self", ")", ":", "self", ".", "_TP", "=", "np", ".", "zeros", "(", "self", ".", "_n_class", ")", "self", ".", "_FP", "=", "np", ".", "zeros", "(", "self", ".", "_n_class", ")", "self", ".", "_FN", "=", "np", ".", "zeros", ...
Resets the sampler to its initial state Note ---- This will destroy the label cache and history of estimates.
[ "Resets", "the", "sampler", "to", "its", "initial", "state" ]
28a037a8924b85ae97db8a93960a910a219d6a4a
https://github.com/ngmarchant/oasis/blob/28a037a8924b85ae97db8a93960a910a219d6a4a/oasis/passive.py#L141-L155
train
Resets the sampler to its initial state.
ngmarchant/oasis
oasis/passive.py
PassiveSampler._iterate
def _iterate(self, **kwargs): """Procedure for a single iteration (sampling and updating)""" # Sample item loc, weight, extra_info = self._sample_item(**kwargs) # Query label ell = self._query_label(loc) # Get predictions ell_hat = self.predictions[loc,:] ...
python
def _iterate(self, **kwargs): """Procedure for a single iteration (sampling and updating)""" # Sample item loc, weight, extra_info = self._sample_item(**kwargs) # Query label ell = self._query_label(loc) # Get predictions ell_hat = self.predictions[loc,:] ...
[ "def", "_iterate", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# Sample item", "loc", ",", "weight", ",", "extra_info", "=", "self", ".", "_sample_item", "(", "*", "*", "kwargs", ")", "# Query label", "ell", "=", "self", ".", "_query_label", "(", ...
Procedure for a single iteration (sampling and updating)
[ "Procedure", "for", "a", "single", "iteration", "(", "sampling", "and", "updating", ")" ]
28a037a8924b85ae97db8a93960a910a219d6a4a
https://github.com/ngmarchant/oasis/blob/28a037a8924b85ae97db8a93960a910a219d6a4a/oasis/passive.py#L157-L172
train
Procedure for a single iteration ( sampling and updating
ngmarchant/oasis
oasis/passive.py
PassiveSampler.sample
def sample(self, n_to_sample, **kwargs): """Sample a sequence of items from the pool Parameters ---------- n_to_sample : int number of items to sample """ n_to_sample = verify_positive(int(n_to_sample)) n_remaining = self._max_iter - self.t_ ...
python
def sample(self, n_to_sample, **kwargs): """Sample a sequence of items from the pool Parameters ---------- n_to_sample : int number of items to sample """ n_to_sample = verify_positive(int(n_to_sample)) n_remaining = self._max_iter - self.t_ ...
[ "def", "sample", "(", "self", ",", "n_to_sample", ",", "*", "*", "kwargs", ")", ":", "n_to_sample", "=", "verify_positive", "(", "int", "(", "n_to_sample", ")", ")", "n_remaining", "=", "self", ".", "_max_iter", "-", "self", ".", "t_", "if", "n_remaining...
Sample a sequence of items from the pool Parameters ---------- n_to_sample : int number of items to sample
[ "Sample", "a", "sequence", "of", "items", "from", "the", "pool" ]
28a037a8924b85ae97db8a93960a910a219d6a4a
https://github.com/ngmarchant/oasis/blob/28a037a8924b85ae97db8a93960a910a219d6a4a/oasis/passive.py#L174-L201
train
Sample a sequence of items from the pool.
ngmarchant/oasis
oasis/passive.py
PassiveSampler.sample_distinct
def sample_distinct(self, n_to_sample, **kwargs): """Sample a sequence of items from the pool until a minimum number of distinct items are queried Parameters ---------- n_to_sample : int number of distinct items to sample. If sampling with replacement, th...
python
def sample_distinct(self, n_to_sample, **kwargs): """Sample a sequence of items from the pool until a minimum number of distinct items are queried Parameters ---------- n_to_sample : int number of distinct items to sample. If sampling with replacement, th...
[ "def", "sample_distinct", "(", "self", ",", "n_to_sample", ",", "*", "*", "kwargs", ")", ":", "# Record how many distinct items have not yet been sampled", "n_notsampled", "=", "np", ".", "sum", "(", "np", ".", "isnan", "(", "self", ".", "cached_labels_", ")", "...
Sample a sequence of items from the pool until a minimum number of distinct items are queried Parameters ---------- n_to_sample : int number of distinct items to sample. If sampling with replacement, this number is not necessarily the same as the number of ...
[ "Sample", "a", "sequence", "of", "items", "from", "the", "pool", "until", "a", "minimum", "number", "of", "distinct", "items", "are", "queried" ]
28a037a8924b85ae97db8a93960a910a219d6a4a
https://github.com/ngmarchant/oasis/blob/28a037a8924b85ae97db8a93960a910a219d6a4a/oasis/passive.py#L203-L229
train
Sample a sequence of items from the pool until a minimum number of distinct items are queried.
ngmarchant/oasis
oasis/passive.py
PassiveSampler._sample_item
def _sample_item(self, **kwargs): """Sample an item from the pool""" if self.replace: # Can sample from any of the items loc = np.random.choice(self._n_items) else: # Can only sample from items that have not been seen # Find ids that haven't been s...
python
def _sample_item(self, **kwargs): """Sample an item from the pool""" if self.replace: # Can sample from any of the items loc = np.random.choice(self._n_items) else: # Can only sample from items that have not been seen # Find ids that haven't been s...
[ "def", "_sample_item", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "replace", ":", "# Can sample from any of the items", "loc", "=", "np", ".", "random", ".", "choice", "(", "self", ".", "_n_items", ")", "else", ":", "# Can only samp...
Sample an item from the pool
[ "Sample", "an", "item", "from", "the", "pool" ]
28a037a8924b85ae97db8a93960a910a219d6a4a
https://github.com/ngmarchant/oasis/blob/28a037a8924b85ae97db8a93960a910a219d6a4a/oasis/passive.py#L231-L241
train
Sample an item from the pool
ngmarchant/oasis
oasis/passive.py
PassiveSampler._query_label
def _query_label(self, loc): """Query the label for the item with index `loc`. Preferentially queries the label from the cache, but if not yet cached, queries the oracle. Returns ------- int the true label "0" or "1". """ # Try to get label fr...
python
def _query_label(self, loc): """Query the label for the item with index `loc`. Preferentially queries the label from the cache, but if not yet cached, queries the oracle. Returns ------- int the true label "0" or "1". """ # Try to get label fr...
[ "def", "_query_label", "(", "self", ",", "loc", ")", ":", "# Try to get label from cache", "ell", "=", "self", ".", "cached_labels_", "[", "loc", "]", "if", "np", ".", "isnan", "(", "ell", ")", ":", "# Label has not been cached. Need to query oracle", "oracle_arg"...
Query the label for the item with index `loc`. Preferentially queries the label from the cache, but if not yet cached, queries the oracle. Returns ------- int the true label "0" or "1".
[ "Query", "the", "label", "for", "the", "item", "with", "index", "loc", ".", "Preferentially", "queries", "the", "label", "from", "the", "cache", "but", "if", "not", "yet", "cached", "queries", "the", "oracle", "." ]
28a037a8924b85ae97db8a93960a910a219d6a4a
https://github.com/ngmarchant/oasis/blob/28a037a8924b85ae97db8a93960a910a219d6a4a/oasis/passive.py#L243-L266
train
Query the label for the item with index loc.
ngmarchant/oasis
oasis/passive.py
PassiveSampler._F_measure
def _F_measure(self, alpha, TP, FP, FN, return_num_den=False): """Calculate the weighted F-measure""" num = np.float64(TP) den = np.float64(alpha * (TP + FP) + (1 - alpha) * (TP + FN)) with np.errstate(divide='ignore', invalid='ignore'): F_measure = num/den #F_measure...
python
def _F_measure(self, alpha, TP, FP, FN, return_num_den=False): """Calculate the weighted F-measure""" num = np.float64(TP) den = np.float64(alpha * (TP + FP) + (1 - alpha) * (TP + FN)) with np.errstate(divide='ignore', invalid='ignore'): F_measure = num/den #F_measure...
[ "def", "_F_measure", "(", "self", ",", "alpha", ",", "TP", ",", "FP", ",", "FN", ",", "return_num_den", "=", "False", ")", ":", "num", "=", "np", ".", "float64", "(", "TP", ")", "den", "=", "np", ".", "float64", "(", "alpha", "*", "(", "TP", "+...
Calculate the weighted F-measure
[ "Calculate", "the", "weighted", "F", "-", "measure" ]
28a037a8924b85ae97db8a93960a910a219d6a4a
https://github.com/ngmarchant/oasis/blob/28a037a8924b85ae97db8a93960a910a219d6a4a/oasis/passive.py#L268-L279
train
Calculate the weighted F - measure of a set of TPs FP FN.
ngmarchant/oasis
oasis/passive.py
PassiveSampler._update_estimate_and_sampler
def _update_estimate_and_sampler(self, ell, ell_hat, weight, extra_info, **kwargs): """Update the estimate after querying the label for an item""" self._TP += ell_hat * ell * weight self._FP += ell_hat * (1 - ell) * weight self._FN += (1 - ell_hat) * ...
python
def _update_estimate_and_sampler(self, ell, ell_hat, weight, extra_info, **kwargs): """Update the estimate after querying the label for an item""" self._TP += ell_hat * ell * weight self._FP += ell_hat * (1 - ell) * weight self._FN += (1 - ell_hat) * ...
[ "def", "_update_estimate_and_sampler", "(", "self", ",", "ell", ",", "ell_hat", ",", "weight", ",", "extra_info", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_TP", "+=", "ell_hat", "*", "ell", "*", "weight", "self", ".", "_FP", "+=", "ell_hat", "*...
Update the estimate after querying the label for an item
[ "Update", "the", "estimate", "after", "querying", "the", "label", "for", "an", "item" ]
28a037a8924b85ae97db8a93960a910a219d6a4a
https://github.com/ngmarchant/oasis/blob/28a037a8924b85ae97db8a93960a910a219d6a4a/oasis/passive.py#L281-L290
train
Update the estimate after querying the label for an item
openearth/mmi-python
mmi/tracker_client.py
MMITracker.key_occurrence
def key_occurrence(self, key, update=True): """ Return a dict containing the value of the provided key and its uuid as value. """ if update: self.update() result = {} for k, v in self.database.items(): if key in v: result[st...
python
def key_occurrence(self, key, update=True): """ Return a dict containing the value of the provided key and its uuid as value. """ if update: self.update() result = {} for k, v in self.database.items(): if key in v: result[st...
[ "def", "key_occurrence", "(", "self", ",", "key", ",", "update", "=", "True", ")", ":", "if", "update", ":", "self", ".", "update", "(", ")", "result", "=", "{", "}", "for", "k", ",", "v", "in", "self", ".", "database", ".", "items", "(", ")", ...
Return a dict containing the value of the provided key and its uuid as value.
[ "Return", "a", "dict", "containing", "the", "value", "of", "the", "provided", "key", "and", "its", "uuid", "as", "value", "." ]
a2f4ac96b1e7f2fa903f668b3e05c4e86ad42e8d
https://github.com/openearth/mmi-python/blob/a2f4ac96b1e7f2fa903f668b3e05c4e86ad42e8d/mmi/tracker_client.py#L17-L28
train
Return a dict containing the value of the provided key and its uuid as value.
openearth/mmi-python
mmi/tracker_client.py
MMITracker.zmq_address
def zmq_address(self, key): """ Return a ZeroMQ address to the module with the provided key. """ zmq_address = "tcp://" + self.database[key]['node'] + ":" + str(self.database[key]['ports']['REQ']) return zmq_address
python
def zmq_address(self, key): """ Return a ZeroMQ address to the module with the provided key. """ zmq_address = "tcp://" + self.database[key]['node'] + ":" + str(self.database[key]['ports']['REQ']) return zmq_address
[ "def", "zmq_address", "(", "self", ",", "key", ")", ":", "zmq_address", "=", "\"tcp://\"", "+", "self", ".", "database", "[", "key", "]", "[", "'node'", "]", "+", "\":\"", "+", "str", "(", "self", ".", "database", "[", "key", "]", "[", "'ports'", "...
Return a ZeroMQ address to the module with the provided key.
[ "Return", "a", "ZeroMQ", "address", "to", "the", "module", "with", "the", "provided", "key", "." ]
a2f4ac96b1e7f2fa903f668b3e05c4e86ad42e8d
https://github.com/openearth/mmi-python/blob/a2f4ac96b1e7f2fa903f668b3e05c4e86ad42e8d/mmi/tracker_client.py#L30-L35
train
Return a ZeroMQ address to the module with the provided key.
mkoura/dump2polarion
dump2polarion/results/ostriztools.py
_get_json
def _get_json(location): """Reads JSON data from file or URL.""" location = os.path.expanduser(location) try: if os.path.isfile(location): with io.open(location, encoding="utf-8") as json_data: return json.load(json_data, object_pairs_hook=OrderedDict).get("tests") ...
python
def _get_json(location): """Reads JSON data from file or URL.""" location = os.path.expanduser(location) try: if os.path.isfile(location): with io.open(location, encoding="utf-8") as json_data: return json.load(json_data, object_pairs_hook=OrderedDict).get("tests") ...
[ "def", "_get_json", "(", "location", ")", ":", "location", "=", "os", ".", "path", ".", "expanduser", "(", "location", ")", "try", ":", "if", "os", ".", "path", ".", "isfile", "(", "location", ")", ":", "with", "io", ".", "open", "(", "location", "...
Reads JSON data from file or URL.
[ "Reads", "JSON", "data", "from", "file", "or", "URL", "." ]
f4bd24e9d5070e282aad15f1e8bb514c0525cd37
https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/results/ostriztools.py#L29-L44
train
Reads JSON data from file or URL.
mkoura/dump2polarion
dump2polarion/results/ostriztools.py
_calculate_duration
def _calculate_duration(start_time, finish_time): """Calculates how long it took to execute the testcase.""" if not (start_time and finish_time): return 0 start = datetime.datetime.fromtimestamp(start_time) finish = datetime.datetime.fromtimestamp(finish_time) duration = finish - start ...
python
def _calculate_duration(start_time, finish_time): """Calculates how long it took to execute the testcase.""" if not (start_time and finish_time): return 0 start = datetime.datetime.fromtimestamp(start_time) finish = datetime.datetime.fromtimestamp(finish_time) duration = finish - start ...
[ "def", "_calculate_duration", "(", "start_time", ",", "finish_time", ")", ":", "if", "not", "(", "start_time", "and", "finish_time", ")", ":", "return", "0", "start", "=", "datetime", ".", "datetime", ".", "fromtimestamp", "(", "start_time", ")", "finish", "...
Calculates how long it took to execute the testcase.
[ "Calculates", "how", "long", "it", "took", "to", "execute", "the", "testcase", "." ]
f4bd24e9d5070e282aad15f1e8bb514c0525cd37
https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/results/ostriztools.py#L67-L76
train
Calculates how long it took to execute the testcase.
mkoura/dump2polarion
dump2polarion/results/ostriztools.py
_filter_parameters
def _filter_parameters(parameters): """Filters the ignored parameters out.""" if not parameters: return None return OrderedDict( (param, value) for param, value in six.iteritems(parameters) if param not in IGNORED_PARAMS )
python
def _filter_parameters(parameters): """Filters the ignored parameters out.""" if not parameters: return None return OrderedDict( (param, value) for param, value in six.iteritems(parameters) if param not in IGNORED_PARAMS )
[ "def", "_filter_parameters", "(", "parameters", ")", ":", "if", "not", "parameters", ":", "return", "None", "return", "OrderedDict", "(", "(", "param", ",", "value", ")", "for", "param", ",", "value", "in", "six", ".", "iteritems", "(", "parameters", ")", ...
Filters the ignored parameters out.
[ "Filters", "the", "ignored", "parameters", "out", "." ]
f4bd24e9d5070e282aad15f1e8bb514c0525cd37
https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/results/ostriztools.py#L88-L94
train
Filters the ignored parameters out.
mkoura/dump2polarion
dump2polarion/results/ostriztools.py
_append_record
def _append_record(test_data, results, test_path): """Adds data of single testcase results to results database.""" statuses = test_data.get("statuses") jenkins_data = test_data.get("jenkins") or {} data = [ ("title", test_data.get("test_name") or _get_testname(test_path)), ("verdict", s...
python
def _append_record(test_data, results, test_path): """Adds data of single testcase results to results database.""" statuses = test_data.get("statuses") jenkins_data = test_data.get("jenkins") or {} data = [ ("title", test_data.get("test_name") or _get_testname(test_path)), ("verdict", s...
[ "def", "_append_record", "(", "test_data", ",", "results", ",", "test_path", ")", ":", "statuses", "=", "test_data", ".", "get", "(", "\"statuses\"", ")", "jenkins_data", "=", "test_data", ".", "get", "(", "\"jenkins\"", ")", "or", "{", "}", "data", "=", ...
Adds data of single testcase results to results database.
[ "Adds", "data", "of", "single", "testcase", "results", "to", "results", "database", "." ]
f4bd24e9d5070e282aad15f1e8bb514c0525cd37
https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/results/ostriztools.py#L97-L120
train
Adds data of single testcase results to results database.
mkoura/dump2polarion
dump2polarion/results/ostriztools.py
_parse_ostriz
def _parse_ostriz(ostriz_data): """Reads the content of the input JSON and returns testcases results.""" if not ostriz_data: raise NothingToDoException("No data to import") results = [] found_build = None last_finish_time = [0] for test_path, test_data in six.iteritems(ostriz_data): ...
python
def _parse_ostriz(ostriz_data): """Reads the content of the input JSON and returns testcases results.""" if not ostriz_data: raise NothingToDoException("No data to import") results = [] found_build = None last_finish_time = [0] for test_path, test_data in six.iteritems(ostriz_data): ...
[ "def", "_parse_ostriz", "(", "ostriz_data", ")", ":", "if", "not", "ostriz_data", ":", "raise", "NothingToDoException", "(", "\"No data to import\"", ")", "results", "=", "[", "]", "found_build", "=", "None", "last_finish_time", "=", "[", "0", "]", "for", "tes...
Reads the content of the input JSON and returns testcases results.
[ "Reads", "the", "content", "of", "the", "input", "JSON", "and", "returns", "testcases", "results", "." ]
f4bd24e9d5070e282aad15f1e8bb514c0525cd37
https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/results/ostriztools.py#L129-L160
train
Reads the content of the input JSON and returns testcases results.
openearth/mmi-python
mmi/__init__.py
send_array
def send_array( socket, A=None, metadata=None, flags=0, copy=False, track=False, compress=None, chunksize=50 * 1000 * 1000 ): """send a numpy array with metadata over zmq message is mostly multipart: metadata | array part 1 | array part 2, etc only metadata: metadata t...
python
def send_array( socket, A=None, metadata=None, flags=0, copy=False, track=False, compress=None, chunksize=50 * 1000 * 1000 ): """send a numpy array with metadata over zmq message is mostly multipart: metadata | array part 1 | array part 2, etc only metadata: metadata t...
[ "def", "send_array", "(", "socket", ",", "A", "=", "None", ",", "metadata", "=", "None", ",", "flags", "=", "0", ",", "copy", "=", "False", ",", "track", "=", "False", ",", "compress", "=", "None", ",", "chunksize", "=", "50", "*", "1000", "*", "...
send a numpy array with metadata over zmq message is mostly multipart: metadata | array part 1 | array part 2, etc only metadata: metadata the chunksize roughly determines the size of the parts being sent if the chunksize is too big, you get an error like: zmq.error.Again: Resource te...
[ "send", "a", "numpy", "array", "with", "metadata", "over", "zmq" ]
a2f4ac96b1e7f2fa903f668b3e05c4e86ad42e8d
https://github.com/openearth/mmi-python/blob/a2f4ac96b1e7f2fa903f668b3e05c4e86ad42e8d/mmi/__init__.py#L27-L98
train
send a numpy array over zmq socket
openearth/mmi-python
mmi/__init__.py
recv_array
def recv_array( socket, flags=0, copy=False, track=False, poll=None, poll_timeout=10000 ): """recv a metadata and an optional numpy array from a zmq socket Optionally provide poll object to use recv_array with timeout poll_timeout is in millis """ if...
python
def recv_array( socket, flags=0, copy=False, track=False, poll=None, poll_timeout=10000 ): """recv a metadata and an optional numpy array from a zmq socket Optionally provide poll object to use recv_array with timeout poll_timeout is in millis """ if...
[ "def", "recv_array", "(", "socket", ",", "flags", "=", "0", ",", "copy", "=", "False", ",", "track", "=", "False", ",", "poll", "=", "None", ",", "poll_timeout", "=", "10000", ")", ":", "if", "poll", "is", "None", ":", "md", "=", "socket", ".", "...
recv a metadata and an optional numpy array from a zmq socket Optionally provide poll object to use recv_array with timeout poll_timeout is in millis
[ "recv", "a", "metadata", "and", "an", "optional", "numpy", "array", "from", "a", "zmq", "socket" ]
a2f4ac96b1e7f2fa903f668b3e05c4e86ad42e8d
https://github.com/openearth/mmi-python/blob/a2f4ac96b1e7f2fa903f668b3e05c4e86ad42e8d/mmi/__init__.py#L101-L182
train
recv a metadata and an optional numpy array from a zmq socket
pneff/wsgiservice
wsgiservice/decorators.py
validate
def validate(name, re=None, convert=None, doc=None): """Decorator. Apply on a :class:`wsgiservice.Resource` or any of it's methods to validates a parameter on input. When a parameter does not validate, a :class:`wsgiservice.exceptions.ValidationException` exception will be thrown. :param name: Name...
python
def validate(name, re=None, convert=None, doc=None): """Decorator. Apply on a :class:`wsgiservice.Resource` or any of it's methods to validates a parameter on input. When a parameter does not validate, a :class:`wsgiservice.exceptions.ValidationException` exception will be thrown. :param name: Name...
[ "def", "validate", "(", "name", ",", "re", "=", "None", ",", "convert", "=", "None", ",", "doc", "=", "None", ")", ":", "def", "wrap", "(", "cls_or_func", ")", ":", "if", "not", "hasattr", "(", "cls_or_func", ",", "'_validations'", ")", ":", "cls_or_...
Decorator. Apply on a :class:`wsgiservice.Resource` or any of it's methods to validates a parameter on input. When a parameter does not validate, a :class:`wsgiservice.exceptions.ValidationException` exception will be thrown. :param name: Name of the input parameter to validate. :type name: string ...
[ "Decorator", ".", "Apply", "on", "a", ":", "class", ":", "wsgiservice", ".", "Resource", "or", "any", "of", "it", "s", "methods", "to", "validates", "a", "parameter", "on", "input", ".", "When", "a", "parameter", "does", "not", "validate", "a", ":", "c...
03c064ac2e8c53a1aac9c7b99970f23cf79e20f4
https://github.com/pneff/wsgiservice/blob/03c064ac2e8c53a1aac9c7b99970f23cf79e20f4/wsgiservice/decorators.py#L23-L48
train
Decorator to add validation methods to a resource or any of its sisers.
pneff/wsgiservice
wsgiservice/decorators.py
expires
def expires(duration, vary=None, currtime=time.time): """Decorator. Apply on a :class:`wsgiservice.Resource` method to set the max-age cache control parameter to the given duration. Also calculates the correct ``Expires`` response header. :param duration: Age which this resource may have before becomin...
python
def expires(duration, vary=None, currtime=time.time): """Decorator. Apply on a :class:`wsgiservice.Resource` method to set the max-age cache control parameter to the given duration. Also calculates the correct ``Expires`` response header. :param duration: Age which this resource may have before becomin...
[ "def", "expires", "(", "duration", ",", "vary", "=", "None", ",", "currtime", "=", "time", ".", "time", ")", ":", "if", "isinstance", "(", "duration", ",", "timedelta", ")", ":", "duration", "=", "timedelta_to_seconds", "(", "duration", ")", "@", "decora...
Decorator. Apply on a :class:`wsgiservice.Resource` method to set the max-age cache control parameter to the given duration. Also calculates the correct ``Expires`` response header. :param duration: Age which this resource may have before becoming stale. :type duration: :mod:`datetime.timedelta` :p...
[ "Decorator", ".", "Apply", "on", "a", ":", "class", ":", "wsgiservice", ".", "Resource", "method", "to", "set", "the", "max", "-", "age", "cache", "control", "parameter", "to", "the", "given", "duration", ".", "Also", "calculates", "the", "correct", "Expir...
03c064ac2e8c53a1aac9c7b99970f23cf79e20f4
https://github.com/pneff/wsgiservice/blob/03c064ac2e8c53a1aac9c7b99970f23cf79e20f4/wsgiservice/decorators.py#L51-L84
train
Decorator that applies on a resource method to set the expirations header to the given duration.
klichukb/django-migrate-sql
migrate_sql/autodetector.py
_sql_params
def _sql_params(sql): """ Identify `sql` as either SQL string or 2-tuple of SQL and params. Same format as supported by Django's RunSQL operation for sql/reverse_sql. """ params = None if isinstance(sql, (list, tuple)): elements = len(sql) if elements == 2: sql, param...
python
def _sql_params(sql): """ Identify `sql` as either SQL string or 2-tuple of SQL and params. Same format as supported by Django's RunSQL operation for sql/reverse_sql. """ params = None if isinstance(sql, (list, tuple)): elements = len(sql) if elements == 2: sql, param...
[ "def", "_sql_params", "(", "sql", ")", ":", "params", "=", "None", "if", "isinstance", "(", "sql", ",", "(", "list", ",", "tuple", ")", ")", ":", "elements", "=", "len", "(", "sql", ")", "if", "elements", "==", "2", ":", "sql", ",", "params", "="...
Identify `sql` as either SQL string or 2-tuple of SQL and params. Same format as supported by Django's RunSQL operation for sql/reverse_sql.
[ "Identify", "sql", "as", "either", "SQL", "string", "or", "2", "-", "tuple", "of", "SQL", "and", "params", ".", "Same", "format", "as", "supported", "by", "Django", "s", "RunSQL", "operation", "for", "sql", "/", "reverse_sql", "." ]
be48ff2c9283404e3d951128c459c3496d1ba25d
https://github.com/klichukb/django-migrate-sql/blob/be48ff2c9283404e3d951128c459c3496d1ba25d/migrate_sql/autodetector.py#L18-L30
train
Identify sql as either SQL string or 2 - tuple of SQL and params.
klichukb/django-migrate-sql
migrate_sql/autodetector.py
is_sql_equal
def is_sql_equal(sqls1, sqls2): """ Find out equality of two SQL items. See https://docs.djangoproject.com/en/1.8/ref/migration-operations/#runsql. Args: sqls1, sqls2: SQL items, have the same format as supported by Django's RunSQL operation. Returns: (bool) `True` if equal, otherwi...
python
def is_sql_equal(sqls1, sqls2): """ Find out equality of two SQL items. See https://docs.djangoproject.com/en/1.8/ref/migration-operations/#runsql. Args: sqls1, sqls2: SQL items, have the same format as supported by Django's RunSQL operation. Returns: (bool) `True` if equal, otherwi...
[ "def", "is_sql_equal", "(", "sqls1", ",", "sqls2", ")", ":", "is_seq1", "=", "isinstance", "(", "sqls1", ",", "(", "list", ",", "tuple", ")", ")", "is_seq2", "=", "isinstance", "(", "sqls2", ",", "(", "list", ",", "tuple", ")", ")", "if", "not", "i...
Find out equality of two SQL items. See https://docs.djangoproject.com/en/1.8/ref/migration-operations/#runsql. Args: sqls1, sqls2: SQL items, have the same format as supported by Django's RunSQL operation. Returns: (bool) `True` if equal, otherwise `False`.
[ "Find", "out", "equality", "of", "two", "SQL", "items", "." ]
be48ff2c9283404e3d951128c459c3496d1ba25d
https://github.com/klichukb/django-migrate-sql/blob/be48ff2c9283404e3d951128c459c3496d1ba25d/migrate_sql/autodetector.py#L33-L59
train
Returns True if the SQL items are equal.
klichukb/django-migrate-sql
migrate_sql/autodetector.py
MigrationAutodetector.assemble_changes
def assemble_changes(self, keys, resolve_keys, sql_state): """ Accepts keys of SQL items available, sorts them and adds additional dependencies. Uses graph of `sql_state` nodes to build `keys` and `resolve_keys` into sequence that starts with leaves (items that have not dependents) and e...
python
def assemble_changes(self, keys, resolve_keys, sql_state): """ Accepts keys of SQL items available, sorts them and adds additional dependencies. Uses graph of `sql_state` nodes to build `keys` and `resolve_keys` into sequence that starts with leaves (items that have not dependents) and e...
[ "def", "assemble_changes", "(", "self", ",", "keys", ",", "resolve_keys", ",", "sql_state", ")", ":", "result_keys", "=", "[", "]", "all_keys", "=", "keys", "|", "resolve_keys", "for", "key", "in", "all_keys", ":", "node", "=", "sql_state", ".", "node_map"...
Accepts keys of SQL items available, sorts them and adds additional dependencies. Uses graph of `sql_state` nodes to build `keys` and `resolve_keys` into sequence that starts with leaves (items that have not dependents) and ends with roots. Changes `resolve_keys` argument as dependencies are ad...
[ "Accepts", "keys", "of", "SQL", "items", "available", "sorts", "them", "and", "adds", "additional", "dependencies", ".", "Uses", "graph", "of", "sql_state", "nodes", "to", "build", "keys", "and", "resolve_keys", "into", "sequence", "that", "starts", "with", "l...
be48ff2c9283404e3d951128c459c3496d1ba25d
https://github.com/klichukb/django-migrate-sql/blob/be48ff2c9283404e3d951128c459c3496d1ba25d/migrate_sql/autodetector.py#L73-L108
train
Assemble changes for a set of items.
klichukb/django-migrate-sql
migrate_sql/autodetector.py
MigrationAutodetector.add_sql_operation
def add_sql_operation(self, app_label, sql_name, operation, dependencies): """ Add SQL operation and register it to be used as dependency for further sequential operations. """ deps = [(dp[0], SQL_BLOB, dp[1], self._sql_operations.get(dp)) for dp in dependencies] self.ad...
python
def add_sql_operation(self, app_label, sql_name, operation, dependencies): """ Add SQL operation and register it to be used as dependency for further sequential operations. """ deps = [(dp[0], SQL_BLOB, dp[1], self._sql_operations.get(dp)) for dp in dependencies] self.ad...
[ "def", "add_sql_operation", "(", "self", ",", "app_label", ",", "sql_name", ",", "operation", ",", "dependencies", ")", ":", "deps", "=", "[", "(", "dp", "[", "0", "]", ",", "SQL_BLOB", ",", "dp", "[", "1", "]", ",", "self", ".", "_sql_operations", "...
Add SQL operation and register it to be used as dependency for further sequential operations.
[ "Add", "SQL", "operation", "and", "register", "it", "to", "be", "used", "as", "dependency", "for", "further", "sequential", "operations", "." ]
be48ff2c9283404e3d951128c459c3496d1ba25d
https://github.com/klichukb/django-migrate-sql/blob/be48ff2c9283404e3d951128c459c3496d1ba25d/migrate_sql/autodetector.py#L110-L118
train
Add SQL operation and register it to be used as dependency for further sequential operations.
klichukb/django-migrate-sql
migrate_sql/autodetector.py
MigrationAutodetector._generate_reversed_sql
def _generate_reversed_sql(self, keys, changed_keys): """ Generate reversed operations for changes, that require full rollback and creation. """ for key in keys: if key not in changed_keys: continue app_label, sql_name = key old_item = ...
python
def _generate_reversed_sql(self, keys, changed_keys): """ Generate reversed operations for changes, that require full rollback and creation. """ for key in keys: if key not in changed_keys: continue app_label, sql_name = key old_item = ...
[ "def", "_generate_reversed_sql", "(", "self", ",", "keys", ",", "changed_keys", ")", ":", "for", "key", "in", "keys", ":", "if", "key", "not", "in", "changed_keys", ":", "continue", "app_label", ",", "sql_name", "=", "key", "old_item", "=", "self", ".", ...
Generate reversed operations for changes, that require full rollback and creation.
[ "Generate", "reversed", "operations", "for", "changes", "that", "require", "full", "rollback", "and", "creation", "." ]
be48ff2c9283404e3d951128c459c3496d1ba25d
https://github.com/klichukb/django-migrate-sql/blob/be48ff2c9283404e3d951128c459c3496d1ba25d/migrate_sql/autodetector.py#L120-L137
train
Generate reversed operations for changes that require full rollback and creation.
klichukb/django-migrate-sql
migrate_sql/autodetector.py
MigrationAutodetector._generate_sql
def _generate_sql(self, keys, changed_keys): """ Generate forward operations for changing/creating SQL items. """ for key in reversed(keys): app_label, sql_name = key new_item = self.to_sql_graph.nodes[key] sql_deps = [n.key for n in self.to_sql_graph....
python
def _generate_sql(self, keys, changed_keys): """ Generate forward operations for changing/creating SQL items. """ for key in reversed(keys): app_label, sql_name = key new_item = self.to_sql_graph.nodes[key] sql_deps = [n.key for n in self.to_sql_graph....
[ "def", "_generate_sql", "(", "self", ",", "keys", ",", "changed_keys", ")", ":", "for", "key", "in", "reversed", "(", "keys", ")", ":", "app_label", ",", "sql_name", "=", "key", "new_item", "=", "self", ".", "to_sql_graph", ".", "nodes", "[", "key", "]...
Generate forward operations for changing/creating SQL items.
[ "Generate", "forward", "operations", "for", "changing", "/", "creating", "SQL", "items", "." ]
be48ff2c9283404e3d951128c459c3496d1ba25d
https://github.com/klichukb/django-migrate-sql/blob/be48ff2c9283404e3d951128c459c3496d1ba25d/migrate_sql/autodetector.py#L139-L165
train
Generate SQL operations for changing or creating items.
klichukb/django-migrate-sql
migrate_sql/autodetector.py
MigrationAutodetector._generate_altered_sql_dependencies
def _generate_altered_sql_dependencies(self, dep_changed_keys): """ Generate forward operations for changing/creating SQL item dependencies. Dependencies are only in-memory and should be reflecting database dependencies, so changing them in SQL config does not alter database. Such actio...
python
def _generate_altered_sql_dependencies(self, dep_changed_keys): """ Generate forward operations for changing/creating SQL item dependencies. Dependencies are only in-memory and should be reflecting database dependencies, so changing them in SQL config does not alter database. Such actio...
[ "def", "_generate_altered_sql_dependencies", "(", "self", ",", "dep_changed_keys", ")", ":", "for", "key", ",", "removed_deps", ",", "added_deps", "in", "dep_changed_keys", ":", "app_label", ",", "sql_name", "=", "key", "operation", "=", "AlterSQLState", "(", "sql...
Generate forward operations for changing/creating SQL item dependencies. Dependencies are only in-memory and should be reflecting database dependencies, so changing them in SQL config does not alter database. Such actions are persisted in separate type operation - `AlterSQLState`. Args...
[ "Generate", "forward", "operations", "for", "changing", "/", "creating", "SQL", "item", "dependencies", "." ]
be48ff2c9283404e3d951128c459c3496d1ba25d
https://github.com/klichukb/django-migrate-sql/blob/be48ff2c9283404e3d951128c459c3496d1ba25d/migrate_sql/autodetector.py#L167-L184
train
Generates forward operations for changing or creating SQL item dependencies.
klichukb/django-migrate-sql
migrate_sql/autodetector.py
MigrationAutodetector._generate_delete_sql
def _generate_delete_sql(self, delete_keys): """ Generate forward delete operations for SQL items. """ for key in delete_keys: app_label, sql_name = key old_node = self.from_sql_graph.nodes[key] operation = DeleteSQL(sql_name, old_node.reverse_sql, rev...
python
def _generate_delete_sql(self, delete_keys): """ Generate forward delete operations for SQL items. """ for key in delete_keys: app_label, sql_name = key old_node = self.from_sql_graph.nodes[key] operation = DeleteSQL(sql_name, old_node.reverse_sql, rev...
[ "def", "_generate_delete_sql", "(", "self", ",", "delete_keys", ")", ":", "for", "key", "in", "delete_keys", ":", "app_label", ",", "sql_name", "=", "key", "old_node", "=", "self", ".", "from_sql_graph", ".", "nodes", "[", "key", "]", "operation", "=", "De...
Generate forward delete operations for SQL items.
[ "Generate", "forward", "delete", "operations", "for", "SQL", "items", "." ]
be48ff2c9283404e3d951128c459c3496d1ba25d
https://github.com/klichukb/django-migrate-sql/blob/be48ff2c9283404e3d951128c459c3496d1ba25d/migrate_sql/autodetector.py#L186-L196
train
Generate forward delete operations for SQL items.
klichukb/django-migrate-sql
migrate_sql/autodetector.py
MigrationAutodetector.generate_sql_changes
def generate_sql_changes(self): """ Starting point of this tool, which identifies changes and generates respective operations. """ from_keys = set(self.from_sql_graph.nodes.keys()) to_keys = set(self.to_sql_graph.nodes.keys()) new_keys = to_keys - from_keys ...
python
def generate_sql_changes(self): """ Starting point of this tool, which identifies changes and generates respective operations. """ from_keys = set(self.from_sql_graph.nodes.keys()) to_keys = set(self.to_sql_graph.nodes.keys()) new_keys = to_keys - from_keys ...
[ "def", "generate_sql_changes", "(", "self", ")", ":", "from_keys", "=", "set", "(", "self", ".", "from_sql_graph", ".", "nodes", ".", "keys", "(", ")", ")", "to_keys", "=", "set", "(", "self", ".", "to_sql_graph", ".", "nodes", ".", "keys", "(", ")", ...
Starting point of this tool, which identifies changes and generates respective operations.
[ "Starting", "point", "of", "this", "tool", "which", "identifies", "changes", "and", "generates", "respective", "operations", "." ]
be48ff2c9283404e3d951128c459c3496d1ba25d
https://github.com/klichukb/django-migrate-sql/blob/be48ff2c9283404e3d951128c459c3496d1ba25d/migrate_sql/autodetector.py#L198-L236
train
Generate the SQL changes for the current locale.
klichukb/django-migrate-sql
migrate_sql/autodetector.py
MigrationAutodetector.check_dependency
def check_dependency(self, operation, dependency): """ Enhances default behavior of method by checking dependency for matching operation. """ if isinstance(dependency[1], SQLBlob): # NOTE: we follow the sort order created by `assemble_changes` so we build a fixed chain ...
python
def check_dependency(self, operation, dependency): """ Enhances default behavior of method by checking dependency for matching operation. """ if isinstance(dependency[1], SQLBlob): # NOTE: we follow the sort order created by `assemble_changes` so we build a fixed chain ...
[ "def", "check_dependency", "(", "self", ",", "operation", ",", "dependency", ")", ":", "if", "isinstance", "(", "dependency", "[", "1", "]", ",", "SQLBlob", ")", ":", "# NOTE: we follow the sort order created by `assemble_changes` so we build a fixed chain", "# of operati...
Enhances default behavior of method by checking dependency for matching operation.
[ "Enhances", "default", "behavior", "of", "method", "by", "checking", "dependency", "for", "matching", "operation", "." ]
be48ff2c9283404e3d951128c459c3496d1ba25d
https://github.com/klichukb/django-migrate-sql/blob/be48ff2c9283404e3d951128c459c3496d1ba25d/migrate_sql/autodetector.py#L238-L246
train
Check if dependency for a migration operation is correct.
klichukb/django-migrate-sql
migrate_sql/autodetector.py
MigrationAutodetector.generate_altered_fields
def generate_altered_fields(self): """ Injecting point. This is quite awkward, and i'm looking forward Django for having the logic divided into smaller methods/functions for easier enhancement and substitution. So far we're doing all the SQL magic in this method. """ resu...
python
def generate_altered_fields(self): """ Injecting point. This is quite awkward, and i'm looking forward Django for having the logic divided into smaller methods/functions for easier enhancement and substitution. So far we're doing all the SQL magic in this method. """ resu...
[ "def", "generate_altered_fields", "(", "self", ")", ":", "result", "=", "super", "(", "MigrationAutodetector", ",", "self", ")", ".", "generate_altered_fields", "(", ")", "self", ".", "generate_sql_changes", "(", ")", "return", "result" ]
Injecting point. This is quite awkward, and i'm looking forward Django for having the logic divided into smaller methods/functions for easier enhancement and substitution. So far we're doing all the SQL magic in this method.
[ "Injecting", "point", ".", "This", "is", "quite", "awkward", "and", "i", "m", "looking", "forward", "Django", "for", "having", "the", "logic", "divided", "into", "smaller", "methods", "/", "functions", "for", "easier", "enhancement", "and", "substitution", "."...
be48ff2c9283404e3d951128c459c3496d1ba25d
https://github.com/klichukb/django-migrate-sql/blob/be48ff2c9283404e3d951128c459c3496d1ba25d/migrate_sql/autodetector.py#L248-L256
train
This method is used to generate the altered fields of the migration object.
skioo/django-customer-billing
billing/actions/credit_cards.py
reactivate
def reactivate(credit_card_id: str) -> None: """ Reactivates a credit card. """ logger.info('reactivating-credit-card', credit_card_id=credit_card_id) with transaction.atomic(): cc = CreditCard.objects.get(pk=credit_card_id) cc.reactivate() cc.save()
python
def reactivate(credit_card_id: str) -> None: """ Reactivates a credit card. """ logger.info('reactivating-credit-card', credit_card_id=credit_card_id) with transaction.atomic(): cc = CreditCard.objects.get(pk=credit_card_id) cc.reactivate() cc.save()
[ "def", "reactivate", "(", "credit_card_id", ":", "str", ")", "->", "None", ":", "logger", ".", "info", "(", "'reactivating-credit-card'", ",", "credit_card_id", "=", "credit_card_id", ")", "with", "transaction", ".", "atomic", "(", ")", ":", "cc", "=", "Cred...
Reactivates a credit card.
[ "Reactivates", "a", "credit", "card", "." ]
6ac1ed9ef9d1d7eee0379de7f0c4b76919ae1f2d
https://github.com/skioo/django-customer-billing/blob/6ac1ed9ef9d1d7eee0379de7f0c4b76919ae1f2d/billing/actions/credit_cards.py#L20-L28
train
Reactivates a credit card.
mgoral/subconvert
src/subconvert/parsing/Offset.py
TimeSync.sync
def sync(self, syncPointList): """Synchronise subtitles using a given list of SyncPoints.""" if len(syncPointList) == 0: return subsCopy = self._subs.clone() syncPointList.sort() SubAssert(syncPointList[0].subNo >= 0) SubAssert(syncPointList[0].subNo < sub...
python
def sync(self, syncPointList): """Synchronise subtitles using a given list of SyncPoints.""" if len(syncPointList) == 0: return subsCopy = self._subs.clone() syncPointList.sort() SubAssert(syncPointList[0].subNo >= 0) SubAssert(syncPointList[0].subNo < sub...
[ "def", "sync", "(", "self", ",", "syncPointList", ")", ":", "if", "len", "(", "syncPointList", ")", "==", "0", ":", "return", "subsCopy", "=", "self", ".", "_subs", ".", "clone", "(", ")", "syncPointList", ".", "sort", "(", ")", "SubAssert", "(", "sy...
Synchronise subtitles using a given list of SyncPoints.
[ "Synchronise", "subtitles", "using", "a", "given", "list", "of", "SyncPoints", "." ]
59701e5e69ef1ca26ce7d1d766c936664aa2cb32
https://github.com/mgoral/subconvert/blob/59701e5e69ef1ca26ce7d1d766c936664aa2cb32/src/subconvert/parsing/Offset.py#L60-L118
train
Synchronise subtitles using a given list of SyncPoints.
mgoral/subconvert
src/subconvert/parsing/Offset.py
TimeSync._getDeltas
def _getDeltas(self, firstSub, secondSub): """Arguments must have "start" and "end" properties which are FrameTimes.""" startDelta = max(firstSub.start, secondSub.start) - min(firstSub.start, secondSub.start) endDelta = max(firstSub.end, secondSub.end) - min(firstSub.end, secondSub.end) ...
python
def _getDeltas(self, firstSub, secondSub): """Arguments must have "start" and "end" properties which are FrameTimes.""" startDelta = max(firstSub.start, secondSub.start) - min(firstSub.start, secondSub.start) endDelta = max(firstSub.end, secondSub.end) - min(firstSub.end, secondSub.end) ...
[ "def", "_getDeltas", "(", "self", ",", "firstSub", ",", "secondSub", ")", ":", "startDelta", "=", "max", "(", "firstSub", ".", "start", ",", "secondSub", ".", "start", ")", "-", "min", "(", "firstSub", ".", "start", ",", "secondSub", ".", "start", ")",...
Arguments must have "start" and "end" properties which are FrameTimes.
[ "Arguments", "must", "have", "start", "and", "end", "properties", "which", "are", "FrameTimes", "." ]
59701e5e69ef1ca26ce7d1d766c936664aa2cb32
https://github.com/mgoral/subconvert/blob/59701e5e69ef1ca26ce7d1d766c936664aa2cb32/src/subconvert/parsing/Offset.py#L120-L124
train
Get the delta between two FrameTimes objects.
mgoral/subconvert
src/subconvert/parsing/Offset.py
TimeSync._getLowestSyncPoint
def _getLowestSyncPoint(self, syncPointList, subs): """Get the lowest possible sync point. If it is not the first one on the **sorted** syncPointList, first subtitle will be converted to the one.""" if syncPointList[0].subNo == 0: return syncPointList[0] return SyncPoint(0, s...
python
def _getLowestSyncPoint(self, syncPointList, subs): """Get the lowest possible sync point. If it is not the first one on the **sorted** syncPointList, first subtitle will be converted to the one.""" if syncPointList[0].subNo == 0: return syncPointList[0] return SyncPoint(0, s...
[ "def", "_getLowestSyncPoint", "(", "self", ",", "syncPointList", ",", "subs", ")", ":", "if", "syncPointList", "[", "0", "]", ".", "subNo", "==", "0", ":", "return", "syncPointList", "[", "0", "]", "return", "SyncPoint", "(", "0", ",", "subs", "[", "0"...
Get the lowest possible sync point. If it is not the first one on the **sorted** syncPointList, first subtitle will be converted to the one.
[ "Get", "the", "lowest", "possible", "sync", "point", ".", "If", "it", "is", "not", "the", "first", "one", "on", "the", "**", "sorted", "**", "syncPointList", "first", "subtitle", "will", "be", "converted", "to", "the", "one", "." ]
59701e5e69ef1ca26ce7d1d766c936664aa2cb32
https://github.com/mgoral/subconvert/blob/59701e5e69ef1ca26ce7d1d766c936664aa2cb32/src/subconvert/parsing/Offset.py#L143-L148
train
Get the lowest possible sync point.
PythonOptimizers/cygenja
cygenja/treemap/treemap.py
TreeMap._get_location_descriptor
def _get_location_descriptor(self, location): """ Get corresponding :class:`LocationDescriptor` object from a string or a :class:`LocationDescriptor` itself. Args: location: a string or a :class:`LocationDescriptor`. Returns: A corresponding :cla...
python
def _get_location_descriptor(self, location): """ Get corresponding :class:`LocationDescriptor` object from a string or a :class:`LocationDescriptor` itself. Args: location: a string or a :class:`LocationDescriptor`. Returns: A corresponding :cla...
[ "def", "_get_location_descriptor", "(", "self", ",", "location", ")", ":", "loc_descriptor", "=", "None", "if", "isinstance", "(", "location", ",", "basestring", ")", ":", "loc_descriptor", "=", "LocationDescriptor", "(", "location", ")", "elif", "isinstance", "...
Get corresponding :class:`LocationDescriptor` object from a string or a :class:`LocationDescriptor` itself. Args: location: a string or a :class:`LocationDescriptor`. Returns: A corresponding :class:`LocationDescriptor` object. If ``location`` is a :class:`Locat...
[ "Get", "corresponding", ":", "class", ":", "LocationDescriptor", "object", "from", "a", "string", "or", "a", ":", "class", ":", "LocationDescriptor", "itself", ".", "Args", ":", "location", ":", "a", "string", "or", "a", ":", "class", ":", "LocationDescripto...
a9ef91cdfa8452beeeec4f050f928b830379f91c
https://github.com/PythonOptimizers/cygenja/blob/a9ef91cdfa8452beeeec4f050f928b830379f91c/cygenja/treemap/treemap.py#L58-L80
train
Returns a corresponding LocationDescriptor object from a string or a LocationDescriptor itself.
PythonOptimizers/cygenja
cygenja/treemap/treemap.py
TreeMap._get_node
def _get_node(self, loc_descriptor, create_non_existing_nodes=False): """ Get node corresponding to last location in a :class:`LocationDescriptor` object. Args: loc_descriptor: A :class:`LocationDescriptor` object create_non_existing_nodes (bool): Do we create n...
python
def _get_node(self, loc_descriptor, create_non_existing_nodes=False): """ Get node corresponding to last location in a :class:`LocationDescriptor` object. Args: loc_descriptor: A :class:`LocationDescriptor` object create_non_existing_nodes (bool): Do we create n...
[ "def", "_get_node", "(", "self", ",", "loc_descriptor", ",", "create_non_existing_nodes", "=", "False", ")", ":", "node", "=", "self", ".", "_root_node", "for", "location", "in", "loc_descriptor", ".", "generate_all_sub_locations", "(", ")", ":", "child", "=", ...
Get node corresponding to last location in a :class:`LocationDescriptor` object. Args: loc_descriptor: A :class:`LocationDescriptor` object create_non_existing_nodes (bool): Do we create non existing nodes along the way (including last node)? Raises: ...
[ "Get", "node", "corresponding", "to", "last", "location", "in", "a", ":", "class", ":", "LocationDescriptor", "object", ".", "Args", ":", "loc_descriptor", ":", "A", ":", "class", ":", "LocationDescriptor", "object", "create_non_existing_nodes", "(", "bool", ")"...
a9ef91cdfa8452beeeec4f050f928b830379f91c
https://github.com/PythonOptimizers/cygenja/blob/a9ef91cdfa8452beeeec4f050f928b830379f91c/cygenja/treemap/treemap.py#L82-L109
train
Returns a node corresponding to the last location in a LocationDescriptor object.
PythonOptimizers/cygenja
cygenja/treemap/treemap.py
TreeMap._create_entry
def _create_entry(self, location, element, unique=True, delete_element=False): """ Create an entry located at ``location``. Args: location: String or :class:`LocationDescriptor` to describe a "separator location" (i.e. dir1/dir2/dir3 for instance). ...
python
def _create_entry(self, location, element, unique=True, delete_element=False): """ Create an entry located at ``location``. Args: location: String or :class:`LocationDescriptor` to describe a "separator location" (i.e. dir1/dir2/dir3 for instance). ...
[ "def", "_create_entry", "(", "self", ",", "location", ",", "element", ",", "unique", "=", "True", ",", "delete_element", "=", "False", ")", ":", "loc_descriptor", "=", "self", ".", "_get_location_descriptor", "(", "location", ")", "# find parent node", "parent_n...
Create an entry located at ``location``. Args: location: String or :class:`LocationDescriptor` to describe a "separator location" (i.e. dir1/dir2/dir3 for instance). element: Element to store at the location. unique: ``True`` means that the element to...
[ "Create", "an", "entry", "located", "at", "location", ".", "Args", ":", "location", ":", "String", "or", ":", "class", ":", "LocationDescriptor", "to", "describe", "a", "separator", "location", "(", "i", ".", "e", ".", "dir1", "/", "dir2", "/", "dir3", ...
a9ef91cdfa8452beeeec4f050f928b830379f91c
https://github.com/PythonOptimizers/cygenja/blob/a9ef91cdfa8452beeeec4f050f928b830379f91c/cygenja/treemap/treemap.py#L111-L155
train
Internal method to create an entry in the tree.
PythonOptimizers/cygenja
cygenja/treemap/treemap.py
TreeMap.add_unique_element
def add_unique_element(self, location, element): """ Create an entry located at ``location``. Args: location: String or :class:`LocationDescriptor` to describe a "separator location" (i.e. dir1/dir2/dir3 for instance). element: Element to store. ...
python
def add_unique_element(self, location, element): """ Create an entry located at ``location``. Args: location: String or :class:`LocationDescriptor` to describe a "separator location" (i.e. dir1/dir2/dir3 for instance). element: Element to store. ...
[ "def", "add_unique_element", "(", "self", ",", "location", ",", "element", ")", ":", "return", "self", ".", "_create_entry", "(", "location", ",", "element", ",", "unique", "=", "True", ")" ]
Create an entry located at ``location``. Args: location: String or :class:`LocationDescriptor` to describe a "separator location" (i.e. dir1/dir2/dir3 for instance). element: Element to store. Returns: The created node with the elemen...
[ "Create", "an", "entry", "located", "at", "location", ".", "Args", ":", "location", ":", "String", "or", ":", "class", ":", "LocationDescriptor", "to", "describe", "a", "separator", "location", "(", "i", ".", "e", ".", "dir1", "/", "dir2", "/", "dir3", ...
a9ef91cdfa8452beeeec4f050f928b830379f91c
https://github.com/PythonOptimizers/cygenja/blob/a9ef91cdfa8452beeeec4f050f928b830379f91c/cygenja/treemap/treemap.py#L185-L201
train
Create an entry located at location and add an element to the cache.
PythonOptimizers/cygenja
cygenja/treemap/treemap.py
TreeMap.add_element
def add_element(self, location, element, delete_elem=False): """ Create an entry located at ``location``. Args: location: String or :class:`LocationDescriptor` to describe a "separator location" (i.e. dir1/dir2/dir3 for instance). element: Element...
python
def add_element(self, location, element, delete_elem=False): """ Create an entry located at ``location``. Args: location: String or :class:`LocationDescriptor` to describe a "separator location" (i.e. dir1/dir2/dir3 for instance). element: Element...
[ "def", "add_element", "(", "self", ",", "location", ",", "element", ",", "delete_elem", "=", "False", ")", ":", "return", "self", ".", "_create_entry", "(", "location", ",", "element", ",", "unique", "=", "False", ",", "delete_element", "=", "delete_elem", ...
Create an entry located at ``location``. Args: location: String or :class:`LocationDescriptor` to describe a "separator location" (i.e. dir1/dir2/dir3 for instance). element: Element to store. delete_elem: Delete old element or not if it exist? ...
[ "Create", "an", "entry", "located", "at", "location", ".", "Args", ":", "location", ":", "String", "or", ":", "class", ":", "LocationDescriptor", "to", "describe", "a", "separator", "location", "(", "i", ".", "e", ".", "dir1", "/", "dir2", "/", "dir3", ...
a9ef91cdfa8452beeeec4f050f928b830379f91c
https://github.com/PythonOptimizers/cygenja/blob/a9ef91cdfa8452beeeec4f050f928b830379f91c/cygenja/treemap/treemap.py#L203-L222
train
Create an entry located at location.
PythonOptimizers/cygenja
cygenja/treemap/treemap.py
TreeMap.retrieve_element
def retrieve_element(self, location): """ Args: location: Returns: """ loc_descriptor = self._get_location_descriptor(location) # find node node = self._get_node(loc_descriptor) return node.get_element()
python
def retrieve_element(self, location): """ Args: location: Returns: """ loc_descriptor = self._get_location_descriptor(location) # find node node = self._get_node(loc_descriptor) return node.get_element()
[ "def", "retrieve_element", "(", "self", ",", "location", ")", ":", "loc_descriptor", "=", "self", ".", "_get_location_descriptor", "(", "location", ")", "# find node", "node", "=", "self", ".", "_get_node", "(", "loc_descriptor", ")", "return", "node", ".", "g...
Args: location: Returns:
[ "Args", ":", "location", ":", "Returns", ":" ]
a9ef91cdfa8452beeeec4f050f928b830379f91c
https://github.com/PythonOptimizers/cygenja/blob/a9ef91cdfa8452beeeec4f050f928b830379f91c/cygenja/treemap/treemap.py#L224-L235
train
Retrieves the element from the node identified by location.
PythonOptimizers/cygenja
cygenja/treemap/treemap.py
TreeMap.retrieve_element_or_default
def retrieve_element_or_default(self, location, default=None): """ Args: location: default: Returns: """ loc_descriptor = self._get_location_descriptor(location) # find node node = None try: node = sel...
python
def retrieve_element_or_default(self, location, default=None): """ Args: location: default: Returns: """ loc_descriptor = self._get_location_descriptor(location) # find node node = None try: node = sel...
[ "def", "retrieve_element_or_default", "(", "self", ",", "location", ",", "default", "=", "None", ")", ":", "loc_descriptor", "=", "self", ".", "_get_location_descriptor", "(", "location", ")", "# find node", "node", "=", "None", "try", ":", "node", "=", "self"...
Args: location: default: Returns:
[ "Args", ":", "location", ":", "default", ":", "Returns", ":" ]
a9ef91cdfa8452beeeec4f050f928b830379f91c
https://github.com/PythonOptimizers/cygenja/blob/a9ef91cdfa8452beeeec4f050f928b830379f91c/cygenja/treemap/treemap.py#L237-L254
train
Retrieve an element from the node with the specified location or return the default if it s not found.
ludeeus/GHLocalApi
ghlocalapi/scan.py
NetworkScan.scan_for_units
async def scan_for_units(self, iprange): """Scan local network for GH units.""" units = [] for ip_address in ipaddress.IPv4Network(iprange): sock = socket.socket() sock.settimeout(0.02) host = str(ip_address) try: scan_result = sock...
python
async def scan_for_units(self, iprange): """Scan local network for GH units.""" units = [] for ip_address in ipaddress.IPv4Network(iprange): sock = socket.socket() sock.settimeout(0.02) host = str(ip_address) try: scan_result = sock...
[ "async", "def", "scan_for_units", "(", "self", ",", "iprange", ")", ":", "units", "=", "[", "]", "for", "ip_address", "in", "ipaddress", ".", "IPv4Network", "(", "iprange", ")", ":", "sock", "=", "socket", ".", "socket", "(", ")", "sock", ".", "settime...
Scan local network for GH units.
[ "Scan", "local", "network", "for", "GH", "units", "." ]
93abdee299c4a4b65aa9dd03c77ec34e174e3c56
https://github.com/ludeeus/GHLocalApi/blob/93abdee299c4a4b65aa9dd03c77ec34e174e3c56/ghlocalapi/scan.py#L24-L51
train
Scan local network for GH units.
ludeeus/GHLocalApi
examples/bluetooth_scan_unit.py
bluetooth_scan
async def bluetooth_scan(): """Get nearby bluetooth devices.""" async with aiohttp.ClientSession() as session: ghlocalapi = Bluetooth(LOOP, session, IPADDRESS) await ghlocalapi.scan_for_devices() # Start device scan await ghlocalapi.get_scan_result() # Returns the result print...
python
async def bluetooth_scan(): """Get nearby bluetooth devices.""" async with aiohttp.ClientSession() as session: ghlocalapi = Bluetooth(LOOP, session, IPADDRESS) await ghlocalapi.scan_for_devices() # Start device scan await ghlocalapi.get_scan_result() # Returns the result print...
[ "async", "def", "bluetooth_scan", "(", ")", ":", "async", "with", "aiohttp", ".", "ClientSession", "(", ")", "as", "session", ":", "ghlocalapi", "=", "Bluetooth", "(", "LOOP", ",", "session", ",", "IPADDRESS", ")", "await", "ghlocalapi", ".", "scan_for_devic...
Get nearby bluetooth devices.
[ "Get", "nearby", "bluetooth", "devices", "." ]
93abdee299c4a4b65aa9dd03c77ec34e174e3c56
https://github.com/ludeeus/GHLocalApi/blob/93abdee299c4a4b65aa9dd03c77ec34e174e3c56/examples/bluetooth_scan_unit.py#L9-L16
train
Get nearby bluetooth devices.
romanorac/discomll
discomll/classification/naivebayes.py
map_fit
def map_fit(interface, state, label, inp): """ Function counts occurrences of feature values for every row in given data chunk. For continuous features it returns number of values and it calculates mean and variance for every feature. For discrete features it counts occurrences of labels and values for ...
python
def map_fit(interface, state, label, inp): """ Function counts occurrences of feature values for every row in given data chunk. For continuous features it returns number of values and it calculates mean and variance for every feature. For discrete features it counts occurrences of labels and values for ...
[ "def", "map_fit", "(", "interface", ",", "state", ",", "label", ",", "inp", ")", ":", "import", "numpy", "as", "np", "combiner", "=", "{", "}", "# combiner used for joining of intermediate pairs", "out", "=", "interface", ".", "output", "(", "0", ")", "# all...
Function counts occurrences of feature values for every row in given data chunk. For continuous features it returns number of values and it calculates mean and variance for every feature. For discrete features it counts occurrences of labels and values for every feature. It returns occurrences of pairs: lab...
[ "Function", "counts", "occurrences", "of", "feature", "values", "for", "every", "row", "in", "given", "data", "chunk", ".", "For", "continuous", "features", "it", "returns", "number", "of", "values", "and", "it", "calculates", "mean", "and", "variance", "for",...
a4703daffb2ba3c9f614bc3dbe45ae55884aea00
https://github.com/romanorac/discomll/blob/a4703daffb2ba3c9f614bc3dbe45ae55884aea00/discomll/classification/naivebayes.py#L17-L57
train
Function that calculates the mean and variance of every feature in a data chunk. It returns the number of elements and the variance of the feature in each row in inp.
romanorac/discomll
discomll/classification/naivebayes.py
reduce_fit
def reduce_fit(interface, state, label, inp): """ Function separates aggregation of continuous and discrete features. For continuous features it aggregates partially calculated means and variances and returns them. For discrete features it aggregates pairs and returns them. Pairs with label occurrences ...
python
def reduce_fit(interface, state, label, inp): """ Function separates aggregation of continuous and discrete features. For continuous features it aggregates partially calculated means and variances and returns them. For discrete features it aggregates pairs and returns them. Pairs with label occurrences ...
[ "def", "reduce_fit", "(", "interface", ",", "state", ",", "label", ",", "inp", ")", ":", "from", "disco", ".", "util", "import", "kvgroup", "# function for grouping values by key", "import", "numpy", "as", "np", "out", "=", "interface", ".", "output", "(", "...
Function separates aggregation of continuous and discrete features. For continuous features it aggregates partially calculated means and variances and returns them. For discrete features it aggregates pairs and returns them. Pairs with label occurrences are used to calculate prior probabilities
[ "Function", "separates", "aggregation", "of", "continuous", "and", "discrete", "features", ".", "For", "continuous", "features", "it", "aggregates", "partially", "calculated", "means", "and", "variances", "and", "returns", "them", ".", "For", "discrete", "features",...
a4703daffb2ba3c9f614bc3dbe45ae55884aea00
https://github.com/romanorac/discomll/blob/a4703daffb2ba3c9f614bc3dbe45ae55884aea00/discomll/classification/naivebayes.py#L60-L128
train
Function that calculates the mean and variance of a single node in a naive Bayes dataset.