repo
stringlengths
7
55
path
stringlengths
4
223
url
stringlengths
87
315
code
stringlengths
75
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
avg_line_len
float64
7.91
980
saltstack/salt
salt/modules/win_status.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_status.py#L506-L589
def master(master=None, connected=True): ''' .. versionadded:: 2015.5.0 Fire an event if the minion gets disconnected from its master. This function is meant to be run via a scheduled job from the minion. If master_ip is an FQDN/Hostname, is must be resolvable to a valid IPv4 address. CLI ...
[ "def", "master", "(", "master", "=", "None", ",", "connected", "=", "True", ")", ":", "def", "_win_remotes_on", "(", "port", ")", ":", "'''\n Windows specific helper function.\n Returns set of ipv4 host addresses of remote established connections\n on local o...
.. versionadded:: 2015.5.0 Fire an event if the minion gets disconnected from its master. This function is meant to be run via a scheduled job from the minion. If master_ip is an FQDN/Hostname, is must be resolvable to a valid IPv4 address. CLI Example: .. code-block:: bash salt '*' ...
[ "..", "versionadded", "::", "2015", ".", "5", ".", "0" ]
python
train
32.452381
ausaki/subfinder
subfinder/subsearcher/subsearcher.py
https://github.com/ausaki/subfinder/blob/b74b79214f618c603a551b9334ebb110ccf9684c/subfinder/subsearcher/subsearcher.py#L111-L173
def _parse_videoname(cls, videoname): """ parse videoname and return video info dict video info contains: - title, the name of video - sub_title, the sub_title of video - resolution, - source, - - season, defaults to 0 - episode, defaults to 0 ...
[ "def", "_parse_videoname", "(", "cls", ",", "videoname", ")", ":", "info", "=", "{", "'title'", ":", "''", ",", "'season'", ":", "0", ",", "'episode'", ":", "0", ",", "'sub_title'", ":", "''", ",", "'resolution'", ":", "''", ",", "'source'", ":", "''...
parse videoname and return video info dict video info contains: - title, the name of video - sub_title, the sub_title of video - resolution, - source, - - season, defaults to 0 - episode, defaults to 0
[ "parse", "videoname", "and", "return", "video", "info", "dict", "video", "info", "contains", ":", "-", "title", "the", "name", "of", "video", "-", "sub_title", "the", "sub_title", "of", "video", "-", "resolution", "-", "source", "-", "-", "season", "defaul...
python
train
30.587302
gmr/helper
helper/setupext.py
https://github.com/gmr/helper/blob/fe8e45fc8eabf619429b2940c682c252ee33c082/helper/setupext.py#L50-L70
def run(self): """Import the controller and run it. This mimics the processing done by :func:`helper.start` when a controller is run in the foreground. A new instance of ``self.controller`` is created and run until a keyboard interrupt occurs or the controller stops on its own ...
[ "def", "run", "(", "self", ")", ":", "segments", "=", "self", ".", "controller", ".", "split", "(", "'.'", ")", "controller_class", "=", "reduce", "(", "getattr", ",", "segments", "[", "1", ":", "]", ",", "__import__", "(", "'.'", ".", "join", "(", ...
Import the controller and run it. This mimics the processing done by :func:`helper.start` when a controller is run in the foreground. A new instance of ``self.controller`` is created and run until a keyboard interrupt occurs or the controller stops on its own accord.
[ "Import", "the", "controller", "and", "run", "it", "." ]
python
train
40.809524
raphaelvallat/pingouin
pingouin/pandas.py
https://github.com/raphaelvallat/pingouin/blob/58b19fa4fffbfe09d58b456e3926a148249e4d9b/pingouin/pandas.py#L29-L33
def _welch_anova(self, dv=None, between=None, export_filename=None): """Return one-way Welch ANOVA.""" aov = welch_anova(data=self, dv=dv, between=between, export_filename=export_filename) return aov
[ "def", "_welch_anova", "(", "self", ",", "dv", "=", "None", ",", "between", "=", "None", ",", "export_filename", "=", "None", ")", ":", "aov", "=", "welch_anova", "(", "data", "=", "self", ",", "dv", "=", "dv", ",", "between", "=", "between", ",", ...
Return one-way Welch ANOVA.
[ "Return", "one", "-", "way", "Welch", "ANOVA", "." ]
python
train
45.8
cisco-sas/kitty
kitty/fuzzers/base.py
https://github.com/cisco-sas/kitty/blob/cb0760989dcdfe079e43ac574d872d0b18953a32/kitty/fuzzers/base.py#L398-L406
def handle_stage_changed(self, model): ''' handle a stage change in the data model :param model: the data model that was changed ''' stages = model.get_stages() if self.dataman: self.dataman.set('stages', stages)
[ "def", "handle_stage_changed", "(", "self", ",", "model", ")", ":", "stages", "=", "model", ".", "get_stages", "(", ")", "if", "self", ".", "dataman", ":", "self", ".", "dataman", ".", "set", "(", "'stages'", ",", "stages", ")" ]
handle a stage change in the data model :param model: the data model that was changed
[ "handle", "a", "stage", "change", "in", "the", "data", "model" ]
python
train
29.444444
Stewori/pytypes
pytypes/type_util.py
https://github.com/Stewori/pytypes/blob/b814d38709e84c0e0825caf8b721c20eb5a8ab3b/pytypes/type_util.py#L173-L201
def get_Generic_itemtype(sq, simplify=True): """Retrieves the item type from a PEP 484 generic or subclass of such. sq must be a typing.Tuple or (subclass of) typing.Iterable or typing.Container. Consequently this also works with typing.List, typing.Set and typing.Dict. Note that for typing.Dict and map...
[ "def", "get_Generic_itemtype", "(", "sq", ",", "simplify", "=", "True", ")", ":", "if", "is_Tuple", "(", "sq", ")", ":", "if", "simplify", ":", "itm_tps", "=", "[", "x", "for", "x", "in", "get_Tuple_params", "(", "sq", ")", "]", "simplify_for_Union", "...
Retrieves the item type from a PEP 484 generic or subclass of such. sq must be a typing.Tuple or (subclass of) typing.Iterable or typing.Container. Consequently this also works with typing.List, typing.Set and typing.Dict. Note that for typing.Dict and mapping types in general, the key type is regarded as i...
[ "Retrieves", "the", "item", "type", "from", "a", "PEP", "484", "generic", "or", "subclass", "of", "such", ".", "sq", "must", "be", "a", "typing", ".", "Tuple", "or", "(", "subclass", "of", ")", "typing", ".", "Iterable", "or", "typing", ".", "Container...
python
train
41.758621
saltstack/salt
salt/modules/boto_elbv2.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_elbv2.py#L417-L482
def describe_target_groups(names=None, target_group_arns=None, load_balancer_arn=None, region=None, key=None, keyid=None, profile=None): ''' Describes...
[ "def", "describe_target_groups", "(", "names", "=", "None", ",", "target_group_arns", "=", "None", ",", "load_balancer_arn", "=", "None", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":...
Describes the specified target groups or all of your target groups. By default, all target groups are described. Alternatively, you can specify one of the following to filter the results: the ARN of the load balancer, the names of one or more target groups, or the ARNs of one or more target groups. Ret...
[ "Describes", "the", "specified", "target", "groups", "or", "all", "of", "your", "target", "groups", ".", "By", "default", "all", "target", "groups", "are", "described", ".", "Alternatively", "you", "can", "specify", "one", "of", "the", "following", "to", "fi...
python
train
35.393939
vlukes/dicom2fem
dicom2fem/mesh.py
https://github.com/vlukes/dicom2fem/blob/3056c977ca7119e01984d3aa0c4448a1c6c2430f/dicom2fem/mesh.py#L153-L185
def get_min_vertex_distance( coor, guess ): """Can miss the minimum, but is enough for our purposes.""" # Sort by x. ix = nm.argsort( coor[:,0] ) scoor = coor[ix] mvd = 1e16 # Get mvd in chunks potentially smaller than guess. n_coor = coor.shape[0] print n_coor i0 = i1 = 0...
[ "def", "get_min_vertex_distance", "(", "coor", ",", "guess", ")", ":", "# Sort by x.", "ix", "=", "nm", ".", "argsort", "(", "coor", "[", ":", ",", "0", "]", ")", "scoor", "=", "coor", "[", "ix", "]", "mvd", "=", "1e16", "# Get mvd in chunks potentially ...
Can miss the minimum, but is enough for our purposes.
[ "Can", "miss", "the", "minimum", "but", "is", "enough", "for", "our", "purposes", "." ]
python
train
25.787879
globocom/GloboNetworkAPI-client-python
networkapiclient/ApiEquipment.py
https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiEquipment.py#L46-L59
def search(self, **kwargs): """ Method to search equipments based on extends search. :param search: Dict containing QuerySets to find equipments. :param include: Array containing fields to include on response. :param exclude: Array containing fields to exclude on response. ...
[ "def", "search", "(", "self", ",", "*", "*", "kwargs", ")", ":", "return", "super", "(", "ApiEquipment", ",", "self", ")", ".", "get", "(", "self", ".", "prepare_url", "(", "'api/v3/equipment/'", ",", "kwargs", ")", ")" ]
Method to search equipments based on extends search. :param search: Dict containing QuerySets to find equipments. :param include: Array containing fields to include on response. :param exclude: Array containing fields to exclude on response. :param fields: Array containing fields to ov...
[ "Method", "to", "search", "equipments", "based", "on", "extends", "search", "." ]
python
train
48.357143
sassoo/goldman
goldman/queryparams/fields.py
https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/queryparams/fields.py#L24-L50
def _parse_param(key, val): """ Parse the query param looking for sparse fields params Ensure the `val` or what will become the sparse fields is always an array. If the query param is not a sparse fields query param then return None. :param key: the query parameter key in the request (left...
[ "def", "_parse_param", "(", "key", ",", "val", ")", ":", "regex", "=", "re", ".", "compile", "(", "r'fields\\[([A-Za-z]+)\\]'", ")", "match", "=", "regex", ".", "match", "(", "key", ")", "if", "match", ":", "if", "not", "isinstance", "(", "val", ",", ...
Parse the query param looking for sparse fields params Ensure the `val` or what will become the sparse fields is always an array. If the query param is not a sparse fields query param then return None. :param key: the query parameter key in the request (left of =) :param val: the q...
[ "Parse", "the", "query", "param", "looking", "for", "sparse", "fields", "params" ]
python
train
29
mapbox/rio-mucho
examples/simple_read.py
https://github.com/mapbox/rio-mucho/blob/b2267bda2a7ac8557c9328742aeaab6adc825315/examples/simple_read.py#L7-L10
def read_function(data, window, ij, g_args): """Takes an array, and sets any value above the mean to the max, the rest to 0""" output = (data[0] > numpy.mean(data[0])).astype(data[0].dtype) * data[0].max() return output
[ "def", "read_function", "(", "data", ",", "window", ",", "ij", ",", "g_args", ")", ":", "output", "=", "(", "data", "[", "0", "]", ">", "numpy", ".", "mean", "(", "data", "[", "0", "]", ")", ")", ".", "astype", "(", "data", "[", "0", "]", "."...
Takes an array, and sets any value above the mean to the max, the rest to 0
[ "Takes", "an", "array", "and", "sets", "any", "value", "above", "the", "mean", "to", "the", "max", "the", "rest", "to", "0" ]
python
train
57
apache/airflow
airflow/www/utils.py
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/www/utils.py#L193-L201
def json_response(obj): """ returns a json response from a json serializable python object """ return Response( response=json.dumps( obj, indent=4, cls=AirflowJsonEncoder), status=200, mimetype="application/json")
[ "def", "json_response", "(", "obj", ")", ":", "return", "Response", "(", "response", "=", "json", ".", "dumps", "(", "obj", ",", "indent", "=", "4", ",", "cls", "=", "AirflowJsonEncoder", ")", ",", "status", "=", "200", ",", "mimetype", "=", "\"applica...
returns a json response from a json serializable python object
[ "returns", "a", "json", "response", "from", "a", "json", "serializable", "python", "object" ]
python
test
28.555556
bcbio/bcbio-nextgen
bcbio/variation/multi.py
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/multi.py#L106-L133
def _group_batches_shared(xs, caller_batch_fn, prep_data_fn): """Shared functionality for grouping by batches for variant calling and joint calling. """ singles = [] batch_groups = collections.defaultdict(list) for args in xs: data = utils.to_single_data(args) caller, batch = caller_...
[ "def", "_group_batches_shared", "(", "xs", ",", "caller_batch_fn", ",", "prep_data_fn", ")", ":", "singles", "=", "[", "]", "batch_groups", "=", "collections", ".", "defaultdict", "(", "list", ")", "for", "args", "in", "xs", ":", "data", "=", "utils", ".",...
Shared functionality for grouping by batches for variant calling and joint calling.
[ "Shared", "functionality", "for", "grouping", "by", "batches", "for", "variant", "calling", "and", "joint", "calling", "." ]
python
train
45.071429
Shizmob/pydle
pydle/features/ircv3/cap.py
https://github.com/Shizmob/pydle/blob/7ec7d65d097318ed0bcdc5d8401470287d8c7cf7/pydle/features/ircv3/cap.py#L65-L75
async def on_raw_cap(self, message): """ Handle CAP message. """ target, subcommand = message.params[:2] params = message.params[2:] # Call handler. attr = 'on_raw_cap_' + pydle.protocol.identifierify(subcommand) if hasattr(self, attr): await getattr(self, at...
[ "async", "def", "on_raw_cap", "(", "self", ",", "message", ")", ":", "target", ",", "subcommand", "=", "message", ".", "params", "[", ":", "2", "]", "params", "=", "message", ".", "params", "[", "2", ":", "]", "# Call handler.", "attr", "=", "'on_raw_c...
Handle CAP message.
[ "Handle", "CAP", "message", "." ]
python
train
38.727273
jjkester/django-auditlog
src/auditlog/compat.py
https://github.com/jjkester/django-auditlog/blob/a22978e05b7ed43b87e4b6109550b86c738578fe/src/auditlog/compat.py#L3-L20
def is_authenticated(user): """Return whether or not a User is authenticated. Function provides compatibility following deprecation of method call to `is_authenticated()` in Django 2.0. This is *only* required to support Django < v1.10 (i.e. v1.9 and earlier), as `is_authenticated` was introduced ...
[ "def", "is_authenticated", "(", "user", ")", ":", "if", "not", "hasattr", "(", "user", ",", "'is_authenticated'", ")", ":", "return", "False", "if", "callable", "(", "user", ".", "is_authenticated", ")", ":", "# Will be callable if django.version < 2.0, but is only ...
Return whether or not a User is authenticated. Function provides compatibility following deprecation of method call to `is_authenticated()` in Django 2.0. This is *only* required to support Django < v1.10 (i.e. v1.9 and earlier), as `is_authenticated` was introduced as a property in v1.10.s
[ "Return", "whether", "or", "not", "a", "User", "is", "authenticated", "." ]
python
train
40.833333
chriskiehl/Gooey
gooey/gui/containers/application.py
https://github.com/chriskiehl/Gooey/blob/e598573c6519b953e0ccfc1f3663f827f8cd7e22/gooey/gui/containers/application.py#L189-L199
def buildNavigation(self): """ Chooses the appropriate layout navigation component based on user prefs """ if self.buildSpec['navigation'] == constants.TABBED: navigation = Tabbar(self, self.buildSpec, self.configs) else: navigation = Sidebar(self, ...
[ "def", "buildNavigation", "(", "self", ")", ":", "if", "self", ".", "buildSpec", "[", "'navigation'", "]", "==", "constants", ".", "TABBED", ":", "navigation", "=", "Tabbar", "(", "self", ",", "self", ".", "buildSpec", ",", "self", ".", "configs", ")", ...
Chooses the appropriate layout navigation component based on user prefs
[ "Chooses", "the", "appropriate", "layout", "navigation", "component", "based", "on", "user", "prefs" ]
python
train
42.454545
apple/turicreate
src/unity/python/turicreate/util/_cloudpickle.py
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/util/_cloudpickle.py#L1090-L1105
def _fill_function(func, globals, defaults, dict, module, closure_values): """ Fills in the rest of function data into the skeleton function object that were created via _make_skel_func(). """ func.__globals__.update(globals) func.__defaults__ = defaults func.__dict__ = dict func.__modul...
[ "def", "_fill_function", "(", "func", ",", "globals", ",", "defaults", ",", "dict", ",", "module", ",", "closure_values", ")", ":", "func", ".", "__globals__", ".", "update", "(", "globals", ")", "func", ".", "__defaults__", "=", "defaults", "func", ".", ...
Fills in the rest of function data into the skeleton function object that were created via _make_skel_func().
[ "Fills", "in", "the", "rest", "of", "function", "data", "into", "the", "skeleton", "function", "object", "that", "were", "created", "via", "_make_skel_func", "()", "." ]
python
train
33.125
rbarrois/django-batchform
batchform/views.py
https://github.com/rbarrois/django-batchform/blob/f6b659a6790750285af248ccd1d4d178ecbad129/batchform/views.py#L119-L128
def form_lines_valid(self, form): """Handle a valid LineFormSet.""" handled = 0 for inner_form in form: if not inner_form.cleaned_data.get(formsets.DELETION_FIELD_NAME): handled += 1 self.handle_inner_form(inner_form) self.log_and_notify_lines...
[ "def", "form_lines_valid", "(", "self", ",", "form", ")", ":", "handled", "=", "0", "for", "inner_form", "in", "form", ":", "if", "not", "inner_form", ".", "cleaned_data", ".", "get", "(", "formsets", ".", "DELETION_FIELD_NAME", ")", ":", "handled", "+=", ...
Handle a valid LineFormSet.
[ "Handle", "a", "valid", "LineFormSet", "." ]
python
train
38.5
mikedh/trimesh
trimesh/util.py
https://github.com/mikedh/trimesh/blob/25e059bf6d4caa74f62ffd58ce4f61a90ee4e518/trimesh/util.py#L1292-L1398
def submesh(mesh, faces_sequence, only_watertight=False, append=False): """ Return a subset of a mesh. Parameters ---------- mesh : Trimesh Source mesh to take geometry from faces_sequence : sequence (p,) int Indexes of mesh.faces only_wate...
[ "def", "submesh", "(", "mesh", ",", "faces_sequence", ",", "only_watertight", "=", "False", ",", "append", "=", "False", ")", ":", "# evaluate generators so we can escape early", "faces_sequence", "=", "list", "(", "faces_sequence", ")", "if", "len", "(", "faces_s...
Return a subset of a mesh. Parameters ---------- mesh : Trimesh Source mesh to take geometry from faces_sequence : sequence (p,) int Indexes of mesh.faces only_watertight : bool Only return submeshes which are watertight. append : bool Return a single mesh which h...
[ "Return", "a", "subset", "of", "a", "mesh", "." ]
python
train
32.373832
manns/pyspread
pyspread/src/model/model.py
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/model/model.py#L1078-L1088
def set_row_height(self, row, tab, height): """Sets row height""" try: old_height = self.row_heights.pop((row, tab)) except KeyError: old_height = None if height is not None: self.row_heights[(row, tab)] = float(height)
[ "def", "set_row_height", "(", "self", ",", "row", ",", "tab", ",", "height", ")", ":", "try", ":", "old_height", "=", "self", ".", "row_heights", ".", "pop", "(", "(", "row", ",", "tab", ")", ")", "except", "KeyError", ":", "old_height", "=", "None",...
Sets row height
[ "Sets", "row", "height" ]
python
train
25.454545
qubole/qds-sdk-py
qds_sdk/cluster.py
https://github.com/qubole/qds-sdk-py/blob/77210fb64e5a7d567aedeea3b742a1d872fd0e5e/qds_sdk/cluster.py#L907-L926
def set_stable_spot_instance_settings(self, maximum_bid_price_percentage=None, timeout_for_request=None, allow_fallback=True): """ Purchase options for stable spot instances. `maximum_bid_price_percentage`: Maxi...
[ "def", "set_stable_spot_instance_settings", "(", "self", ",", "maximum_bid_price_percentage", "=", "None", ",", "timeout_for_request", "=", "None", ",", "allow_fallback", "=", "True", ")", ":", "self", ".", "hadoop_settings", "[", "'stable_spot_instance_settings'", "]",...
Purchase options for stable spot instances. `maximum_bid_price_percentage`: Maximum value to bid for stable node spot instances, expressed as a percentage of the base price (applies to both master and slave nodes). `timeout_for_request`: Timeout for a stable node spot instance ...
[ "Purchase", "options", "for", "stable", "spot", "instances", "." ]
python
train
48.25
acutesoftware/AIKIF
aikif/agents/agent_map_data.py
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/agents/agent_map_data.py#L29-L37
def map_data(self): """ provides a mapping from the CSV file to the aikif data structures. """ with open(self.src_file, "r") as f: for line in f: cols = line.split(',') print(cols)
[ "def", "map_data", "(", "self", ")", ":", "with", "open", "(", "self", ".", "src_file", ",", "\"r\"", ")", "as", "f", ":", "for", "line", "in", "f", ":", "cols", "=", "line", ".", "split", "(", "','", ")", "print", "(", "cols", ")" ]
provides a mapping from the CSV file to the aikif data structures.
[ "provides", "a", "mapping", "from", "the", "CSV", "file", "to", "the", "aikif", "data", "structures", "." ]
python
train
28.555556
annoviko/pyclustering
pyclustering/nnet/syncsegm.py
https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/nnet/syncsegm.py#L131-L153
def allocate_objects(self, eps = 0.01, noise_size = 1): """! @brief Allocates object segments. @param[in] eps (double): Tolerance level that define maximal difference between phases of oscillators in one segment. @param[in] noise_size (uint): Threshold that defines noise - ...
[ "def", "allocate_objects", "(", "self", ",", "eps", "=", "0.01", ",", "noise_size", "=", "1", ")", ":", "if", "(", "self", ".", "__object_segment_analysers", "is", "None", ")", ":", "return", "[", "]", "segments", "=", "[", "]", "for", "object_segment_an...
! @brief Allocates object segments. @param[in] eps (double): Tolerance level that define maximal difference between phases of oscillators in one segment. @param[in] noise_size (uint): Threshold that defines noise - segments size (in pixels) that is less then the threshold is conside...
[ "!" ]
python
valid
46.521739
lago-project/lago
lago/sdk.py
https://github.com/lago-project/lago/blob/5b8970f7687e063e4619066d5b8093ca997678c9/lago/sdk.py#L38-L64
def init(config, workdir=None, logfile=None, loglevel=logging.INFO, **kwargs): """ Initialize the Lago environment Args: config(str): Path to LagoInitFile workdir(str): Path to initalize the workdir, defaults to "$PWD/.lago" **kwargs(dict): Pass arguments to :func:`~lago.cmd.do_init...
[ "def", "init", "(", "config", ",", "workdir", "=", "None", ",", "logfile", "=", "None", ",", "loglevel", "=", "logging", ".", "INFO", ",", "*", "*", "kwargs", ")", ":", "setup_sdk_logging", "(", "logfile", ",", "loglevel", ")", "defaults", "=", "lago_c...
Initialize the Lago environment Args: config(str): Path to LagoInitFile workdir(str): Path to initalize the workdir, defaults to "$PWD/.lago" **kwargs(dict): Pass arguments to :func:`~lago.cmd.do_init` logfile(str): A path to setup a log file. loglevel(int): :mod:`logging` l...
[ "Initialize", "the", "Lago", "environment" ]
python
train
32.925926
numenta/htmresearch
projects/sequence_prediction/continuous_sequence/plotPerformance.py
https://github.com/numenta/htmresearch/blob/70c096b09a577ea0432c3f3bfff4442d4871b7aa/projects/sequence_prediction/continuous_sequence/plotPerformance.py#L45-L55
def getDatetimeAxis(): """ use datetime as x-axis """ dataSet = 'nyc_taxi' filePath = './data/' + dataSet + '.csv' data = pd.read_csv(filePath, header=0, skiprows=[1, 2], names=['datetime', 'value', 'timeofday', 'dayofweek']) xaxisDate = pd.to_datetime(data['datetime']) return xaxi...
[ "def", "getDatetimeAxis", "(", ")", ":", "dataSet", "=", "'nyc_taxi'", "filePath", "=", "'./data/'", "+", "dataSet", "+", "'.csv'", "data", "=", "pd", ".", "read_csv", "(", "filePath", ",", "header", "=", "0", ",", "skiprows", "=", "[", "1", ",", "2", ...
use datetime as x-axis
[ "use", "datetime", "as", "x", "-", "axis" ]
python
train
28.636364
numenta/htmresearch
htmresearch/regions/ApicalTMSequenceRegion.py
https://github.com/numenta/htmresearch/blob/70c096b09a577ea0432c3f3bfff4442d4871b7aa/htmresearch/regions/ApicalTMSequenceRegion.py#L39-L279
def getSpec(cls): """ Return the Spec for ApicalTMSequenceRegion. """ spec = { "description": ApicalTMSequenceRegion.__doc__, "singleNodeOnly": True, "inputs": { "activeColumns": { "description": ("An array of 0's and 1's representing the active " ...
[ "def", "getSpec", "(", "cls", ")", ":", "spec", "=", "{", "\"description\"", ":", "ApicalTMSequenceRegion", ".", "__doc__", ",", "\"singleNodeOnly\"", ":", "True", ",", "\"inputs\"", ":", "{", "\"activeColumns\"", ":", "{", "\"description\"", ":", "(", "\"An a...
Return the Spec for ApicalTMSequenceRegion.
[ "Return", "the", "Spec", "for", "ApicalTMSequenceRegion", "." ]
python
train
34.186722
spotify/luigi
luigi/contrib/hadoop.py
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/hadoop.py#L989-L1004
def _map_input(self, input_stream): """ Iterate over input and call the mapper for each item. If the job has a parser defined, the return values from the parser will be passed as arguments to the mapper. If the input is coded output from a previous run, the arguments wil...
[ "def", "_map_input", "(", "self", ",", "input_stream", ")", ":", "for", "record", "in", "self", ".", "reader", "(", "input_stream", ")", ":", "for", "output", "in", "self", ".", "mapper", "(", "*", "record", ")", ":", "yield", "output", "if", "self", ...
Iterate over input and call the mapper for each item. If the job has a parser defined, the return values from the parser will be passed as arguments to the mapper. If the input is coded output from a previous run, the arguments will be splitted in key and value.
[ "Iterate", "over", "input", "and", "call", "the", "mapper", "for", "each", "item", ".", "If", "the", "job", "has", "a", "parser", "defined", "the", "return", "values", "from", "the", "parser", "will", "be", "passed", "as", "arguments", "to", "the", "mapp...
python
train
39.9375
HPENetworking/PYHPEIMC
archived/pyhpimc.py
https://github.com/HPENetworking/PYHPEIMC/blob/4fba31827573587e03a6233c7db60f188038c8e5/archived/pyhpimc.py#L269-L305
def get_dev_details(ip_address): """Takes string input of IP address to issue RESTUL call to HP IMC :param ip_address: string object of dotted decimal notation of IPv4 address :return: dictionary of device details >>> get_dev_details('10.101.0.1') {'symbolLevel': '2', 'typeName': 'Cisco 2811', 'loc...
[ "def", "get_dev_details", "(", "ip_address", ")", ":", "# checks to see if the imc credentials are already available", "if", "auth", "is", "None", "or", "url", "is", "None", ":", "set_imc_creds", "(", ")", "global", "r", "get_dev_details_url", "=", "\"/imcrs/plat/res/de...
Takes string input of IP address to issue RESTUL call to HP IMC :param ip_address: string object of dotted decimal notation of IPv4 address :return: dictionary of device details >>> get_dev_details('10.101.0.1') {'symbolLevel': '2', 'typeName': 'Cisco 2811', 'location': 'changed this too', 'status': '1...
[ "Takes", "string", "input", "of", "IP", "address", "to", "issue", "RESTUL", "call", "to", "HP", "IMC", ":", "param", "ip_address", ":", "string", "object", "of", "dotted", "decimal", "notation", "of", "IPv4", "address", ":", "return", ":", "dictionary", "o...
python
train
54.837838
gem/oq-engine
openquake/hazardlib/gsim/bindi_2017.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/bindi_2017.py#L79-L96
def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types): """ See :meth:`superclass method <.base.GroundShakingIntensityModel.get_mean_and_stddevs>` for spec of input and result values. """ # extracting dictionary of coefficients specific to required #...
[ "def", "get_mean_and_stddevs", "(", "self", ",", "sites", ",", "rup", ",", "dists", ",", "imt", ",", "stddev_types", ")", ":", "# extracting dictionary of coefficients specific to required", "# intensity measure type.", "C", "=", "self", ".", "COEFFS", "[", "imt", "...
See :meth:`superclass method <.base.GroundShakingIntensityModel.get_mean_and_stddevs>` for spec of input and result values.
[ "See", ":", "meth", ":", "superclass", "method", "<", ".", "base", ".", "GroundShakingIntensityModel", ".", "get_mean_and_stddevs", ">", "for", "spec", "of", "input", "and", "result", "values", "." ]
python
train
41.611111
bodylabs/lace
lace/color.py
https://github.com/bodylabs/lace/blob/b68f4a60a4cac66c0607ffbae38ef9d07d37f459/lace/color.py#L5-L39
def colors_like(color, arr, colormap=DEFAULT_COLORMAP): ''' Given an array of size NxM (usually Nx3), we accept color in the following ways: - A string color name. The accepted names are roughly what's in X11's rgb.txt - An explicit rgb triple, in (3, ), (3, 1), or (1, 3) shape - A list of values (N...
[ "def", "colors_like", "(", "color", ",", "arr", ",", "colormap", "=", "DEFAULT_COLORMAP", ")", ":", "import", "numpy", "as", "np", "from", "blmath", ".", "numerics", "import", "is_empty_arraylike", "if", "is_empty_arraylike", "(", "color", ")", ":", "return", ...
Given an array of size NxM (usually Nx3), we accept color in the following ways: - A string color name. The accepted names are roughly what's in X11's rgb.txt - An explicit rgb triple, in (3, ), (3, 1), or (1, 3) shape - A list of values (N, ), (N, 1), or (1, N) that are put through a colormap to get per ve...
[ "Given", "an", "array", "of", "size", "NxM", "(", "usually", "Nx3", ")", "we", "accept", "color", "in", "the", "following", "ways", ":", "-", "A", "string", "color", "name", ".", "The", "accepted", "names", "are", "roughly", "what", "s", "in", "X11", ...
python
train
44.885714
streamlink/streamlink
src/streamlink/plugins/funimationnow.py
https://github.com/streamlink/streamlink/blob/c8ed1daff14ac03195870238b9b900c1109dd5c1/src/streamlink/plugins/funimationnow.py#L127-L135
def sources(self): """ Get the sources for a given experience_id, which is tied to a specific language :param experience_id: int; video content id :return: sources dict """ api_url = self.sources_api_url.format(experience_id=self.experience_id) res = self.get(api_...
[ "def", "sources", "(", "self", ")", ":", "api_url", "=", "self", ".", "sources_api_url", ".", "format", "(", "experience_id", "=", "self", ".", "experience_id", ")", "res", "=", "self", ".", "get", "(", "api_url", ",", "params", "=", "{", "\"pinst_id\"",...
Get the sources for a given experience_id, which is tied to a specific language :param experience_id: int; video content id :return: sources dict
[ "Get", "the", "sources", "for", "a", "given", "experience_id", "which", "is", "tied", "to", "a", "specific", "language", ":", "param", "experience_id", ":", "int", ";", "video", "content", "id", ":", "return", ":", "sources", "dict" ]
python
test
43.888889
pudo/dataset
dataset/table.py
https://github.com/pudo/dataset/blob/a008d120c7f3c48ccba98a282c0c67d6e719c0e5/dataset/table.py#L369-L388
def drop_column(self, name): """Drop the column ``name``. :: table.drop_column('created_at') """ if self.db.engine.dialect.name == 'sqlite': raise RuntimeError("SQLite does not support dropping columns.") name = normalize_column_name(name) with sel...
[ "def", "drop_column", "(", "self", ",", "name", ")", ":", "if", "self", ".", "db", ".", "engine", ".", "dialect", ".", "name", "==", "'sqlite'", ":", "raise", "RuntimeError", "(", "\"SQLite does not support dropping columns.\"", ")", "name", "=", "normalize_co...
Drop the column ``name``. :: table.drop_column('created_at')
[ "Drop", "the", "column", "name", ".", "::", "table", ".", "drop_column", "(", "created_at", ")" ]
python
train
33.25
pybel/pybel-tools
src/pybel_tools/analysis/heat.py
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/analysis/heat.py#L369-L399
def get_random_edge(self): """This function should be run when there are no leaves, but there are still unscored nodes. It will introduce a probabilistic element to the algorithm, where some edges are disregarded randomly to eventually get a score for the network. This means that the score can b...
[ "def", "get_random_edge", "(", "self", ")", ":", "nodes", "=", "[", "(", "n", ",", "self", ".", "in_out_ratio", "(", "n", ")", ")", "for", "n", "in", "self", ".", "unscored_nodes_iter", "(", ")", "if", "n", "!=", "self", ".", "target_node", "]", "n...
This function should be run when there are no leaves, but there are still unscored nodes. It will introduce a probabilistic element to the algorithm, where some edges are disregarded randomly to eventually get a score for the network. This means that the score can be averaged over many runs for a given ...
[ "This", "function", "should", "be", "run", "when", "there", "are", "no", "leaves", "but", "there", "are", "still", "unscored", "nodes", ".", "It", "will", "introduce", "a", "probabilistic", "element", "to", "the", "algorithm", "where", "some", "edges", "are"...
python
valid
44.451613
berkeley-cocosci/Wallace
wallace/command_line.py
https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/wallace/command_line.py#L83-L219
def setup_experiment(debug=True, verbose=False, app=None): """Check the app and, if it's compatible with Wallace, freeze its state.""" print_header() # Verify that the package is usable. log("Verifying that directory is compatible with Wallace...") if not verify_package(verbose=verbose): ra...
[ "def", "setup_experiment", "(", "debug", "=", "True", ",", "verbose", "=", "False", ",", "app", "=", "None", ")", ":", "print_header", "(", ")", "# Verify that the package is usable.", "log", "(", "\"Verifying that directory is compatible with Wallace...\"", ")", "if"...
Check the app and, if it's compatible with Wallace, freeze its state.
[ "Check", "the", "app", "and", "if", "it", "s", "compatible", "with", "Wallace", "freeze", "its", "state", "." ]
python
train
28.992701
pywbem/pywbem
pywbem/cim_obj.py
https://github.com/pywbem/pywbem/blob/e54ecb82c2211e289a268567443d60fdd489f1e4/pywbem/cim_obj.py#L3332-L3348
def copy(self): """ Return a new :class:`~pywbem.CIMClassName` object that is a copy of this CIM class path. Objects of this class have no mutable types in any attributes, so modifications of the original object will not affect the returned copy, and vice versa. ...
[ "def", "copy", "(", "self", ")", ":", "return", "CIMClassName", "(", "self", ".", "classname", ",", "host", "=", "self", ".", "host", ",", "namespace", "=", "self", ".", "namespace", ")" ]
Return a new :class:`~pywbem.CIMClassName` object that is a copy of this CIM class path. Objects of this class have no mutable types in any attributes, so modifications of the original object will not affect the returned copy, and vice versa. Note that the Python functions :fun...
[ "Return", "a", "new", ":", "class", ":", "~pywbem", ".", "CIMClassName", "object", "that", "is", "a", "copy", "of", "this", "CIM", "class", "path", "." ]
python
train
37
uyar/pygenstub
pygenstub.py
https://github.com/uyar/pygenstub/blob/a6b18a823382d3c6be29c411fb33c58b6090d22c/pygenstub.py#L102-L111
def extract_signature(docstring): """Extract the signature from a docstring. :sig: (str) -> Optional[str] :param docstring: Docstring to extract the signature from. :return: Extracted signature, or ``None`` if there's no signature. """ root = publish_doctree(docstring, settings_overrides={"repo...
[ "def", "extract_signature", "(", "docstring", ")", ":", "root", "=", "publish_doctree", "(", "docstring", ",", "settings_overrides", "=", "{", "\"report_level\"", ":", "5", "}", ")", "fields", "=", "get_fields", "(", "root", ")", "return", "fields", ".", "ge...
Extract the signature from a docstring. :sig: (str) -> Optional[str] :param docstring: Docstring to extract the signature from. :return: Extracted signature, or ``None`` if there's no signature.
[ "Extract", "the", "signature", "from", "a", "docstring", "." ]
python
train
38.8
oasiswork/zimsoap
zimsoap/client.py
https://github.com/oasiswork/zimsoap/blob/d1ea2eb4d50f263c9a16e5549af03f1eff3e295e/zimsoap/client.py#L1195-L1245
def search_directory(self, **kwargs): """ SearchAccount is deprecated, using SearchDirectory :param query: Query string - should be an LDAP-style filter string (RFC 2254) :param limit: The maximum number of accounts to return (0 is default and means all) :param o...
[ "def", "search_directory", "(", "self", ",", "*", "*", "kwargs", ")", ":", "search_response", "=", "self", ".", "request", "(", "'SearchDirectory'", ",", "kwargs", ")", "result", "=", "{", "}", "items", "=", "{", "\"account\"", ":", "zobjects", ".", "Acc...
SearchAccount is deprecated, using SearchDirectory :param query: Query string - should be an LDAP-style filter string (RFC 2254) :param limit: The maximum number of accounts to return (0 is default and means all) :param offset: The starting offset (0, 25, etc) :param dom...
[ "SearchAccount", "is", "deprecated", "using", "SearchDirectory" ]
python
train
43.27451
Pelagicore/qface
qface/idl/domain.py
https://github.com/Pelagicore/qface/blob/7f60e91e3a91a7cb04cfacbc9ce80f43df444853/qface/idl/domain.py#L146-L149
def add_tag(self, tag): """ add a tag to the tag list """ if tag not in self._tags: self._tags[tag] = dict()
[ "def", "add_tag", "(", "self", ",", "tag", ")", ":", "if", "tag", "not", "in", "self", ".", "_tags", ":", "self", ".", "_tags", "[", "tag", "]", "=", "dict", "(", ")" ]
add a tag to the tag list
[ "add", "a", "tag", "to", "the", "tag", "list" ]
python
train
33.25
merll/docker-map
dockermap/map/config/main.py
https://github.com/merll/docker-map/blob/e14fe86a6ff5c33d121eb2f9157e9359cb80dd02/dockermap/map/config/main.py#L332-L428
def dependency_items(self): """ Generates all containers' dependencies, i.e. an iterator on tuples in the format ``(container_name, used_containers)``, whereas the used containers are a set, and can be empty. :return: Container dependencies. :rtype: collections.Iterable ...
[ "def", "dependency_items", "(", "self", ")", ":", "def", "_get_used_items_np", "(", "u", ")", ":", "volume_config_name", ",", "__", ",", "volume_instance", "=", "u", ".", "name", ".", "partition", "(", "'.'", ")", "attaching_config_name", "=", "attaching", "...
Generates all containers' dependencies, i.e. an iterator on tuples in the format ``(container_name, used_containers)``, whereas the used containers are a set, and can be empty. :return: Container dependencies. :rtype: collections.Iterable
[ "Generates", "all", "containers", "dependencies", "i", ".", "e", ".", "an", "iterator", "on", "tuples", "in", "the", "format", "(", "container_name", "used_containers", ")", "whereas", "the", "used", "containers", "are", "a", "set", "and", "can", "be", "empt...
python
train
47.226804
pudo/normality
normality/__init__.py
https://github.com/pudo/normality/blob/b53cc2c6e5c6205573d2010f72d90808710a4b58/normality/__init__.py#L60-L69
def slugify(text, sep='-'): """A simple slug generator.""" text = stringify(text) if text is None: return None text = text.replace(sep, WS) text = normalize(text, ascii=True) if text is None: return None return text.replace(WS, sep)
[ "def", "slugify", "(", "text", ",", "sep", "=", "'-'", ")", ":", "text", "=", "stringify", "(", "text", ")", "if", "text", "is", "None", ":", "return", "None", "text", "=", "text", ".", "replace", "(", "sep", ",", "WS", ")", "text", "=", "normali...
A simple slug generator.
[ "A", "simple", "slug", "generator", "." ]
python
train
26.7
fermiPy/fermipy
fermipy/diffuse/model_manager.py
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/model_manager.py#L455-L469
def get_sub_comp_info(source_info, comp): """Build and return information about a sub-component for a particular selection """ sub_comps = source_info.get('components', None) if sub_comps is None: return source_info.copy() moving = source_info.get('moving', False) ...
[ "def", "get_sub_comp_info", "(", "source_info", ",", "comp", ")", ":", "sub_comps", "=", "source_info", ".", "get", "(", "'components'", ",", "None", ")", "if", "sub_comps", "is", "None", ":", "return", "source_info", ".", "copy", "(", ")", "moving", "=", ...
Build and return information about a sub-component for a particular selection
[ "Build", "and", "return", "information", "about", "a", "sub", "-", "component", "for", "a", "particular", "selection" ]
python
train
42.2
rootpy/rootpy
rootpy/plotting/hist.py
https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/hist.py#L1260-L1273
def set_sum_w2(self, w, ix, iy=0, iz=0): """ Sets the true number of entries in the bin weighted by w^2 """ if self.GetSumw2N() == 0: raise RuntimeError( "Attempting to access Sumw2 in histogram " "where weights were not stored") xl = s...
[ "def", "set_sum_w2", "(", "self", ",", "w", ",", "ix", ",", "iy", "=", "0", ",", "iz", "=", "0", ")", ":", "if", "self", ".", "GetSumw2N", "(", ")", "==", "0", ":", "raise", "RuntimeError", "(", "\"Attempting to access Sumw2 in histogram \"", "\"where we...
Sets the true number of entries in the bin weighted by w^2
[ "Sets", "the", "true", "number", "of", "entries", "in", "the", "bin", "weighted", "by", "w^2" ]
python
train
40.357143
hyperledger/sawtooth-core
validator/sawtooth_validator/execution/execution_context.py
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/execution/execution_context.py#L230-L242
def create_prefetch(self, addresses): """Create futures needed before starting the process of reading the address's value from the merkle tree. Args: addresses (list of str): addresses in the txn's inputs that aren't in any base context (or any in the chain). ...
[ "def", "create_prefetch", "(", "self", ",", "addresses", ")", ":", "with", "self", ".", "_lock", ":", "for", "add", "in", "addresses", ":", "self", ".", "_state", "[", "add", "]", "=", "_ContextFuture", "(", "address", "=", "add", ",", "wait_for_tree", ...
Create futures needed before starting the process of reading the address's value from the merkle tree. Args: addresses (list of str): addresses in the txn's inputs that aren't in any base context (or any in the chain).
[ "Create", "futures", "needed", "before", "starting", "the", "process", "of", "reading", "the", "address", "s", "value", "from", "the", "merkle", "tree", "." ]
python
train
38.846154
scanny/python-pptx
pptx/oxml/xmlchemy.py
https://github.com/scanny/python-pptx/blob/d6ab8234f8b03953d2f831ff9394b1852db34130/pptx/oxml/xmlchemy.py#L21-L30
def OxmlElement(nsptag_str, nsmap=None): """ Return a 'loose' lxml element having the tag specified by *nsptag_str*. *nsptag_str* must contain the standard namespace prefix, e.g. 'a:tbl'. The resulting element is an instance of the custom element class for this tag name if one is defined. """ ...
[ "def", "OxmlElement", "(", "nsptag_str", ",", "nsmap", "=", "None", ")", ":", "nsptag", "=", "NamespacePrefixedTag", "(", "nsptag_str", ")", "nsmap", "=", "nsmap", "if", "nsmap", "is", "not", "None", "else", "nsptag", ".", "nsmap", "return", "oxml_parser", ...
Return a 'loose' lxml element having the tag specified by *nsptag_str*. *nsptag_str* must contain the standard namespace prefix, e.g. 'a:tbl'. The resulting element is an instance of the custom element class for this tag name if one is defined.
[ "Return", "a", "loose", "lxml", "element", "having", "the", "tag", "specified", "by", "*", "nsptag_str", "*", ".", "*", "nsptag_str", "*", "must", "contain", "the", "standard", "namespace", "prefix", "e", ".", "g", ".", "a", ":", "tbl", ".", "The", "re...
python
train
47.8
edoburu/django-any-urlfield
any_urlfield/templatetags/any_urlfield_tags.py
https://github.com/edoburu/django-any-urlfield/blob/8d7d36c8a1fc251930f6dbdcc8b5b5151d20e3ab/any_urlfield/templatetags/any_urlfield_tags.py#L31-L45
def withdict(parser, token): """ Take a complete context dict as extra layer. """ bits = token.split_contents() if len(bits) != 2: raise TemplateSyntaxError("{% withdict %} expects one argument") nodelist = parser.parse(('endwithdict',)) parser.delete_first_token() return WithD...
[ "def", "withdict", "(", "parser", ",", "token", ")", ":", "bits", "=", "token", ".", "split_contents", "(", ")", "if", "len", "(", "bits", ")", "!=", "2", ":", "raise", "TemplateSyntaxError", "(", "\"{% withdict %} expects one argument\"", ")", "nodelist", "...
Take a complete context dict as extra layer.
[ "Take", "a", "complete", "context", "dict", "as", "extra", "layer", "." ]
python
train
26.6
wesyoung/pyzyre
czmq/_czmq_ctypes.py
https://github.com/wesyoung/pyzyre/blob/22d4c757acefcfdb700d3802adaf30b402bb9eea/czmq/_czmq_ctypes.py#L4931-L4936
def set_argsx(self, arguments, *args): """ Setup the command line arguments, the first item must be an (absolute) filename to run. Variadic function, must be NULL terminated. """ return lib.zproc_set_argsx(self._as_parameter_, arguments, *args)
[ "def", "set_argsx", "(", "self", ",", "arguments", ",", "*", "args", ")", ":", "return", "lib", ".", "zproc_set_argsx", "(", "self", ".", "_as_parameter_", ",", "arguments", ",", "*", "args", ")" ]
Setup the command line arguments, the first item must be an (absolute) filename to run. Variadic function, must be NULL terminated.
[ "Setup", "the", "command", "line", "arguments", "the", "first", "item", "must", "be", "an", "(", "absolute", ")", "filename", "to", "run", ".", "Variadic", "function", "must", "be", "NULL", "terminated", "." ]
python
train
45.166667
tensorflow/tensorboard
tensorboard/plugins/interactive_inference/interactive_inference_plugin.py
https://github.com/tensorflow/tensorboard/blob/8e5f497b48e40f2a774f85416b8a35ac0693c35e/tensorboard/plugins/interactive_inference/interactive_inference_plugin.py#L230-L247
def _parse_request_arguments(self, request): """Parses comma separated request arguments Args: request: A request that should contain 'inference_address', 'model_name', 'model_version', 'model_signature'. Returns: A tuple of lists for model parameters """ inference_addresses = ...
[ "def", "_parse_request_arguments", "(", "self", ",", "request", ")", ":", "inference_addresses", "=", "request", ".", "args", ".", "get", "(", "'inference_address'", ")", ".", "split", "(", "','", ")", "model_names", "=", "request", ".", "args", ".", "get", ...
Parses comma separated request arguments Args: request: A request that should contain 'inference_address', 'model_name', 'model_version', 'model_signature'. Returns: A tuple of lists for model parameters
[ "Parses", "comma", "separated", "request", "arguments" ]
python
train
45.833333
RaRe-Technologies/smart_open
smart_open/smart_open_lib.py
https://github.com/RaRe-Technologies/smart_open/blob/2dc8d60f223fc7b00a2000c56362a7bd6cd0850e/smart_open/smart_open_lib.py#L442-L501
def _shortcut_open( uri, mode, ignore_ext=False, buffering=-1, encoding=None, errors=None, ): """Try to open the URI using the standard library io.open function. This can be much faster than the alternative of opening in binary mode and then decoding....
[ "def", "_shortcut_open", "(", "uri", ",", "mode", ",", "ignore_ext", "=", "False", ",", "buffering", "=", "-", "1", ",", "encoding", "=", "None", ",", "errors", "=", "None", ",", ")", ":", "if", "not", "isinstance", "(", "uri", ",", "six", ".", "st...
Try to open the URI using the standard library io.open function. This can be much faster than the alternative of opening in binary mode and then decoding. This is only possible under the following conditions: 1. Opening a local file 2. Ignore extension is set to True If it is not pos...
[ "Try", "to", "open", "the", "URI", "using", "the", "standard", "library", "io", ".", "open", "function", "." ]
python
train
31.133333
goldsmith/Wikipedia
wikipedia/wikipedia.py
https://github.com/goldsmith/Wikipedia/blob/2065c568502b19b8634241b47fd96930d1bf948d/wikipedia/wikipedia.py#L188-L211
def random(pages=1): ''' Get a list of random Wikipedia article titles. .. note:: Random only gets articles from namespace 0, meaning no Category, User talk, or other meta-Wikipedia pages. Keyword arguments: * pages - the number of random pages returned (max of 10) ''' #http://en.wikipedia.org/w/api.ph...
[ "def", "random", "(", "pages", "=", "1", ")", ":", "#http://en.wikipedia.org/w/api.php?action=query&list=random&rnlimit=5000&format=jsonfm", "query_params", "=", "{", "'list'", ":", "'random'", ",", "'rnnamespace'", ":", "0", ",", "'rnlimit'", ":", "pages", ",", "}", ...
Get a list of random Wikipedia article titles. .. note:: Random only gets articles from namespace 0, meaning no Category, User talk, or other meta-Wikipedia pages. Keyword arguments: * pages - the number of random pages returned (max of 10)
[ "Get", "a", "list", "of", "random", "Wikipedia", "article", "titles", "." ]
python
train
25.333333
nilp0inter/cpe
cpe/cpe2_3_wfn.py
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpe2_3_wfn.py#L110-L216
def _parse(self): """ Checks if the CPE Name is valid. :returns: None :exception: ValueError - bad-formed CPE Name """ # Check prefix and initial bracket of WFN if self._str[0:5] != CPE2_3_WFN.CPE_PREFIX: errmsg = "Bad-formed CPE Name: WFN prefix not...
[ "def", "_parse", "(", "self", ")", ":", "# Check prefix and initial bracket of WFN", "if", "self", ".", "_str", "[", "0", ":", "5", "]", "!=", "CPE2_3_WFN", ".", "CPE_PREFIX", ":", "errmsg", "=", "\"Bad-formed CPE Name: WFN prefix not found\"", "raise", "ValueError"...
Checks if the CPE Name is valid. :returns: None :exception: ValueError - bad-formed CPE Name
[ "Checks", "if", "the", "CPE", "Name", "is", "valid", "." ]
python
train
38.065421
IdentityPython/oidcendpoint
src/oidcendpoint/session.py
https://github.com/IdentityPython/oidcendpoint/blob/6c1d729d51bfb6332816117fe476073df7a1d823/src/oidcendpoint/session.py#L109-L127
def mint_sub(client_salt, sector_id="", subject_type="public", uid='', user_salt=''): """ Mint a new sub (subject identifier) :param authn_event: Authentication event information :param client_salt: client specific salt - used in pairwise :param sector_id: Possible sector identifier ...
[ "def", "mint_sub", "(", "client_salt", ",", "sector_id", "=", "\"\"", ",", "subject_type", "=", "\"public\"", ",", "uid", "=", "''", ",", "user_salt", "=", "''", ")", ":", "if", "subject_type", "==", "\"public\"", ":", "sub", "=", "hashlib", ".", "sha256...
Mint a new sub (subject identifier) :param authn_event: Authentication event information :param client_salt: client specific salt - used in pairwise :param sector_id: Possible sector identifier :param subject_type: 'public'/'pairwise' :return: Subject identifier
[ "Mint", "a", "new", "sub", "(", "subject", "identifier", ")" ]
python
train
34.263158
awslabs/sockeye
sockeye/data_io.py
https://github.com/awslabs/sockeye/blob/5d64a1ee1ef3cbba17c6d1d94bc061020c43f6ab/sockeye/data_io.py#L522-L531
def get_num_shards(num_samples: int, samples_per_shard: int, min_num_shards: int) -> int: """ Returns the number of shards. :param num_samples: Number of training data samples. :param samples_per_shard: Samples per shard. :param min_num_shards: Minimum number of shards. :return: Number of shard...
[ "def", "get_num_shards", "(", "num_samples", ":", "int", ",", "samples_per_shard", ":", "int", ",", "min_num_shards", ":", "int", ")", "->", "int", ":", "return", "max", "(", "int", "(", "math", ".", "ceil", "(", "num_samples", "/", "samples_per_shard", ")...
Returns the number of shards. :param num_samples: Number of training data samples. :param samples_per_shard: Samples per shard. :param min_num_shards: Minimum number of shards. :return: Number of shards.
[ "Returns", "the", "number", "of", "shards", "." ]
python
train
40.1
pypa/pipenv
pipenv/patched/notpip/_internal/cli/parser.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/cli/parser.py#L251-L261
def invalid_config_error_message(action, key, val): """Returns a better error message when invalid configuration option is provided.""" if action in ('store_true', 'store_false'): return ("{0} is not a valid value for {1} option, " "please specify a boolean value like yes/no, " ...
[ "def", "invalid_config_error_message", "(", "action", ",", "key", ",", "val", ")", ":", "if", "action", "in", "(", "'store_true'", ",", "'store_false'", ")", ":", "return", "(", "\"{0} is not a valid value for {1} option, \"", "\"please specify a boolean value like yes/no...
Returns a better error message when invalid configuration option is provided.
[ "Returns", "a", "better", "error", "message", "when", "invalid", "configuration", "option", "is", "provided", "." ]
python
train
47.454545
tBuLi/symfit
symfit/core/fit.py
https://github.com/tBuLi/symfit/blob/759dd3d1d4270510d651f40b23dd26b1b10eee83/symfit/core/fit.py#L1043-L1051
def independent_data(self): """ Read-only Property :return: Data belonging to each independent variable as a dict with variable names as key, data as value. :rtype: collections.OrderedDict """ return OrderedDict((var, self.data[var]) for var in self.mode...
[ "def", "independent_data", "(", "self", ")", ":", "return", "OrderedDict", "(", "(", "var", ",", "self", ".", "data", "[", "var", "]", ")", "for", "var", "in", "self", ".", "model", ".", "independent_vars", ")" ]
Read-only Property :return: Data belonging to each independent variable as a dict with variable names as key, data as value. :rtype: collections.OrderedDict
[ "Read", "-", "only", "Property" ]
python
train
36.777778
manns/pyspread
pyspread/src/gui/_chart_dialog.py
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_chart_dialog.py#L639-L645
def OnSecondaryCheckbox(self, event): """Top Checkbox event handler""" self.attrs["top"] = event.IsChecked() self.attrs["right"] = event.IsChecked() post_command_event(self, self.DrawChartMsg)
[ "def", "OnSecondaryCheckbox", "(", "self", ",", "event", ")", ":", "self", ".", "attrs", "[", "\"top\"", "]", "=", "event", ".", "IsChecked", "(", ")", "self", ".", "attrs", "[", "\"right\"", "]", "=", "event", ".", "IsChecked", "(", ")", "post_command...
Top Checkbox event handler
[ "Top", "Checkbox", "event", "handler" ]
python
train
31.428571
jonhadfield/python-hosts
python_hosts/hosts.py
https://github.com/jonhadfield/python-hosts/blob/9ccaa8edc63418a91f10bf732b26070f21dd2ad0/python_hosts/hosts.py#L177-L221
def write(self, path=None): """ Write all of the HostsEntry instances back to the hosts file :param path: override the write path :return: Dictionary containing counts """ written_count = 0 comments_written = 0 blanks_written = 0 ipv4_entries_writt...
[ "def", "write", "(", "self", ",", "path", "=", "None", ")", ":", "written_count", "=", "0", "comments_written", "=", "0", "blanks_written", "=", "0", "ipv4_entries_written", "=", "0", "ipv6_entries_written", "=", "0", "if", "path", ":", "output_file_path", "...
Write all of the HostsEntry instances back to the hosts file :param path: override the write path :return: Dictionary containing counts
[ "Write", "all", "of", "the", "HostsEntry", "instances", "back", "to", "the", "hosts", "file", ":", "param", "path", ":", "override", "the", "write", "path", ":", "return", ":", "Dictionary", "containing", "counts" ]
python
train
41.088889
djordon/queueing-tool
queueing_tool/network/queue_network.py
https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/network/queue_network.py#L612-L640
def clear_data(self, queues=None, edge=None, edge_type=None): """Clears data from all queues. If none of the parameters are given then every queue's data is cleared. Parameters ---------- queues : int or an iterable of int (optional) The edge index (or an it...
[ "def", "clear_data", "(", "self", ",", "queues", "=", "None", ",", "edge", "=", "None", ",", "edge_type", "=", "None", ")", ":", "queues", "=", "_get_queues", "(", "self", ".", "g", ",", "queues", ",", "edge", ",", "edge_type", ")", "for", "k", "in...
Clears data from all queues. If none of the parameters are given then every queue's data is cleared. Parameters ---------- queues : int or an iterable of int (optional) The edge index (or an iterable of edge indices) identifying the :class:`QueueServer(s...
[ "Clears", "data", "from", "all", "queues", "." ]
python
valid
37.137931
DataONEorg/d1_python
gmn/src/d1_gmn/app/views/assert_sysmeta.py
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/views/assert_sysmeta.py#L36-L46
def sanity(request, sysmeta_pyxb): """Check that sysmeta_pyxb is suitable for creating a new object and matches the uploaded sciobj bytes.""" _does_not_contain_replica_sections(sysmeta_pyxb) _is_not_archived(sysmeta_pyxb) _obsoleted_by_not_specified(sysmeta_pyxb) if 'HTTP_VENDOR_GMN_REMOTE_URL' ...
[ "def", "sanity", "(", "request", ",", "sysmeta_pyxb", ")", ":", "_does_not_contain_replica_sections", "(", "sysmeta_pyxb", ")", "_is_not_archived", "(", "sysmeta_pyxb", ")", "_obsoleted_by_not_specified", "(", "sysmeta_pyxb", ")", "if", "'HTTP_VENDOR_GMN_REMOTE_URL'", "in...
Check that sysmeta_pyxb is suitable for creating a new object and matches the uploaded sciobj bytes.
[ "Check", "that", "sysmeta_pyxb", "is", "suitable", "for", "creating", "a", "new", "object", "and", "matches", "the", "uploaded", "sciobj", "bytes", "." ]
python
train
44.545455
tanghaibao/goatools
goatools/anno/annoreader_base.py
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/annoreader_base.py#L104-L115
def _prt_qualifiers(associations, prt=sys.stdout): """Print Qualifiers found in the annotations. QUALIFIERS: 1,462 colocalizes_with 1,454 contributes_to 1,157 not 13 not colocalizes_with (TBD: CHK - Seen in gene2go, but not gafs) ...
[ "def", "_prt_qualifiers", "(", "associations", ",", "prt", "=", "sys", ".", "stdout", ")", ":", "prt", ".", "write", "(", "'QUALIFIERS:\\n'", ")", "for", "fld", ",", "cnt", "in", "cx", ".", "Counter", "(", "q", "for", "nt", "in", "associations", "for",...
Print Qualifiers found in the annotations. QUALIFIERS: 1,462 colocalizes_with 1,454 contributes_to 1,157 not 13 not colocalizes_with (TBD: CHK - Seen in gene2go, but not gafs) 4 not contributes_to (TBD: CHK - Seen in...
[ "Print", "Qualifiers", "found", "in", "the", "annotations", ".", "QUALIFIERS", ":", "1", "462", "colocalizes_with", "1", "454", "contributes_to", "1", "157", "not", "13", "not", "colocalizes_with", "(", "TBD", ":", "CHK", "-", "Seen", "in", "gene2go", "but",...
python
train
50.5
gem/oq-engine
openquake/hazardlib/gsim/convertito_2012.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/convertito_2012.py#L109-L116
def _compute_site_scaling(self, C, vs30): """ Returns the site scaling term as a simple coefficient """ site_term = np.zeros(len(vs30), dtype=float) # For soil sites add on the site coefficient site_term[vs30 < 760.0] = C["e"] return site_term
[ "def", "_compute_site_scaling", "(", "self", ",", "C", ",", "vs30", ")", ":", "site_term", "=", "np", ".", "zeros", "(", "len", "(", "vs30", ")", ",", "dtype", "=", "float", ")", "# For soil sites add on the site coefficient", "site_term", "[", "vs30", "<", ...
Returns the site scaling term as a simple coefficient
[ "Returns", "the", "site", "scaling", "term", "as", "a", "simple", "coefficient" ]
python
train
36.5
readbeyond/aeneas
aeneas/syncmap/fragmentlist.py
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/syncmap/fragmentlist.py#L248-L271
def sort(self): """ Sort the fragments in the list. :raises ValueError: if there is a fragment which violates the list constraints """ if self.is_guaranteed_sorted: self.log(u"Already sorted, returning") return self.log...
[ "def", "sort", "(", "self", ")", ":", "if", "self", ".", "is_guaranteed_sorted", ":", "self", ".", "log", "(", "u\"Already sorted, returning\"", ")", "return", "self", ".", "log", "(", "u\"Sorting...\"", ")", "self", ".", "__fragments", "=", "sorted", "(", ...
Sort the fragments in the list. :raises ValueError: if there is a fragment which violates the list constraints
[ "Sort", "the", "fragments", "in", "the", "list", "." ]
python
train
45.458333
minhhoit/yacms
yacms/boot/__init__.py
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/boot/__init__.py#L38-L52
def import_field(field_classpath): """ Imports a field by its dotted class path, prepending "django.db.models" to raw class names and raising an exception if the import fails. """ if '.' in field_classpath: fully_qualified = field_classpath else: fully_qualified = "django.db.mode...
[ "def", "import_field", "(", "field_classpath", ")", ":", "if", "'.'", "in", "field_classpath", ":", "fully_qualified", "=", "field_classpath", "else", ":", "fully_qualified", "=", "\"django.db.models.%s\"", "%", "field_classpath", "try", ":", "return", "import_dotted_...
Imports a field by its dotted class path, prepending "django.db.models" to raw class names and raising an exception if the import fails.
[ "Imports", "a", "field", "by", "its", "dotted", "class", "path", "prepending", "django", ".", "db", ".", "models", "to", "raw", "class", "names", "and", "raising", "an", "exception", "if", "the", "import", "fails", "." ]
python
train
42
nirum/descent
descent/proxops.py
https://github.com/nirum/descent/blob/074c8452f15a0da638668a4fe139fde06ccfae7f/descent/proxops.py#L251-L259
def columns(x, rho, proxop): """Applies a proximal operator to the columns of a matrix""" xnext = np.zeros_like(x) for ix in range(x.shape[1]): xnext[:, ix] = proxop(x[:, ix], rho) return xnext
[ "def", "columns", "(", "x", ",", "rho", ",", "proxop", ")", ":", "xnext", "=", "np", ".", "zeros_like", "(", "x", ")", "for", "ix", "in", "range", "(", "x", ".", "shape", "[", "1", "]", ")", ":", "xnext", "[", ":", ",", "ix", "]", "=", "pro...
Applies a proximal operator to the columns of a matrix
[ "Applies", "a", "proximal", "operator", "to", "the", "columns", "of", "a", "matrix" ]
python
valid
23.555556
enkore/i3pystatus
i3pystatus/core/io.py
https://github.com/enkore/i3pystatus/blob/14cfde967cecf79b40e223e35a04600f4c875af7/i3pystatus/core/io.py#L185-L190
def read(self): """Iterate over all JSON input (Generator)""" for line in self.io.read(): with self.parse_line(line) as j: yield j
[ "def", "read", "(", "self", ")", ":", "for", "line", "in", "self", ".", "io", ".", "read", "(", ")", ":", "with", "self", ".", "parse_line", "(", "line", ")", "as", "j", ":", "yield", "j" ]
Iterate over all JSON input (Generator)
[ "Iterate", "over", "all", "JSON", "input", "(", "Generator", ")" ]
python
train
28.333333
juju/charm-helpers
charmhelpers/core/host.py
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/core/host.py#L669-L681
def check_hash(path, checksum, hash_type='md5'): """Validate a file using a cryptographic checksum. :param str checksum: Value of the checksum used to validate the file. :param str hash_type: Hash algorithm used to generate `checksum`. Can be any hash alrgorithm supported by :mod:`hashlib`, ...
[ "def", "check_hash", "(", "path", ",", "checksum", ",", "hash_type", "=", "'md5'", ")", ":", "actual_checksum", "=", "file_hash", "(", "path", ",", "hash_type", ")", "if", "checksum", "!=", "actual_checksum", ":", "raise", "ChecksumError", "(", "\"'%s' != '%s'...
Validate a file using a cryptographic checksum. :param str checksum: Value of the checksum used to validate the file. :param str hash_type: Hash algorithm used to generate `checksum`. Can be any hash alrgorithm supported by :mod:`hashlib`, such as md5, sha1, sha256, sha512, etc. :raises Che...
[ "Validate", "a", "file", "using", "a", "cryptographic", "checksum", "." ]
python
train
44.153846
hyperledger/sawtooth-core
validator/sawtooth_validator/journal/consensus/consensus_factory.py
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/journal/consensus/consensus_factory.py#L27-L56
def get_consensus_module(module_name): """Returns a consensus module by name. Args: module_name (str): The name of the module to load. Returns: module: The consensus module. Raises: UnknownConsensusModuleError: Raised if the given module_name does ...
[ "def", "get_consensus_module", "(", "module_name", ")", ":", "module_package", "=", "module_name", "if", "module_name", "==", "'genesis'", ":", "module_package", "=", "(", "'sawtooth_validator.journal.consensus.genesis.'", "'genesis_consensus'", ")", "elif", "module_name", ...
Returns a consensus module by name. Args: module_name (str): The name of the module to load. Returns: module: The consensus module. Raises: UnknownConsensusModuleError: Raised if the given module_name does not correspond to a consensus imple...
[ "Returns", "a", "consensus", "module", "by", "name", "." ]
python
train
33.1
RudolfCardinal/pythonlib
cardinal_pythonlib/sqlalchemy/alembic_func.py
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/sqlalchemy/alembic_func.py#L113-L145
def get_current_and_head_revision( database_url: str, alembic_config_filename: str, alembic_base_dir: str = None, version_table: str = DEFAULT_ALEMBIC_VERSION_TABLE) -> Tuple[str, str]: """ Returns a tuple of ``(current_revision, head_revision)``; see :func:`get_current_revis...
[ "def", "get_current_and_head_revision", "(", "database_url", ":", "str", ",", "alembic_config_filename", ":", "str", ",", "alembic_base_dir", ":", "str", "=", "None", ",", "version_table", ":", "str", "=", "DEFAULT_ALEMBIC_VERSION_TABLE", ")", "->", "Tuple", "[", ...
Returns a tuple of ``(current_revision, head_revision)``; see :func:`get_current_revision` and :func:`get_head_revision_from_alembic`. Arguments: database_url: SQLAlchemy URL for the database alembic_config_filename: config filename alembic_base_dir: directory to start in, so relative p...
[ "Returns", "a", "tuple", "of", "(", "current_revision", "head_revision", ")", ";", "see", ":", "func", ":", "get_current_revision", "and", ":", "func", ":", "get_head_revision_from_alembic", "." ]
python
train
35.939394
DataONEorg/d1_python
gmn/src/d1_gmn/app/scimeta.py
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/scimeta.py#L30-L64
def assert_valid(sysmeta_pyxb, pid): """Validate file at {sciobj_path} against schema selected via formatId and raise InvalidRequest if invalid. Validation is only performed when: - SciMeta validation is enabled - and Object size is below size limit for validation - and formatId designates obj...
[ "def", "assert_valid", "(", "sysmeta_pyxb", ",", "pid", ")", ":", "if", "not", "(", "_is_validation_enabled", "(", ")", "and", "_is_installed_scimeta_format_id", "(", "sysmeta_pyxb", ")", ")", ":", "return", "if", "_is_above_size_limit", "(", "sysmeta_pyxb", ")", ...
Validate file at {sciobj_path} against schema selected via formatId and raise InvalidRequest if invalid. Validation is only performed when: - SciMeta validation is enabled - and Object size is below size limit for validation - and formatId designates object as a Science Metadata object which is re...
[ "Validate", "file", "at", "{", "sciobj_path", "}", "against", "schema", "selected", "via", "formatId", "and", "raise", "InvalidRequest", "if", "invalid", "." ]
python
train
42.457143
LegoStormtroopr/django-spaghetti-and-meatballs
django_spaghetti/views.py
https://github.com/LegoStormtroopr/django-spaghetti-and-meatballs/blob/19240f0faeddb0e6fdd9e657cb1565d78bf43f10/django_spaghetti/views.py#L155-L176
def get_node_label(self, model): """ Defines how labels are constructed from models. Default - uses verbose name, lines breaks where sensible """ if model.is_proxy: label = "(P) %s" % (model.name.title()) else: label = "%s" % (model.name.title()) ...
[ "def", "get_node_label", "(", "self", ",", "model", ")", ":", "if", "model", ".", "is_proxy", ":", "label", "=", "\"(P) %s\"", "%", "(", "model", ".", "name", ".", "title", "(", ")", ")", "else", ":", "label", "=", "\"%s\"", "%", "(", "model", ".",...
Defines how labels are constructed from models. Default - uses verbose name, lines breaks where sensible
[ "Defines", "how", "labels", "are", "constructed", "from", "models", ".", "Default", "-", "uses", "verbose", "name", "lines", "breaks", "where", "sensible" ]
python
train
27.863636
kstaniek/condoor
condoor/actions.py
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/actions.py#L134-L140
def a_unexpected_prompt(ctx): """Provide message when received humphost prompt.""" prompt = ctx.ctrl.match.group(0) ctx.msg = "Received the jump host prompt: '{}'".format(prompt) ctx.device.connected = False ctx.finished = True raise ConnectionError("Unable to connect to the device.", ctx.ctrl.h...
[ "def", "a_unexpected_prompt", "(", "ctx", ")", ":", "prompt", "=", "ctx", ".", "ctrl", ".", "match", ".", "group", "(", "0", ")", "ctx", ".", "msg", "=", "\"Received the jump host prompt: '{}'\"", ".", "format", "(", "prompt", ")", "ctx", ".", "device", ...
Provide message when received humphost prompt.
[ "Provide", "message", "when", "received", "humphost", "prompt", "." ]
python
train
46
necaris/python3-openid
openid/extensions/draft/pape5.py
https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/openid/extensions/draft/pape5.py#L73-L80
def _generateAlias(self): """Return an unused auth level alias""" for i in range(1000): alias = 'cust%d' % (i, ) if alias not in self.auth_level_aliases: return alias raise RuntimeError('Could not find an unused alias (tried 1000!)')
[ "def", "_generateAlias", "(", "self", ")", ":", "for", "i", "in", "range", "(", "1000", ")", ":", "alias", "=", "'cust%d'", "%", "(", "i", ",", ")", "if", "alias", "not", "in", "self", ".", "auth_level_aliases", ":", "return", "alias", "raise", "Runt...
Return an unused auth level alias
[ "Return", "an", "unused", "auth", "level", "alias" ]
python
train
36.375
apple/turicreate
src/unity/python/turicreate/data_structures/sarray.py
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/data_structures/sarray.py#L4286-L4313
def cumulative_min(self): """ Return the cumulative minimum value of the elements in the SArray. Returns an SArray where each element in the output corresponds to the minimum value of all the elements preceding and including it. The SArray is expected to be of numeric type (int,...
[ "def", "cumulative_min", "(", "self", ")", ":", "from", ".", ".", "import", "extensions", "agg_op", "=", "\"__builtin__cum_min__\"", "return", "SArray", "(", "_proxy", "=", "self", ".", "__proxy__", ".", "builtin_cumulative_aggregate", "(", "agg_op", ")", ")" ]
Return the cumulative minimum value of the elements in the SArray. Returns an SArray where each element in the output corresponds to the minimum value of all the elements preceding and including it. The SArray is expected to be of numeric type (int, float). Returns ------- ...
[ "Return", "the", "cumulative", "minimum", "value", "of", "the", "elements", "in", "the", "SArray", "." ]
python
train
29.821429
bkabrda/flask-whooshee
flask_whooshee.py
https://github.com/bkabrda/flask-whooshee/blob/773fc51ed53043bd5e92c65eadef5663845ae8c4/flask_whooshee.py#L433-L454
def on_commit(self, changes): """Method that gets called when a model is changed. This serves to do the actual index writing. """ if _get_config(self)['enable_indexing'] is False: return None for wh in self.whoosheers: if not wh.auto_update: ...
[ "def", "on_commit", "(", "self", ",", "changes", ")", ":", "if", "_get_config", "(", "self", ")", "[", "'enable_indexing'", "]", "is", "False", ":", "return", "None", "for", "wh", "in", "self", ".", "whoosheers", ":", "if", "not", "wh", ".", "auto_upda...
Method that gets called when a model is changed. This serves to do the actual index writing.
[ "Method", "that", "gets", "called", "when", "a", "model", "is", "changed", ".", "This", "serves", "to", "do", "the", "actual", "index", "writing", "." ]
python
train
42.409091
Microsoft/nni
src/sdk/pynni/nni/evolution_tuner/evolution_tuner.py
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/evolution_tuner/evolution_tuner.py#L236-L278
def generate_parameters(self, parameter_id): """Returns a dict of trial (hyper-)parameters, as a serializable object. Parameters ---------- parameter_id : int Returns ------- config : dict """ if not self.population: raise Runtime...
[ "def", "generate_parameters", "(", "self", ",", "parameter_id", ")", ":", "if", "not", "self", ".", "population", ":", "raise", "RuntimeError", "(", "'The population is empty'", ")", "pos", "=", "-", "1", "for", "i", "in", "range", "(", "len", "(", "self",...
Returns a dict of trial (hyper-)parameters, as a serializable object. Parameters ---------- parameter_id : int Returns ------- config : dict
[ "Returns", "a", "dict", "of", "trial", "(", "hyper", "-", ")", "parameters", "as", "a", "serializable", "object", "." ]
python
train
35.767442
juju/python-libjuju
juju/client/_client.py
https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/client/_client.py#L22-L36
def lookup_facade(name, version): """ Given a facade name and version, attempt to pull that facade out of the correct client<version>.py file. """ for _version in range(int(version), 0, -1): try: facade = getattr(CLIENTS[str(_version)], name) return facade ex...
[ "def", "lookup_facade", "(", "name", ",", "version", ")", ":", "for", "_version", "in", "range", "(", "int", "(", "version", ")", ",", "0", ",", "-", "1", ")", ":", "try", ":", "facade", "=", "getattr", "(", "CLIENTS", "[", "str", "(", "_version", ...
Given a facade name and version, attempt to pull that facade out of the correct client<version>.py file.
[ "Given", "a", "facade", "name", "and", "version", "attempt", "to", "pull", "that", "facade", "out", "of", "the", "correct", "client<version", ">", ".", "py", "file", "." ]
python
train
31.733333
gevious/flask_slither
flask_slither/resources.py
https://github.com/gevious/flask_slither/blob/bf1fd1e58224c19883f4b19c5f727f47ee9857da/flask_slither/resources.py#L173-L188
def merge_record_data(self, changes, orig_record=None): """This method merges PATCH requests with the db record to ensure no data is lost. In addition, it is also a hook for other fields to be overwritten, to ensure immutable fields aren't changed by a request.""" curren...
[ "def", "merge_record_data", "(", "self", ",", "changes", ",", "orig_record", "=", "None", ")", ":", "current_app", ".", "logger", ".", "info", "(", "\"Merging request data with db record\"", ")", "current_app", ".", "logger", ".", "debug", "(", "\"orig_record: {}\...
This method merges PATCH requests with the db record to ensure no data is lost. In addition, it is also a hook for other fields to be overwritten, to ensure immutable fields aren't changed by a request.
[ "This", "method", "merges", "PATCH", "requests", "with", "the", "db", "record", "to", "ensure", "no", "data", "is", "lost", ".", "In", "addition", "it", "is", "also", "a", "hook", "for", "other", "fields", "to", "be", "overwritten", "to", "ensure", "immu...
python
train
50.5
ibis-project/ibis
ibis/expr/api.py
https://github.com/ibis-project/ibis/blob/1e39a5fd9ef088b45c155e8a5f541767ee8ef2e7/ibis/expr/api.py#L2146-L2171
def _string_like(self, patterns): """ Wildcard fuzzy matching function equivalent to the SQL LIKE directive. Use % as a multiple-character wildcard or _ (underscore) as a single-character wildcard. Use re_search or rlike for regex-based matching. Parameters ---------- pattern : str or ...
[ "def", "_string_like", "(", "self", ",", "patterns", ")", ":", "return", "functools", ".", "reduce", "(", "operator", ".", "or_", ",", "(", "ops", ".", "StringSQLLike", "(", "self", ",", "pattern", ")", ".", "to_expr", "(", ")", "for", "pattern", "in",...
Wildcard fuzzy matching function equivalent to the SQL LIKE directive. Use % as a multiple-character wildcard or _ (underscore) as a single-character wildcard. Use re_search or rlike for regex-based matching. Parameters ---------- pattern : str or List[str] A pattern or list of pattern...
[ "Wildcard", "fuzzy", "matching", "function", "equivalent", "to", "the", "SQL", "LIKE", "directive", ".", "Use", "%", "as", "a", "multiple", "-", "character", "wildcard", "or", "_", "(", "underscore", ")", "as", "a", "single", "-", "character", "wildcard", ...
python
train
28.461538
Duke-GCB/DukeDSClient
ddsc/core/ddsapi.py
https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/ddsapi.py#L565-L576
def update_file(self, file_id, upload_id): """ Send PUT request to /files/{file_id} to update the file contents to upload_id and sets a label. :param file_id: str uuid of file :param upload_id: str uuid of the upload where all the file chunks where uploaded :param label: str shor...
[ "def", "update_file", "(", "self", ",", "file_id", ",", "upload_id", ")", ":", "put_data", "=", "{", "\"upload[id]\"", ":", "upload_id", ",", "}", "return", "self", ".", "_put", "(", "\"/files/\"", "+", "file_id", ",", "put_data", ",", "content_type", "=",...
Send PUT request to /files/{file_id} to update the file contents to upload_id and sets a label. :param file_id: str uuid of file :param upload_id: str uuid of the upload where all the file chunks where uploaded :param label: str short display label for the file :return: requests.Response...
[ "Send", "PUT", "request", "to", "/", "files", "/", "{", "file_id", "}", "to", "update", "the", "file", "contents", "to", "upload_id", "and", "sets", "a", "label", ".", ":", "param", "file_id", ":", "str", "uuid", "of", "file", ":", "param", "upload_id"...
python
train
47.666667
hhatto/autopep8
autopep8.py
https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L648-L664
def fix_e125(self, result): """Fix indentation undistinguish from the next logical line.""" num_indent_spaces = int(result['info'].split()[1]) line_index = result['line'] - 1 target = self.source[line_index] spaces_to_add = num_indent_spaces - len(_get_indentation(target)) ...
[ "def", "fix_e125", "(", "self", ",", "result", ")", ":", "num_indent_spaces", "=", "int", "(", "result", "[", "'info'", "]", ".", "split", "(", ")", "[", "1", "]", ")", "line_index", "=", "result", "[", "'line'", "]", "-", "1", "target", "=", "self...
Fix indentation undistinguish from the next logical line.
[ "Fix", "indentation", "undistinguish", "from", "the", "next", "logical", "line", "." ]
python
train
41.294118
RRZE-HPC/kerncraft
kerncraft/kernel.py
https://github.com/RRZE-HPC/kerncraft/blob/c60baf8043e4da8d8d66da7575021c2f4c6c78af/kerncraft/kernel.py#L454-L465
def global_iterator(self): """ Return global iterator sympy expression """ global_iterator = sympy.Integer(0) total_length = sympy.Integer(1) for var_name, start, end, incr in reversed(self._loop_stack): loop_var = symbol_pos_int(var_name) length =...
[ "def", "global_iterator", "(", "self", ")", ":", "global_iterator", "=", "sympy", ".", "Integer", "(", "0", ")", "total_length", "=", "sympy", ".", "Integer", "(", "1", ")", "for", "var_name", ",", "start", ",", "end", ",", "incr", "in", "reversed", "(...
Return global iterator sympy expression
[ "Return", "global", "iterator", "sympy", "expression" ]
python
test
40.916667
twisted/mantissa
xmantissa/people.py
https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/people.py#L1647-L1654
def getImportPeople(self): """ Return an L{ImportPeopleWidget} which is a child of this fragment and which will add people to C{self.organizer}. """ fragment = ImportPeopleWidget(self.organizer) fragment.setFragmentParent(self) return fragment
[ "def", "getImportPeople", "(", "self", ")", ":", "fragment", "=", "ImportPeopleWidget", "(", "self", ".", "organizer", ")", "fragment", ".", "setFragmentParent", "(", "self", ")", "return", "fragment" ]
Return an L{ImportPeopleWidget} which is a child of this fragment and which will add people to C{self.organizer}.
[ "Return", "an", "L", "{", "ImportPeopleWidget", "}", "which", "is", "a", "child", "of", "this", "fragment", "and", "which", "will", "add", "people", "to", "C", "{", "self", ".", "organizer", "}", "." ]
python
train
36.5
pypa/pipenv
pipenv/patched/notpip/_vendor/html5lib/serializer.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/html5lib/serializer.py#L375-L398
def render(self, treewalker, encoding=None): """Serializes the stream from the treewalker into a string :arg treewalker: the treewalker to serialize :arg encoding: the string encoding to use :returns: the serialized tree Example: >>> from html5lib import parse, getTr...
[ "def", "render", "(", "self", ",", "treewalker", ",", "encoding", "=", "None", ")", ":", "if", "encoding", ":", "return", "b\"\"", ".", "join", "(", "list", "(", "self", ".", "serialize", "(", "treewalker", ",", "encoding", ")", ")", ")", "else", ":"...
Serializes the stream from the treewalker into a string :arg treewalker: the treewalker to serialize :arg encoding: the string encoding to use :returns: the serialized tree Example: >>> from html5lib import parse, getTreeWalker >>> from html5lib.serializer import HTM...
[ "Serializes", "the", "stream", "from", "the", "treewalker", "into", "a", "string" ]
python
train
34.416667
pkgw/pwkit
pwkit/io.py
https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/io.py#L308-L323
def make_relative (self, other): """Return a new path that is the equivalent of this one relative to the path *other*. Unlike :meth:`relative_to`, this will not throw an error if *self* is not a sub-path of *other*; instead, it will use ``..`` to build a relative path. This can result in...
[ "def", "make_relative", "(", "self", ",", "other", ")", ":", "if", "self", ".", "is_absolute", "(", ")", ":", "return", "self", "from", "os", ".", "path", "import", "relpath", "other", "=", "self", ".", "__class__", "(", "other", ")", "return", "self",...
Return a new path that is the equivalent of this one relative to the path *other*. Unlike :meth:`relative_to`, this will not throw an error if *self* is not a sub-path of *other*; instead, it will use ``..`` to build a relative path. This can result in invalid relative paths if *other* contains ...
[ "Return", "a", "new", "path", "that", "is", "the", "equivalent", "of", "this", "one", "relative", "to", "the", "path", "*", "other", "*", ".", "Unlike", ":", "meth", ":", "relative_to", "this", "will", "not", "throw", "an", "error", "if", "*", "self", ...
python
train
42.0625
aleju/imgaug
imgaug/augmentables/polys.py
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/polys.py#L593-L636
def extract_from_image(self, image): """ Extract the image pixels within the polygon. This function will zero-pad the image if the polygon is partially/fully outside of the image. Parameters ---------- image : (H,W) ndarray or (H,W,C) ndarray The ima...
[ "def", "extract_from_image", "(", "self", ",", "image", ")", ":", "ia", ".", "do_assert", "(", "image", ".", "ndim", "in", "[", "2", ",", "3", "]", ")", "if", "len", "(", "self", ".", "exterior", ")", "<=", "2", ":", "raise", "Exception", "(", "\...
Extract the image pixels within the polygon. This function will zero-pad the image if the polygon is partially/fully outside of the image. Parameters ---------- image : (H,W) ndarray or (H,W,C) ndarray The image from which to extract the pixels within the polygon. ...
[ "Extract", "the", "image", "pixels", "within", "the", "polygon", "." ]
python
valid
33
gawel/irc3
irc3/utils.py
https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/utils.py#L240-L262
def as_list(value): """clever string spliting: .. code-block:: python >>> print(as_list('value')) ['value'] >>> print(as_list('v1 v2')) ['v1', 'v2'] >>> print(as_list(None)) [] >>> print(as_list(['v1'])) ['v1'] """ if isinstance(value, (l...
[ "def", "as_list", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "(", "list", ",", "tuple", ")", ")", ":", "return", "value", "if", "not", "value", ":", "return", "[", "]", "for", "c", "in", "'\\n '", ":", "if", "c", "in", "value"...
clever string spliting: .. code-block:: python >>> print(as_list('value')) ['value'] >>> print(as_list('v1 v2')) ['v1', 'v2'] >>> print(as_list(None)) [] >>> print(as_list(['v1'])) ['v1']
[ "clever", "string", "spliting", ":" ]
python
train
22.782609
jobovy/galpy
galpy/potential/DoubleExponentialDiskPotential.py
https://github.com/jobovy/galpy/blob/9c5b9fe65d58835624dffe432be282060918ee08/galpy/potential/DoubleExponentialDiskPotential.py#L152-L183
def _Rforce(self,R,z,phi=0.,t=0.): """ NAME: Rforce PURPOSE: evaluate radial force K_R (R,z) INPUT: R - Cylindrical Galactocentric radius z - vertical height phi - azimuth t - time OUTPUT: K_R (R,z) ...
[ "def", "_Rforce", "(", "self", ",", "R", ",", "z", ",", "phi", "=", "0.", ",", "t", "=", "0.", ")", ":", "if", "True", ":", "if", "isinstance", "(", "R", ",", "nu", ".", "ndarray", ")", ":", "if", "not", "isinstance", "(", "z", ",", "nu", "...
NAME: Rforce PURPOSE: evaluate radial force K_R (R,z) INPUT: R - Cylindrical Galactocentric radius z - vertical height phi - azimuth t - time OUTPUT: K_R (R,z) HISTORY: 2010-04-16 - Written - Bovy (N...
[ "NAME", ":", "Rforce", "PURPOSE", ":", "evaluate", "radial", "force", "K_R", "(", "R", "z", ")", "INPUT", ":", "R", "-", "Cylindrical", "Galactocentric", "radius", "z", "-", "vertical", "height", "phi", "-", "azimuth", "t", "-", "time", "OUTPUT", ":", ...
python
train
43.8125
sashka/flask-googleauth
flask_googleauth.py
https://github.com/sashka/flask-googleauth/blob/4e481d645f1bb22124a6d79c7881746004cf4369/flask_googleauth.py#L292-L304
def required(self, fn): """Request decorator. Forces authentication.""" @functools.wraps(fn) def decorated(*args, **kwargs): if (not self._check_auth() # Don't try to force authentication if the request is part # of the authentication process - otherwise...
[ "def", "required", "(", "self", ",", "fn", ")", ":", "@", "functools", ".", "wraps", "(", "fn", ")", "def", "decorated", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "(", "not", "self", ".", "_check_auth", "(", ")", "# Don't try to fo...
Request decorator. Forces authentication.
[ "Request", "decorator", ".", "Forces", "authentication", "." ]
python
train
46.538462
cloud9ers/gurumate
environment/lib/python2.7/site-packages/nose/ext/dtcompat.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/nose/ext/dtcompat.py#L2112-L2176
def DocFileSuite(*paths, **kw): """A unittest suite for one or more doctest files. The path to each doctest file is given as a string; the interpretation of that string depends on the keyword argument "module_relative". A number of options may be provided as keyword arguments: module_relative...
[ "def", "DocFileSuite", "(", "*", "paths", ",", "*", "*", "kw", ")", ":", "suite", "=", "unittest", ".", "TestSuite", "(", ")", "# We do this here so that _normalize_module is called at the right", "# level. If it were called in DocFileTest, then this function", "# would be t...
A unittest suite for one or more doctest files. The path to each doctest file is given as a string; the interpretation of that string depends on the keyword argument "module_relative". A number of options may be provided as keyword arguments: module_relative If "module_relative" is True, th...
[ "A", "unittest", "suite", "for", "one", "or", "more", "doctest", "files", "." ]
python
test
38.769231
PyCQA/pydocstyle
src/pydocstyle/parser.py
https://github.com/PyCQA/pydocstyle/blob/2549847f9efad225789f931e83dfe782418ca13e/src/pydocstyle/parser.py#L562-L571
def parse_skip_comment(self): """Parse a definition comment for noqa skips.""" skipped_error_codes = '' if self.current.kind == tk.COMMENT: if 'noqa: ' in self.current.value: skipped_error_codes = ''.join( self.current.value.split('noqa: ')[1:]) ...
[ "def", "parse_skip_comment", "(", "self", ")", ":", "skipped_error_codes", "=", "''", "if", "self", ".", "current", ".", "kind", "==", "tk", ".", "COMMENT", ":", "if", "'noqa: '", "in", "self", ".", "current", ".", "value", ":", "skipped_error_codes", "=",...
Parse a definition comment for noqa skips.
[ "Parse", "a", "definition", "comment", "for", "noqa", "skips", "." ]
python
train
44.6
osrg/ryu
ryu/lib/stplib.py
https://github.com/osrg/ryu/blob/6f906e72c92e10bd0264c9b91a2f7bb85b97780c/ryu/lib/stplib.py#L780-L788
def up(self, role, root_priority, root_times): """ A port is started in the state of LISTEN. """ self.port_priority = root_priority self.port_times = root_times state = (PORT_STATE_LISTEN if self.config_enable else PORT_STATE_DISABLE) self._change_role(role) ...
[ "def", "up", "(", "self", ",", "role", ",", "root_priority", ",", "root_times", ")", ":", "self", ".", "port_priority", "=", "root_priority", "self", ".", "port_times", "=", "root_times", "state", "=", "(", "PORT_STATE_LISTEN", "if", "self", ".", "config_ena...
A port is started in the state of LISTEN.
[ "A", "port", "is", "started", "in", "the", "state", "of", "LISTEN", "." ]
python
train
38.222222
robotpy/pyfrc
lib/pyfrc/sim/sim_manager.py
https://github.com/robotpy/pyfrc/blob/7672ea3f17c8d4b702a9f18a7372d95feee7e37d/lib/pyfrc/sim/sim_manager.py#L74-L81
def set_joystick(self, x, y, n): """ Receives joystick values from the SnakeBoard x,y Coordinates n Robot number to give it to """ self.robots[n].set_joystick(x, y)
[ "def", "set_joystick", "(", "self", ",", "x", ",", "y", ",", "n", ")", ":", "self", ".", "robots", "[", "n", "]", ".", "set_joystick", "(", "x", ",", "y", ")" ]
Receives joystick values from the SnakeBoard x,y Coordinates n Robot number to give it to
[ "Receives", "joystick", "values", "from", "the", "SnakeBoard", "x", "y", "Coordinates", "n", "Robot", "number", "to", "give", "it", "to" ]
python
train
30.25
openego/ding0
ding0/core/network/grids.py
https://github.com/openego/ding0/blob/e2d6528f96255e4bb22ba15514a4f1883564ed5d/ding0/core/network/grids.py#L856-L863
def add_station(self, lv_station): """Adds a LV station to _station and grid graph if not already existing""" if not isinstance(lv_station, LVStationDing0): raise Exception('Given LV station is not a LVStationDing0 object.') if self._station is None: self._station = lv_st...
[ "def", "add_station", "(", "self", ",", "lv_station", ")", ":", "if", "not", "isinstance", "(", "lv_station", ",", "LVStationDing0", ")", ":", "raise", "Exception", "(", "'Given LV station is not a LVStationDing0 object.'", ")", "if", "self", ".", "_station", "is"...
Adds a LV station to _station and grid graph if not already existing
[ "Adds", "a", "LV", "station", "to", "_station", "and", "grid", "graph", "if", "not", "already", "existing" ]
python
train
57.25
Radi85/Comment
comment/api/views.py
https://github.com/Radi85/Comment/blob/c3c46afe51228cd7ee4e04f5e6164fff1be3a5bc/comment/api/views.py#L34-L43
def get_queryset(self): ''' Parameters are already validated in the QuerySetPermission ''' model_type = self.request.GET.get("type") pk = self.request.GET.get("id") content_type_model = ContentType.objects.get(model=model_type.lower()) Model = content_type_model.m...
[ "def", "get_queryset", "(", "self", ")", ":", "model_type", "=", "self", ".", "request", ".", "GET", ".", "get", "(", "\"type\"", ")", "pk", "=", "self", ".", "request", ".", "GET", ".", "get", "(", "\"id\"", ")", "content_type_model", "=", "ContentTyp...
Parameters are already validated in the QuerySetPermission
[ "Parameters", "are", "already", "validated", "in", "the", "QuerySetPermission" ]
python
train
43.8
KeplerGO/K2fov
K2fov/fov.py
https://github.com/KeplerGO/K2fov/blob/fb122b35687340e0357cba9e0dd47b3be0760693/K2fov/fov.py#L361-L397
def getColRowWithinChannel(self, ra, dec, ch, wantZeroOffset=False, allowIllegalReturnValues=True): """Returns (col, row) given a (ra, dec) coordinate and channel number. """ # How close is a given ra/dec to the origin of a KeplerModule? x, y = self.default...
[ "def", "getColRowWithinChannel", "(", "self", ",", "ra", ",", "dec", ",", "ch", ",", "wantZeroOffset", "=", "False", ",", "allowIllegalReturnValues", "=", "True", ")", ":", "# How close is a given ra/dec to the origin of a KeplerModule?", "x", ",", "y", "=", "self",...
Returns (col, row) given a (ra, dec) coordinate and channel number.
[ "Returns", "(", "col", "row", ")", "given", "a", "(", "ra", "dec", ")", "coordinate", "and", "channel", "number", "." ]
python
train
42.594595
invoice-x/invoice2data
src/invoice2data/input/tesseract.py
https://github.com/invoice-x/invoice2data/blob/d97fdc5db9c1844fd77fa64f8ea7c42fefd0ba20/src/invoice2data/input/tesseract.py#L4-L38
def to_text(path): """Wraps Tesseract OCR. Parameters ---------- path : str path of electronic invoice in JPG or PNG format Returns ------- extracted_str : str returns extracted text from image in JPG or PNG format """ import subprocess from distutils import sp...
[ "def", "to_text", "(", "path", ")", ":", "import", "subprocess", "from", "distutils", "import", "spawn", "# Check for dependencies. Needs Tesseract and Imagemagick installed.", "if", "not", "spawn", ".", "find_executable", "(", "'tesseract'", ")", ":", "raise", "Environ...
Wraps Tesseract OCR. Parameters ---------- path : str path of electronic invoice in JPG or PNG format Returns ------- extracted_str : str returns extracted text from image in JPG or PNG format
[ "Wraps", "Tesseract", "OCR", "." ]
python
train
27.971429
jwkvam/bowtie
bowtie/_app.py
https://github.com/jwkvam/bowtie/blob/c494850671ac805bf186fbf2bdb07d2a34ae876d/bowtie/_app.py#L161-L166
def cells(self) -> Generator[Tuple[int, int], None, None]: """Generate cells in span.""" yield from itertools.product( range(self.row_start, self.row_end), range(self.column_start, self.column_end) )
[ "def", "cells", "(", "self", ")", "->", "Generator", "[", "Tuple", "[", "int", ",", "int", "]", ",", "None", ",", "None", "]", ":", "yield", "from", "itertools", ".", "product", "(", "range", "(", "self", ".", "row_start", ",", "self", ".", "row_en...
Generate cells in span.
[ "Generate", "cells", "in", "span", "." ]
python
train
40.333333
shazow/workerpool
samples/blockingworker.py
https://github.com/shazow/workerpool/blob/2c5b29ec64ffbc94fc3623a4531eaf7c7c1a9ab5/samples/blockingworker.py#L22-L34
def contract(self, jobs, result): """ Perform a contract on a number of jobs and block until a result is retrieved for each job. """ for j in jobs: WorkerPool.put(self, j) r = [] for i in xrange(len(jobs)): r.append(result.get()) ...
[ "def", "contract", "(", "self", ",", "jobs", ",", "result", ")", ":", "for", "j", "in", "jobs", ":", "WorkerPool", ".", "put", "(", "self", ",", "j", ")", "r", "=", "[", "]", "for", "i", "in", "xrange", "(", "len", "(", "jobs", ")", ")", ":",...
Perform a contract on a number of jobs and block until a result is retrieved for each job.
[ "Perform", "a", "contract", "on", "a", "number", "of", "jobs", "and", "block", "until", "a", "result", "is", "retrieved", "for", "each", "job", "." ]
python
train
24.307692
baruwa-enterprise/BaruwaAPI
BaruwaAPI/resource.py
https://github.com/baruwa-enterprise/BaruwaAPI/blob/53335b377ccfd388e42f4f240f181eed72f51180/BaruwaAPI/resource.py#L290-L297
def get_authservers(self, domainid, page=None): """Get Authentication servers""" opts = {} if page: opts['page'] = page return self.api_call( ENDPOINTS['authservers']['list'], dict(domainid=domainid), **opts)
[ "def", "get_authservers", "(", "self", ",", "domainid", ",", "page", "=", "None", ")", ":", "opts", "=", "{", "}", "if", "page", ":", "opts", "[", "'page'", "]", "=", "page", "return", "self", ".", "api_call", "(", "ENDPOINTS", "[", "'authservers'", ...
Get Authentication servers
[ "Get", "Authentication", "servers" ]
python
train
33.625
kislyuk/aegea
aegea/packages/github3/repos/repo.py
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/repos/repo.py#L741-L756
def create_ref(self, ref, sha): """Create a reference in this repository. :param str ref: (required), fully qualified name of the reference, e.g. ``refs/heads/master``. If it doesn't start with ``refs`` and contain at least two slashes, GitHub's API will reject it. :para...
[ "def", "create_ref", "(", "self", ",", "ref", ",", "sha", ")", ":", "json", "=", "None", "if", "ref", "and", "ref", ".", "count", "(", "'/'", ")", ">=", "2", "and", "sha", ":", "data", "=", "{", "'ref'", ":", "ref", ",", "'sha'", ":", "sha", ...
Create a reference in this repository. :param str ref: (required), fully qualified name of the reference, e.g. ``refs/heads/master``. If it doesn't start with ``refs`` and contain at least two slashes, GitHub's API will reject it. :param str sha: (required), SHA1 value to set th...
[ "Create", "a", "reference", "in", "this", "repository", "." ]
python
train
48.125
saltstack/salt
salt/proxy/marathon.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/marathon.py#L54-L76
def ping(): ''' Is the marathon api responding? ''' try: response = salt.utils.http.query( "{0}/ping".format(CONFIG[CONFIG_BASE_URL]), decode_type='plain', decode=True, ) log.debug( 'marathon.info returned successfully: %s', ...
[ "def", "ping", "(", ")", ":", "try", ":", "response", "=", "salt", ".", "utils", ".", "http", ".", "query", "(", "\"{0}/ping\"", ".", "format", "(", "CONFIG", "[", "CONFIG_BASE_URL", "]", ")", ",", "decode_type", "=", "'plain'", ",", "decode", "=", "...
Is the marathon api responding?
[ "Is", "the", "marathon", "api", "responding?" ]
python
train
26.391304