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
cloudsight/cloudsight-python
cloudsight/api.py
https://github.com/cloudsight/cloudsight-python/blob/f9bb43dfd468d5f5d50cc89bfcfb12d5c4abdb1e/cloudsight/api.py#L161-L179
def repost(self, token): """ Repost the job if it has timed out (:py:data:`cloudsight.STATUS_TIMEOUT`). :param token: Job token as returned from :py:meth:`cloudsight.API.image_request` or :py:meth:`cloudsight.API.remote_image_request` ...
[ "def", "repost", "(", "self", ",", "token", ")", ":", "url", "=", "'%s/%s/repost'", "%", "(", "REQUESTS_URL", ",", "token", ")", "response", "=", "requests", ".", "post", "(", "url", ",", "headers", "=", "{", "'Authorization'", ":", "self", ".", "auth"...
Repost the job if it has timed out (:py:data:`cloudsight.STATUS_TIMEOUT`). :param token: Job token as returned from :py:meth:`cloudsight.API.image_request` or :py:meth:`cloudsight.API.remote_image_request`
[ "Repost", "the", "job", "if", "it", "has", "timed", "out", "(", ":", "py", ":", "data", ":", "cloudsight", ".", "STATUS_TIMEOUT", ")", "." ]
python
train
33
PyconUK/ConferenceScheduler
src/conference_scheduler/converter.py
https://github.com/PyconUK/ConferenceScheduler/blob/fb139f0ef2eab5ac8f4919aa4994d94d4e040030/src/conference_scheduler/converter.py#L43-L66
def solution_to_schedule(solution, events, slots): """Convert a schedule from solution to schedule form Parameters ---------- solution : list or tuple of tuples of event index and slot index for each scheduled item events : list or tuple of :py:class:`resources.Event` instances ...
[ "def", "solution_to_schedule", "(", "solution", ",", "events", ",", "slots", ")", ":", "return", "[", "ScheduledItem", "(", "event", "=", "events", "[", "item", "[", "0", "]", "]", ",", "slot", "=", "slots", "[", "item", "[", "1", "]", "]", ")", "f...
Convert a schedule from solution to schedule form Parameters ---------- solution : list or tuple of tuples of event index and slot index for each scheduled item events : list or tuple of :py:class:`resources.Event` instances slots : list or tuple of :py:class:`resources.Slot...
[ "Convert", "a", "schedule", "from", "solution", "to", "schedule", "form" ]
python
train
25.958333
mikeboers/sitetools
sitetools/utils.py
https://github.com/mikeboers/sitetools/blob/1ec4eea6902b4a276f868a711b783dd965c123b7/sitetools/utils.py#L33-L42
def unique_list(input_, key=lambda x:x): """Return the unique elements from the input, in order.""" seen = set() output = [] for x in input_: keyx = key(x) if keyx not in seen: seen.add(keyx) output.append(x) return output
[ "def", "unique_list", "(", "input_", ",", "key", "=", "lambda", "x", ":", "x", ")", ":", "seen", "=", "set", "(", ")", "output", "=", "[", "]", "for", "x", "in", "input_", ":", "keyx", "=", "key", "(", "x", ")", "if", "keyx", "not", "in", "se...
Return the unique elements from the input, in order.
[ "Return", "the", "unique", "elements", "from", "the", "input", "in", "order", "." ]
python
train
27.3
saltstack/salt
salt/modules/zk_concurrency.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/zk_concurrency.py#L267-L320
def unlock(path, zk_hosts=None, # in case you need to unlock without having run lock (failed execution for example) identifier=None, max_concurrency=1, ephemeral_lease=False, scheme=None, profile=None, username=None, password=None,...
[ "def", "unlock", "(", "path", ",", "zk_hosts", "=", "None", ",", "# in case you need to unlock without having run lock (failed execution for example)", "identifier", "=", "None", ",", "max_concurrency", "=", "1", ",", "ephemeral_lease", "=", "False", ",", "scheme", "=",...
Remove lease from semaphore path The path in zookeeper where the lock is zk_hosts zookeeper connect string identifier Name to identify this minion, if unspecified defaults to hostname max_concurrency Maximum number of lock holders timeout timeout to wait ...
[ "Remove", "lease", "from", "semaphore" ]
python
train
32.018519
mitsei/dlkit
dlkit/handcar/learning/sessions.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/handcar/learning/sessions.py#L2178-L2212
def assign_objective_requisites(self, objective_id=None, requisite_objective_ids=None): """Creates a requirement dependency between Objective + a list of objectives. NON-standard method impl by cjshaw arg: objective_id (osid.id.Id): the Id of the dependent Objective a...
[ "def", "assign_objective_requisites", "(", "self", ",", "objective_id", "=", "None", ",", "requisite_objective_ids", "=", "None", ")", ":", "if", "objective_id", "is", "None", "or", "requisite_objective_ids", "is", "None", ":", "raise", "NullArgument", "(", ")", ...
Creates a requirement dependency between Objective + a list of objectives. NON-standard method impl by cjshaw arg: objective_id (osid.id.Id): the Id of the dependent Objective arg: requisite_objective_id (osid.id.Id): the Id of the required Objective ...
[ "Creates", "a", "requirement", "dependency", "between", "Objective", "+", "a", "list", "of", "objectives", ".", "NON", "-", "standard", "method", "impl", "by", "cjshaw" ]
python
train
44.514286
hvac/hvac
hvac/v1/__init__.py
https://github.com/hvac/hvac/blob/cce5b86889193f622c2a72a4a1b7e1c9c8aff1ce/hvac/v1/__init__.py#L1663-L1674
def transit_delete_key(self, name, mount_point='transit'): """DELETE /<mount_point>/keys/<name> :param name: :type name: :param mount_point: :type mount_point: :return: :rtype: """ url = '/v1/{0}/keys/{1}'.format(mount_point, name) return ...
[ "def", "transit_delete_key", "(", "self", ",", "name", ",", "mount_point", "=", "'transit'", ")", ":", "url", "=", "'/v1/{0}/keys/{1}'", ".", "format", "(", "mount_point", ",", "name", ")", "return", "self", ".", "_adapter", ".", "delete", "(", "url", ")" ...
DELETE /<mount_point>/keys/<name> :param name: :type name: :param mount_point: :type mount_point: :return: :rtype:
[ "DELETE", "/", "<mount_point", ">", "/", "keys", "/", "<name", ">" ]
python
train
27.833333
gbiggs/rtctree
rtctree/exec_context.py
https://github.com/gbiggs/rtctree/blob/bd725a47ac87c259c8bce06156ccc9ab71111c26/rtctree/exec_context.py#L152-L161
def kind(self): '''The kind of this execution context.''' with self._mutex: kind = self._obj.get_kind() if kind == RTC.PERIODIC: return self.PERIODIC elif kind == RTC.EVENT_DRIVEN: return self.EVENT_DRIVEN else: ...
[ "def", "kind", "(", "self", ")", ":", "with", "self", ".", "_mutex", ":", "kind", "=", "self", ".", "_obj", ".", "get_kind", "(", ")", "if", "kind", "==", "RTC", ".", "PERIODIC", ":", "return", "self", ".", "PERIODIC", "elif", "kind", "==", "RTC", ...
The kind of this execution context.
[ "The", "kind", "of", "this", "execution", "context", "." ]
python
train
33.2
poppy-project/pypot
pypot/vrep/remoteApiBindings/vrep.py
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/vrep/remoteApiBindings/vrep.py#L316-L331
def simxGetVisionSensorDepthBuffer(clientID, sensorHandle, operationMode): ''' Please have a look at the function description/documentation in the V-REP user manual ''' c_buffer = ct.POINTER(ct.c_float)() resolution = (ct.c_int*2)() ret = c_GetVisionSensorDepthBuffer(clientID, sensorHandle, res...
[ "def", "simxGetVisionSensorDepthBuffer", "(", "clientID", ",", "sensorHandle", ",", "operationMode", ")", ":", "c_buffer", "=", "ct", ".", "POINTER", "(", "ct", ".", "c_float", ")", "(", ")", "resolution", "=", "(", "ct", ".", "c_int", "*", "2", ")", "("...
Please have a look at the function description/documentation in the V-REP user manual
[ "Please", "have", "a", "look", "at", "the", "function", "description", "/", "documentation", "in", "the", "V", "-", "REP", "user", "manual" ]
python
train
39.6875
nornir-automation/nornir
nornir/core/connections.py
https://github.com/nornir-automation/nornir/blob/3425c47fd870db896cb80f619bae23bd98d50c74/nornir/core/connections.py#L85-L98
def deregister(cls, name: str) -> None: """Deregisters a registered connection plugin by its name Args: name: name of the connection plugin to deregister Raises: :obj:`nornir.core.exceptions.ConnectionPluginNotRegistered` """ if name not in cls.available...
[ "def", "deregister", "(", "cls", ",", "name", ":", "str", ")", "->", "None", ":", "if", "name", "not", "in", "cls", ".", "available", ":", "raise", "ConnectionPluginNotRegistered", "(", "f\"Connection {name!r} is not registered\"", ")", "cls", ".", "available", ...
Deregisters a registered connection plugin by its name Args: name: name of the connection plugin to deregister Raises: :obj:`nornir.core.exceptions.ConnectionPluginNotRegistered`
[ "Deregisters", "a", "registered", "connection", "plugin", "by", "its", "name" ]
python
train
32.857143
neptune-ml/steppy
steppy/adapter.py
https://github.com/neptune-ml/steppy/blob/856b95f1f5189e1d2ca122b891bc670adac9692b/steppy/adapter.py#L106-L122
def adapt(self, all_ouputs: AllOutputs) -> DataPacket: """Adapt inputs for the transformer included in the step. Args: all_ouputs: Dict of outputs from parent steps. The keys should match the names of these steps and the values should be their respective outp...
[ "def", "adapt", "(", "self", ",", "all_ouputs", ":", "AllOutputs", ")", "->", "DataPacket", ":", "adapted", "=", "{", "}", "for", "name", ",", "recipe", "in", "self", ".", "adapting_recipes", ".", "items", "(", ")", ":", "adapted", "[", "name", "]", ...
Adapt inputs for the transformer included in the step. Args: all_ouputs: Dict of outputs from parent steps. The keys should match the names of these steps and the values should be their respective outputs. Returns: Dictionary with the same keys a...
[ "Adapt", "inputs", "for", "the", "transformer", "included", "in", "the", "step", "." ]
python
train
37.764706
abseil/abseil-py
absl/flags/_flagvalues.py
https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/_flagvalues.py#L290-L314
def find_module_defining_flag(self, flagname, default=None): """Return the name of the module defining this flag, or default. Args: flagname: str, name of the flag to lookup. default: Value to return if flagname is not defined. Defaults to None. Returns: The name of the module ...
[ "def", "find_module_defining_flag", "(", "self", ",", "flagname", ",", "default", "=", "None", ")", ":", "registered_flag", "=", "self", ".", "_flags", "(", ")", ".", "get", "(", "flagname", ")", "if", "registered_flag", "is", "None", ":", "return", "defau...
Return the name of the module defining this flag, or default. Args: flagname: str, name of the flag to lookup. default: Value to return if flagname is not defined. Defaults to None. Returns: The name of the module which registered the flag with this name. If no such module ex...
[ "Return", "the", "name", "of", "the", "module", "defining", "this", "flag", "or", "default", "." ]
python
train
40.64
kadrlica/pymodeler
pymodeler/parameter.py
https://github.com/kadrlica/pymodeler/blob/f426c01416fd4b8fc3afeeb6d3b5d1cb0cb8f8e3/pymodeler/parameter.py#L627-L641
def set(self, **kwargs): """Set the value,bounds,free,errors based on corresponding kwargs The invokes hooks for type-checking and bounds-checking that may be implemented by sub-classes. """ # Probably want to reset bounds if set fails if 'bounds' in kwargs: ...
[ "def", "set", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# Probably want to reset bounds if set fails", "if", "'bounds'", "in", "kwargs", ":", "self", ".", "set_bounds", "(", "kwargs", ".", "pop", "(", "'bounds'", ")", ")", "if", "'free'", "in", "kwa...
Set the value,bounds,free,errors based on corresponding kwargs The invokes hooks for type-checking and bounds-checking that may be implemented by sub-classes.
[ "Set", "the", "value", "bounds", "free", "errors", "based", "on", "corresponding", "kwargs" ]
python
test
38.466667
tanghaibao/goatools
goatools/wr_tbl_class.py
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/wr_tbl_class.py#L55-L62
def wr_hdrs(self, worksheet, row_idx): """Print row of column headers""" for col_idx, hdr in enumerate(self.hdrs): # print("ROW({R}) COL({C}) HDR({H}) FMT({F})\n".format( # R=row_idx, C=col_idx, H=hdr, F=self.fmt_hdr)) worksheet.write(row_idx, col_idx, hdr, self.f...
[ "def", "wr_hdrs", "(", "self", ",", "worksheet", ",", "row_idx", ")", ":", "for", "col_idx", ",", "hdr", "in", "enumerate", "(", "self", ".", "hdrs", ")", ":", "# print(\"ROW({R}) COL({C}) HDR({H}) FMT({F})\\n\".format(", "# R=row_idx, C=col_idx, H=hdr, F=self.fmt_h...
Print row of column headers
[ "Print", "row", "of", "column", "headers" ]
python
train
45.5
dopefishh/pympi
pympi/Elan.py
https://github.com/dopefishh/pympi/blob/79c747cde45b5ba203ed93154d8c123ac9c3ef56/pympi/Elan.py#L1276-L1288
def rename_tier(self, id_from, id_to): """Rename a tier. Note that this renames also the child tiers that have the tier as a parent. :param str id_from: Original name of the tier. :param str id_to: Target name of the tier. :throws KeyError: If the tier doesnt' exist. """...
[ "def", "rename_tier", "(", "self", ",", "id_from", ",", "id_to", ")", ":", "childs", "=", "self", ".", "get_child_tiers_for", "(", "id_from", ")", "self", ".", "tiers", "[", "id_to", "]", "=", "self", ".", "tiers", ".", "pop", "(", "id_from", ")", "s...
Rename a tier. Note that this renames also the child tiers that have the tier as a parent. :param str id_from: Original name of the tier. :param str id_to: Target name of the tier. :throws KeyError: If the tier doesnt' exist.
[ "Rename", "a", "tier", ".", "Note", "that", "this", "renames", "also", "the", "child", "tiers", "that", "have", "the", "tier", "as", "a", "parent", "." ]
python
test
41.769231
EventTeam/beliefs
src/beliefs/cells/colors.py
https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/cells/colors.py#L70-L78
def membership_score(self, element): """ Fuzzy set gradable membership score See http://code.google.com/p/python-colormath/wiki/ColorDifferences """ other = self.coerce(element) if self.value and other.value: return 1 - (self.value.delta_e(other.value, mode='cmc', pl=...
[ "def", "membership_score", "(", "self", ",", "element", ")", ":", "other", "=", "self", ".", "coerce", "(", "element", ")", "if", "self", ".", "value", "and", "other", ".", "value", ":", "return", "1", "-", "(", "self", ".", "value", ".", "delta_e", ...
Fuzzy set gradable membership score See http://code.google.com/p/python-colormath/wiki/ColorDifferences
[ "Fuzzy", "set", "gradable", "membership", "score", "See", "http", ":", "//", "code", ".", "google", ".", "com", "/", "p", "/", "python", "-", "colormath", "/", "wiki", "/", "ColorDifferences" ]
python
train
40.666667
brocade/pynos
pynos/versions/ver_6/ver_6_0_1/yang/brocade_clock.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_clock.py#L12-L22
def clock_sa_clock_timezone(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") clock_sa = ET.SubElement(config, "clock-sa", xmlns="urn:brocade.com:mgmt:brocade-clock") clock = ET.SubElement(clock_sa, "clock") timezone = ET.SubElement(clock, "timezon...
[ "def", "clock_sa_clock_timezone", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "clock_sa", "=", "ET", ".", "SubElement", "(", "config", ",", "\"clock-sa\"", ",", "xmlns", "=", "\"urn:brocade.c...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
41
vallis/libstempo
libstempo/toasim.py
https://github.com/vallis/libstempo/blob/0b19300a9b24d64c9ddc25cd6ddbfd12b6231990/libstempo/toasim.py#L677-L701
def extrap1d(interpolator): """ Function to extend an interpolation function to an extrapolation function. :param interpolator: scipy interp1d object :returns ufunclike: extension of function to extrapolation """ xs = interpolator.x ys = interpolator.y def pointwise(x): ...
[ "def", "extrap1d", "(", "interpolator", ")", ":", "xs", "=", "interpolator", ".", "x", "ys", "=", "interpolator", ".", "y", "def", "pointwise", "(", "x", ")", ":", "if", "x", "<", "xs", "[", "0", "]", ":", "return", "ys", "[", "0", "]", "# +(x-xs...
Function to extend an interpolation function to an extrapolation function. :param interpolator: scipy interp1d object :returns ufunclike: extension of function to extrapolation
[ "Function", "to", "extend", "an", "interpolation", "function", "to", "an", "extrapolation", "function", "." ]
python
train
24.88
rodynnz/xccdf
src/xccdf/models/status.py
https://github.com/rodynnz/xccdf/blob/1b9dc2f06b5cce8db2a54c5f95a8f6bcf5cb6981/src/xccdf/models/status.py#L69-L80
def str_to_date(self): """ Returns the date attribute as a date object. :returns: Date of the status if it exists. :rtype: date or NoneType """ if hasattr(self, 'date'): return date(*list(map(int, self.date.split('-')))) else: return None
[ "def", "str_to_date", "(", "self", ")", ":", "if", "hasattr", "(", "self", ",", "'date'", ")", ":", "return", "date", "(", "*", "list", "(", "map", "(", "int", ",", "self", ".", "date", ".", "split", "(", "'-'", ")", ")", ")", ")", "else", ":",...
Returns the date attribute as a date object. :returns: Date of the status if it exists. :rtype: date or NoneType
[ "Returns", "the", "date", "attribute", "as", "a", "date", "object", "." ]
python
train
25.75
jssimporter/python-jss
jss/jssobject.py
https://github.com/jssimporter/python-jss/blob/b95185d74e0c0531b0b563f280d4129e21d5fe5d/jss/jssobject.py#L310-L352
def save(self): """Update or create a new object on the JSS. If this object is not yet on the JSS, this method will create a new object with POST, otherwise, it will try to update the existing object with PUT. Data validation is up to the client; The JSS in most cases will ...
[ "def", "save", "(", "self", ")", ":", "# Object probably exists if it has an ID (user can't assign", "# one). The only objects that don't have an ID are those that", "# cannot list.", "if", "self", ".", "can_put", "and", "(", "not", "self", ".", "can_list", "or", "self", "...
Update or create a new object on the JSS. If this object is not yet on the JSS, this method will create a new object with POST, otherwise, it will try to update the existing object with PUT. Data validation is up to the client; The JSS in most cases will at least give you some ...
[ "Update", "or", "create", "a", "new", "object", "on", "the", "JSS", "." ]
python
train
43.72093
linkedin/naarad
src/naarad/reporting/diff.py
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/reporting/diff.py#L297-L311
def check_sla(self, sla, diff_metric): """ Check whether the SLA has passed or failed """ try: if sla.display is '%': diff_val = float(diff_metric['percent_diff']) else: diff_val = float(diff_metric['absolute_diff']) except ValueError: return False if not (sla.c...
[ "def", "check_sla", "(", "self", ",", "sla", ",", "diff_metric", ")", ":", "try", ":", "if", "sla", ".", "display", "is", "'%'", ":", "diff_val", "=", "float", "(", "diff_metric", "[", "'percent_diff'", "]", ")", "else", ":", "diff_val", "=", "float", ...
Check whether the SLA has passed or failed
[ "Check", "whether", "the", "SLA", "has", "passed", "or", "failed" ]
python
valid
29.8
sephii/zipch
zipch/zipcodes.py
https://github.com/sephii/zipch/blob/a64720e8cb55d00edeab30c426791cf87bcca82a/zipch/zipcodes.py#L115-L124
def get_zipcodes_for_canton(self, canton): """ Return the list of zipcodes for the given canton code. """ zipcodes = [ zipcode for zipcode, location in self.get_locations().items() if location.canton == canton ] return zipcodes
[ "def", "get_zipcodes_for_canton", "(", "self", ",", "canton", ")", ":", "zipcodes", "=", "[", "zipcode", "for", "zipcode", ",", "location", "in", "self", ".", "get_locations", "(", ")", ".", "items", "(", ")", "if", "location", ".", "canton", "==", "cant...
Return the list of zipcodes for the given canton code.
[ "Return", "the", "list", "of", "zipcodes", "for", "the", "given", "canton", "code", "." ]
python
train
29.1
spyder-ide/spyder
spyder/widgets/mixins.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/mixins.py#L862-L868
def mouseReleaseEvent(self, event): """Go to error""" self.QT_CLASS.mouseReleaseEvent(self, event) text = self.get_line_at(event.pos()) if get_error_match(text) and not self.has_selected_text(): if self.go_to_error is not None: self.go_to_error.emit(text...
[ "def", "mouseReleaseEvent", "(", "self", ",", "event", ")", ":", "self", ".", "QT_CLASS", ".", "mouseReleaseEvent", "(", "self", ",", "event", ")", "text", "=", "self", ".", "get_line_at", "(", "event", ".", "pos", "(", ")", ")", "if", "get_error_match",...
Go to error
[ "Go", "to", "error" ]
python
train
45
ming060/robotframework-uiautomatorlibrary
uiautomatorlibrary/Mobile.py
https://github.com/ming060/robotframework-uiautomatorlibrary/blob/b70202b6a8aa68b4efd9d029c2845407fb33451a/uiautomatorlibrary/Mobile.py#L288-L294
def swipe_top(self, steps=10, *args, **selectors): """ Swipe the UI object with *selectors* from center to top See `Swipe Left` for more details. """ self.device(**selectors).swipe.up(steps=steps)
[ "def", "swipe_top", "(", "self", ",", "steps", "=", "10", ",", "*", "args", ",", "*", "*", "selectors", ")", ":", "self", ".", "device", "(", "*", "*", "selectors", ")", ".", "swipe", ".", "up", "(", "steps", "=", "steps", ")" ]
Swipe the UI object with *selectors* from center to top See `Swipe Left` for more details.
[ "Swipe", "the", "UI", "object", "with", "*", "selectors", "*", "from", "center", "to", "top" ]
python
train
33
eumis/pyviews
pyviews/rendering/pipeline.py
https://github.com/eumis/pyviews/blob/80a868242ee9cdc6f4ded594b3e0544cc238ed55/pyviews/rendering/pipeline.py#L37-L43
def get_pipeline(node: Node) -> RenderingPipeline: """Gets rendering pipeline for passed node""" pipeline = _get_registered_pipeline(node) if pipeline is None: msg = _get_pipeline_registration_error_message(node) raise RenderingError(msg) return pipeline
[ "def", "get_pipeline", "(", "node", ":", "Node", ")", "->", "RenderingPipeline", ":", "pipeline", "=", "_get_registered_pipeline", "(", "node", ")", "if", "pipeline", "is", "None", ":", "msg", "=", "_get_pipeline_registration_error_message", "(", "node", ")", "r...
Gets rendering pipeline for passed node
[ "Gets", "rendering", "pipeline", "for", "passed", "node" ]
python
train
40
inveniosoftware/invenio-migrator
invenio_migrator/cli.py
https://github.com/inveniosoftware/invenio-migrator/blob/6902c6968a39b747d15e32363f43b7dffe2622c2/invenio_migrator/cli.py#L227-L232
def loadusers(sources): """Load users.""" from .tasks.users import load_user # Cannot be executed asynchronously due to duplicate emails and usernames # which can create a racing condition. loadcommon(sources, load_user, asynchronous=False)
[ "def", "loadusers", "(", "sources", ")", ":", "from", ".", "tasks", ".", "users", "import", "load_user", "# Cannot be executed asynchronously due to duplicate emails and usernames", "# which can create a racing condition.", "loadcommon", "(", "sources", ",", "load_user", ",",...
Load users.
[ "Load", "users", "." ]
python
test
42.5
gabstopper/smc-python
smc/core/route.py
https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/core/route.py#L671-L711
def remove_route_gateway(self, element, network=None): """ Remove a route element by href or Element. Use this if you want to remove a netlink or a routing element such as BGP or OSPF. Removing is done from within the routing interface context. :: interface0 ...
[ "def", "remove_route_gateway", "(", "self", ",", "element", ",", "network", "=", "None", ")", ":", "if", "self", ".", "level", "not", "in", "(", "'interface'", ",", ")", ":", "raise", "ModificationAborted", "(", "'You must make this change from the '", "'interfa...
Remove a route element by href or Element. Use this if you want to remove a netlink or a routing element such as BGP or OSPF. Removing is done from within the routing interface context. :: interface0 = engine.routing.get(0) interface0.remove_route_gateway(StaticN...
[ "Remove", "a", "route", "element", "by", "href", "or", "Element", ".", "Use", "this", "if", "you", "want", "to", "remove", "a", "netlink", "or", "a", "routing", "element", "such", "as", "BGP", "or", "OSPF", ".", "Removing", "is", "done", "from", "withi...
python
train
43.536585
AltSchool/dynamic-rest
dynamic_rest/serializers.py
https://github.com/AltSchool/dynamic-rest/blob/5b0338c3dd8bc638d60c3bb92645857c5b89c920/dynamic_rest/serializers.py#L520-L541
def _link_fields(self): """Construct dict of name:field for linkable fields.""" query_params = self.get_request_attribute('query_params', {}) if 'exclude_links' in query_params: return {} else: all_fields = self.get_all_fields() return { ...
[ "def", "_link_fields", "(", "self", ")", ":", "query_params", "=", "self", ".", "get_request_attribute", "(", "'query_params'", ",", "{", "}", ")", "if", "'exclude_links'", "in", "query_params", ":", "return", "{", "}", "else", ":", "all_fields", "=", "self"...
Construct dict of name:field for linkable fields.
[ "Construct", "dict", "of", "name", ":", "field", "for", "linkable", "fields", "." ]
python
train
41.681818
majuss/lupupy
lupupy/devices/__init__.py
https://github.com/majuss/lupupy/blob/71af6c397837ffc393c7b8122be175602638d3c6/lupupy/devices/__init__.py#L34-L55
def refresh(self): """Refresh a device""" # new_device = {} if self.type in CONST.BINARY_SENSOR_TYPES: response = self._lupusec.get_sensors() for device in response: if device['device_id'] == self._device_id: self.update(device) ...
[ "def", "refresh", "(", "self", ")", ":", "# new_device = {}", "if", "self", ".", "type", "in", "CONST", ".", "BINARY_SENSOR_TYPES", ":", "response", "=", "self", ".", "_lupusec", ".", "get_sensors", "(", ")", "for", "device", "in", "response", ":", "if", ...
Refresh a device
[ "Refresh", "a", "device" ]
python
train
33.681818
buriburisuri/sugartensor
sugartensor/sg_data.py
https://github.com/buriburisuri/sugartensor/blob/d2c039954777c7fbe3eb0c2ae40c45c9854deb40/sugartensor/sg_data.py#L10-L29
def _data_to_tensor(data_list, batch_size, name=None): r"""Returns batch queues from the whole data. Args: data_list: A list of ndarrays. Every array must have the same size in the first dimension. batch_size: An integer. name: A name for the operations (optional). Returns: ...
[ "def", "_data_to_tensor", "(", "data_list", ",", "batch_size", ",", "name", "=", "None", ")", ":", "# convert to constant tensor", "const_list", "=", "[", "tf", ".", "constant", "(", "data", ")", "for", "data", "in", "data_list", "]", "# create queue from consta...
r"""Returns batch queues from the whole data. Args: data_list: A list of ndarrays. Every array must have the same size in the first dimension. batch_size: An integer. name: A name for the operations (optional). Returns: A list of tensors of `batch_size`.
[ "r", "Returns", "batch", "queues", "from", "the", "whole", "data", ".", "Args", ":", "data_list", ":", "A", "list", "of", "ndarrays", ".", "Every", "array", "must", "have", "the", "same", "size", "in", "the", "first", "dimension", ".", "batch_size", ":",...
python
train
38.1
exhuma/python-cluster
cluster/util.py
https://github.com/exhuma/python-cluster/blob/4c0ac14d9beafcd51f0d849151514083c296402f/cluster/util.py#L118-L124
def dotproduct(a, b): "Calculates the dotproduct between two vecors" assert(len(a) == len(b)) out = 0 for i in range(len(a)): out += a[i] * b[i] return out
[ "def", "dotproduct", "(", "a", ",", "b", ")", ":", "assert", "(", "len", "(", "a", ")", "==", "len", "(", "b", ")", ")", "out", "=", "0", "for", "i", "in", "range", "(", "len", "(", "a", ")", ")", ":", "out", "+=", "a", "[", "i", "]", "...
Calculates the dotproduct between two vecors
[ "Calculates", "the", "dotproduct", "between", "two", "vecors" ]
python
train
25.285714
sixty-north/cosmic-ray
src/cosmic_ray/cloning.py
https://github.com/sixty-north/cosmic-ray/blob/c654e074afbb7b7fcbc23359083c1287c0d3e991/src/cosmic_ray/cloning.py#L139-L162
def _build_env(venv_dir): """Create a new virtual environment in `venv_dir`. This uses the base prefix of any virtual environment that you may be using when you call this. """ # NB: We had to create the because the venv modules wasn't doing what we # needed. In particular, if we used it create ...
[ "def", "_build_env", "(", "venv_dir", ")", ":", "# NB: We had to create the because the venv modules wasn't doing what we", "# needed. In particular, if we used it create a venv from an existing venv,", "# it *always* created symlinks back to the original venv's python", "# executables. Then, when...
Create a new virtual environment in `venv_dir`. This uses the base prefix of any virtual environment that you may be using when you call this.
[ "Create", "a", "new", "virtual", "environment", "in", "venv_dir", "." ]
python
train
46.083333
mattloper/chumpy
chumpy/utils.py
https://github.com/mattloper/chumpy/blob/a3cfdb1be3c8265c369c507b22f6f3f89414c772/chumpy/utils.py#L36-L41
def dfs_do_func_on_graph(node, func, *args, **kwargs): ''' invoke func on each node of the dr graph ''' for _node in node.tree_iterator(): func(_node, *args, **kwargs)
[ "def", "dfs_do_func_on_graph", "(", "node", ",", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "for", "_node", "in", "node", ".", "tree_iterator", "(", ")", ":", "func", "(", "_node", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
invoke func on each node of the dr graph
[ "invoke", "func", "on", "each", "node", "of", "the", "dr", "graph" ]
python
train
31
inveniosoftware-attic/invenio-utils
invenio_utils/url.py
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/url.py#L470-L515
def get_canonical_and_alternates_urls( url, drop_ln=True, washed_argd=None, quote_path=False): """ Given an Invenio URL returns a tuple with two elements. The first is the canonical URL, that is the original URL with CFG_SITE_URL prefix, and where the ln= argument strippe...
[ "def", "get_canonical_and_alternates_urls", "(", "url", ",", "drop_ln", "=", "True", ",", "washed_argd", "=", "None", ",", "quote_path", "=", "False", ")", ":", "dummy_scheme", ",", "dummy_netloc", ",", "path", ",", "dummy_params", ",", "query", ",", "fragment...
Given an Invenio URL returns a tuple with two elements. The first is the canonical URL, that is the original URL with CFG_SITE_URL prefix, and where the ln= argument stripped. The second element element is mapping, language code -> alternate URL @param quote_path: if True, the path section of the given...
[ "Given", "an", "Invenio", "URL", "returns", "a", "tuple", "with", "two", "elements", ".", "The", "first", "is", "the", "canonical", "URL", "that", "is", "the", "original", "URL", "with", "CFG_SITE_URL", "prefix", "and", "where", "the", "ln", "=", "argument...
python
train
35.717391
facelessuser/pyspelling
pyspelling/filters/__init__.py
https://github.com/facelessuser/pyspelling/blob/c25d5292cc2687ad65891a12ead43f7182ca8bb3/pyspelling/filters/__init__.py#L179-L193
def _run_first(self, source_file): """Run on as first in chain.""" self.reset() self.current_encoding = self.default_encoding encoding = None try: encoding = self._detect_encoding(source_file) content = self.filter(source_file, encoding) except Un...
[ "def", "_run_first", "(", "self", ",", "source_file", ")", ":", "self", ".", "reset", "(", ")", "self", ".", "current_encoding", "=", "self", ".", "default_encoding", "encoding", "=", "None", "try", ":", "encoding", "=", "self", ".", "_detect_encoding", "(...
Run on as first in chain.
[ "Run", "on", "as", "first", "in", "chain", "." ]
python
train
35.066667
softlayer/softlayer-python
SoftLayer/managers/image.py
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/image.py#L48-L70
def list_private_images(self, guid=None, name=None, **kwargs): """List all private images. :param string guid: filter based on GUID :param string name: filter based on name :param dict \\*\\*kwargs: response-level options (mask, limit, etc.) """ if 'mask' not in kwargs: ...
[ "def", "list_private_images", "(", "self", ",", "guid", "=", "None", ",", "name", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "'mask'", "not", "in", "kwargs", ":", "kwargs", "[", "'mask'", "]", "=", "IMAGE_MASK", "_filter", "=", "utils", "....
List all private images. :param string guid: filter based on GUID :param string name: filter based on name :param dict \\*\\*kwargs: response-level options (mask, limit, etc.)
[ "List", "all", "private", "images", "." ]
python
train
35.869565
rmed/pyemtmad
pyemtmad/util.py
https://github.com/rmed/pyemtmad/blob/c21c42d0c7b50035dfed29540d7e64ab67833728/pyemtmad/util.py#L87-L107
def datetime_string(day, month, year, hour, minute): """Build a date string using the provided day, month, year numbers. Automatically adds a leading zero to ``day`` and ``month`` if they only have one digit. Args: day (int): Day number. month(int): Month number. year(int): Yea...
[ "def", "datetime_string", "(", "day", ",", "month", ",", "year", ",", "hour", ",", "minute", ")", ":", "# Overflow", "if", "hour", "<", "0", "or", "hour", ">", "23", ":", "hour", "=", "0", "if", "minute", "<", "0", "or", "minute", ">", "60", ":",...
Build a date string using the provided day, month, year numbers. Automatically adds a leading zero to ``day`` and ``month`` if they only have one digit. Args: day (int): Day number. month(int): Month number. year(int): Year number. hour (int): Hour of the day in 24h format....
[ "Build", "a", "date", "string", "using", "the", "provided", "day", "month", "year", "numbers", "." ]
python
train
31.095238
lreis2415/PyGeoC
pygeoc/utils.py
https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/pygeoc/utils.py#L240-L284
def rsquare(obsvalues, # type: Union[numpy.ndarray, List[Union[float, int]]] simvalues # type: Union[numpy.ndarray, List[Union[float, int]]] ): # type: (...) -> Union[float, numpy.ScalarType] """Calculate Coefficient of determination. Same as the square of the ...
[ "def", "rsquare", "(", "obsvalues", ",", "# type: Union[numpy.ndarray, List[Union[float, int]]]", "simvalues", "# type: Union[numpy.ndarray, List[Union[float, int]]]", ")", ":", "# type: (...) -> Union[float, numpy.ScalarType]", "if", "len", "(", "obsvalues", ")", "!=", "len", "(...
Calculate Coefficient of determination. Same as the square of the Pearson correlation coefficient (r), and, the same as the built-in Excel function RSQ(). Programmed according to equation (1) in Legates, D.R. and G.J. McCabe, 1999. Evaluating the use of "goodness of fit" measu...
[ "Calculate", "Coefficient", "of", "determination", "." ]
python
train
46.022222
swharden/SWHLab
doc/uses/EPSCs-and-IPSCs/smooth histogram method/01.py
https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/doc/uses/EPSCs-and-IPSCs/smooth histogram method/01.py#L105-L175
def analyzeSweep(abf,sweep,m1=None,m2=None,plotToo=False): """ m1 and m2, if given, are in seconds. returns [# EPSCs, # IPSCs] """ abf.setsweep(sweep) if m1 is None: m1=0 else: m1=m1*abf.pointsPerSec if m2 is None: m2=-1 else: m2=m2*abf.pointsPerSec # obtain X and Y Yorig=ab...
[ "def", "analyzeSweep", "(", "abf", ",", "sweep", ",", "m1", "=", "None", ",", "m2", "=", "None", ",", "plotToo", "=", "False", ")", ":", "abf", ".", "setsweep", "(", "sweep", ")", "if", "m1", "is", "None", ":", "m1", "=", "0", "else", ":", "m1"...
m1 and m2, if given, are in seconds. returns [# EPSCs, # IPSCs]
[ "m1", "and", "m2", "if", "given", "are", "in", "seconds", ".", "returns", "[", "#", "EPSCs", "#", "IPSCs", "]" ]
python
valid
35.28169
wcember/pypub
pypub/clean.py
https://github.com/wcember/pypub/blob/88a1adc2ccf6f02c33adea1d2d52c729128216fb/pypub/clean.py#L11-L33
def create_html_from_fragment(tag): """ Creates full html tree from a fragment. Assumes that tag should be wrapped in a body and is currently not Args: tag: a bs4.element.Tag Returns:" bs4.element.Tag: A bs4 tag representing a full html document """ try: assert isinsta...
[ "def", "create_html_from_fragment", "(", "tag", ")", ":", "try", ":", "assert", "isinstance", "(", "tag", ",", "bs4", ".", "element", ".", "Tag", ")", "except", "AssertionError", ":", "raise", "TypeError", "try", ":", "assert", "tag", ".", "find_all", "(",...
Creates full html tree from a fragment. Assumes that tag should be wrapped in a body and is currently not Args: tag: a bs4.element.Tag Returns:" bs4.element.Tag: A bs4 tag representing a full html document
[ "Creates", "full", "html", "tree", "from", "a", "fragment", ".", "Assumes", "that", "tag", "should", "be", "wrapped", "in", "a", "body", "and", "is", "currently", "not" ]
python
train
26.217391
ryanjdillon/pylleo
pylleo/lleocal.py
https://github.com/ryanjdillon/pylleo/blob/b9b999fef19eaeccce4f207ab1b6198287c1bfec/pylleo/lleocal.py#L41-L85
def read_cal(cal_yaml_path): '''Load calibration file if exists, else create Args ---- cal_yaml_path: str Path to calibration YAML file Returns ------- cal_dict: dict Key value pairs of calibration meta data ''' from collections import OrderedDict import datetim...
[ "def", "read_cal", "(", "cal_yaml_path", ")", ":", "from", "collections", "import", "OrderedDict", "import", "datetime", "import", "os", "import", "warnings", "import", "yamlord", "from", ".", "import", "utils", "def", "__create_cal", "(", "cal_yaml_path", ")", ...
Load calibration file if exists, else create Args ---- cal_yaml_path: str Path to calibration YAML file Returns ------- cal_dict: dict Key value pairs of calibration meta data
[ "Load", "calibration", "file", "if", "exists", "else", "create" ]
python
train
24.844444
seleniumbase/SeleniumBase
seleniumbase/fixtures/base_case.py
https://github.com/seleniumbase/SeleniumBase/blob/62e5b43ee1f90a9ed923841bdd53b1b38358f43a/seleniumbase/fixtures/base_case.py#L3202-L3228
def __set_last_page_screenshot(self): """ self.__last_page_screenshot is only for pytest html report logs self.__last_page_screenshot_png is for all screenshot log files """ if not self.__last_page_screenshot and ( not self.__last_page_screenshot_png): try: ...
[ "def", "__set_last_page_screenshot", "(", "self", ")", ":", "if", "not", "self", ".", "__last_page_screenshot", "and", "(", "not", "self", ".", "__last_page_screenshot_png", ")", ":", "try", ":", "element", "=", "self", ".", "driver", ".", "find_element_by_tag_n...
self.__last_page_screenshot is only for pytest html report logs self.__last_page_screenshot_png is for all screenshot log files
[ "self", ".", "__last_page_screenshot", "is", "only", "for", "pytest", "html", "report", "logs", "self", ".", "__last_page_screenshot_png", "is", "for", "all", "screenshot", "log", "files" ]
python
train
50.333333
AndrewAnnex/SpiceyPy
spiceypy/spiceypy.py
https://github.com/AndrewAnnex/SpiceyPy/blob/fc20a9b9de68b58eed5b332f0c051fb343a6e335/spiceypy/spiceypy.py#L3497-L3516
def dvcrss(s1, s2): """ Compute the cross product of two 3-dimensional vectors and the derivative of this cross product. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dvcrss_c.html :param s1: Left hand state for cross product and derivative. :type s1: 6-Element Array of floats :p...
[ "def", "dvcrss", "(", "s1", ",", "s2", ")", ":", "assert", "len", "(", "s1", ")", "is", "6", "and", "len", "(", "s2", ")", "is", "6", "s1", "=", "stypes", ".", "toDoubleVector", "(", "s1", ")", "s2", "=", "stypes", ".", "toDoubleVector", "(", "...
Compute the cross product of two 3-dimensional vectors and the derivative of this cross product. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dvcrss_c.html :param s1: Left hand state for cross product and derivative. :type s1: 6-Element Array of floats :param s2: Right hand state for cr...
[ "Compute", "the", "cross", "product", "of", "two", "3", "-", "dimensional", "vectors", "and", "the", "derivative", "of", "this", "cross", "product", "." ]
python
train
36.75
dave-shawley/glinda
glinda/content.py
https://github.com/dave-shawley/glinda/blob/6dec43549d5b1767467174aa3d7fa2425bc25f66/glinda/content.py#L74-L99
def register_text_type(content_type, default_encoding, dumper, loader): """ Register handling for a text-based content type. :param str content_type: content type to register the hooks for :param str default_encoding: encoding to use if none is present in the request :param dumper: called t...
[ "def", "register_text_type", "(", "content_type", ",", "default_encoding", ",", "dumper", ",", "loader", ")", ":", "content_type", "=", "headers", ".", "parse_content_type", "(", "content_type", ")", "content_type", ".", "parameters", ".", "clear", "(", ")", "ke...
Register handling for a text-based content type. :param str content_type: content type to register the hooks for :param str default_encoding: encoding to use if none is present in the request :param dumper: called to decode a string into a dictionary. Calling convention: ``dumper(obj_dict)....
[ "Register", "handling", "for", "a", "text", "-", "based", "content", "type", "." ]
python
train
42.269231
stephen-bunn/file-config
src/file_config/_file_config.py
https://github.com/stephen-bunn/file-config/blob/93429360c949985202e1f2b9cd0340731819ba75/src/file_config/_file_config.py#L429-L440
def from_dict(config_cls, dictionary, validate=False): """ Loads an instance of ``config_cls`` from a dictionary. :param type config_cls: The class to build an instance of :param dict dictionary: The dictionary to load from :param bool validate: Preforms validation before building ``config_cls``, ...
[ "def", "from_dict", "(", "config_cls", ",", "dictionary", ",", "validate", "=", "False", ")", ":", "return", "_build", "(", "config_cls", ",", "dictionary", ",", "validate", "=", "validate", ")" ]
Loads an instance of ``config_cls`` from a dictionary. :param type config_cls: The class to build an instance of :param dict dictionary: The dictionary to load from :param bool validate: Preforms validation before building ``config_cls``, defaults to False, optional :return: An instance of ``co...
[ "Loads", "an", "instance", "of", "config_cls", "from", "a", "dictionary", "." ]
python
train
39.25
rytilahti/python-songpal
songpal/method.py
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/method.py#L107-L115
def asdict(self) -> Dict[str, Union[Dict, Union[str, Dict]]]: """Return a dictionary describing the method. This can be used to dump the information into a JSON file. """ return { "service": self.service.name, **self.signature.serialize(), }
[ "def", "asdict", "(", "self", ")", "->", "Dict", "[", "str", ",", "Union", "[", "Dict", ",", "Union", "[", "str", ",", "Dict", "]", "]", "]", ":", "return", "{", "\"service\"", ":", "self", ".", "service", ".", "name", ",", "*", "*", "self", "....
Return a dictionary describing the method. This can be used to dump the information into a JSON file.
[ "Return", "a", "dictionary", "describing", "the", "method", "." ]
python
train
33.111111
user-cont/colin
colin/utils/cmd_tools.py
https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/utils/cmd_tools.py#L88-L97
def is_rpm_installed(): """Tests if the rpm command is present.""" try: version_result = subprocess.run(["rpm", "--usage"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) rpm_installed = not version_result.returncod...
[ "def", "is_rpm_installed", "(", ")", ":", "try", ":", "version_result", "=", "subprocess", ".", "run", "(", "[", "\"rpm\"", ",", "\"--usage\"", "]", ",", "stdout", "=", "subprocess", ".", "PIPE", ",", "stderr", "=", "subprocess", ".", "PIPE", ")", "rpm_i...
Tests if the rpm command is present.
[ "Tests", "if", "the", "rpm", "command", "is", "present", "." ]
python
train
39.7
tensorflow/tensor2tensor
tensor2tensor/layers/latent_layers.py
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/latent_layers.py#L80-L99
def multinomial_sample(x, vocab_size=None, sampling_method="random", temperature=1.0): """Multinomial sampling from a n-dimensional tensor. Args: x: Tensor of shape [..., vocab_size]. Parameterizes logits of multinomial. vocab_size: Number of classes in multinomial distribution. ...
[ "def", "multinomial_sample", "(", "x", ",", "vocab_size", "=", "None", ",", "sampling_method", "=", "\"random\"", ",", "temperature", "=", "1.0", ")", ":", "vocab_size", "=", "vocab_size", "or", "common_layers", ".", "shape_list", "(", "x", ")", "[", "-", ...
Multinomial sampling from a n-dimensional tensor. Args: x: Tensor of shape [..., vocab_size]. Parameterizes logits of multinomial. vocab_size: Number of classes in multinomial distribution. sampling_method: String, "random" or otherwise deterministic. temperature: Positive float. Returns: Tens...
[ "Multinomial", "sampling", "from", "a", "n", "-", "dimensional", "tensor", "." ]
python
train
39.05
HazyResearch/pdftotree
pdftotree/utils/img_utils.py
https://github.com/HazyResearch/pdftotree/blob/5890d668b475d5d3058d1d886aafbfd83268c440/pdftotree/utils/img_utils.py#L52-L57
def normalize_pts(pts, ymax, scaler=2): """ scales all coordinates and flip y axis due to different origin coordinates (top left vs. bottom left) """ return [(x * scaler, ymax - (y * scaler)) for x, y in pts]
[ "def", "normalize_pts", "(", "pts", ",", "ymax", ",", "scaler", "=", "2", ")", ":", "return", "[", "(", "x", "*", "scaler", ",", "ymax", "-", "(", "y", "*", "scaler", ")", ")", "for", "x", ",", "y", "in", "pts", "]" ]
scales all coordinates and flip y axis due to different origin coordinates (top left vs. bottom left)
[ "scales", "all", "coordinates", "and", "flip", "y", "axis", "due", "to", "different", "origin", "coordinates", "(", "top", "left", "vs", ".", "bottom", "left", ")" ]
python
train
37.166667
pywbem/pywbem
pywbem/mof_compiler.py
https://github.com/pywbem/pywbem/blob/e54ecb82c2211e289a268567443d60fdd489f1e4/pywbem/mof_compiler.py#L1426-L1439
def p_scope(p): """scope : ',' SCOPE '(' metaElementList ')'""" slist = p[4] scopes = OrderedDict() for i in ('CLASS', 'ASSOCIATION', 'INDICATION', 'PROPERTY', 'REFERENCE', 'METHOD', 'PARAMETER', 'ANY'): ...
[ "def", "p_scope", "(", "p", ")", ":", "slist", "=", "p", "[", "4", "]", "scopes", "=", "OrderedDict", "(", ")", "for", "i", "in", "(", "'CLASS'", ",", "'ASSOCIATION'", ",", "'INDICATION'", ",", "'PROPERTY'", ",", "'REFERENCE'", ",", "'METHOD'", ",", ...
scope : ',' SCOPE '(' metaElementList ')
[ "scope", ":", "SCOPE", "(", "metaElementList", ")" ]
python
train
25.214286
phareous/insteonlocal
insteonlocal/Switch.py
https://github.com/phareous/insteonlocal/blob/a4544a17d143fb285852cb873e862c270d55dd00/insteonlocal/Switch.py#L33-L37
def start_all_linking(self, link_type, group_id): """Start all linking""" self.logger.info("Start_all_linking for device %s type %s group %s", self.device_id, link_type, group_id) self.hub.direct_command(self.device_id, '02', '64' + link_type + group_id)
[ "def", "start_all_linking", "(", "self", ",", "link_type", ",", "group_id", ")", ":", "self", ".", "logger", ".", "info", "(", "\"Start_all_linking for device %s type %s group %s\"", ",", "self", ".", "device_id", ",", "link_type", ",", "group_id", ")", "self", ...
Start all linking
[ "Start", "all", "linking" ]
python
train
59.8
Jajcus/pyxmpp2
pyxmpp2/xmppstringprep.py
https://github.com/Jajcus/pyxmpp2/blob/14a40a3950910a9cd008b55f0d8905aa0186ce18/pyxmpp2/xmppstringprep.py#L101-L135
def prepare(self, data): """Complete string preparation procedure for 'stored' strings. (includes checks for unassigned codes) :Parameters: - `data`: Unicode string to prepare. :return: prepared string :raise StringprepError: if the preparation fails """ ...
[ "def", "prepare", "(", "self", ",", "data", ")", ":", "ret", "=", "self", ".", "cache", ".", "get", "(", "data", ")", "if", "ret", "is", "not", "None", ":", "return", "ret", "result", "=", "self", ".", "map", "(", "data", ")", "if", "self", "."...
Complete string preparation procedure for 'stored' strings. (includes checks for unassigned codes) :Parameters: - `data`: Unicode string to prepare. :return: prepared string :raise StringprepError: if the preparation fails
[ "Complete", "string", "preparation", "procedure", "for", "stored", "strings", ".", "(", "includes", "checks", "for", "unassigned", "codes", ")" ]
python
valid
35.085714
ScienceLogic/amiuploader
amiimporter/AWSUtilities.py
https://github.com/ScienceLogic/amiuploader/blob/c36c247b2226107b38571cbc6119118b1fe07182/amiimporter/AWSUtilities.py#L157-L170
def deregister_image(self, ami_id, region='us-east-1'): """ Deregister an AMI by id :param ami_id: :param region: region to deregister from :return: """ deregister_cmd = "aws ec2 --profile {} --region {} deregister-image --image-id {}"\ .format(self.aw...
[ "def", "deregister_image", "(", "self", ",", "ami_id", ",", "region", "=", "'us-east-1'", ")", ":", "deregister_cmd", "=", "\"aws ec2 --profile {} --region {} deregister-image --image-id {}\"", ".", "format", "(", "self", ".", "aws_project", ",", "region", ",", "ami_i...
Deregister an AMI by id :param ami_id: :param region: region to deregister from :return:
[ "Deregister", "an", "AMI", "by", "id", ":", "param", "ami_id", ":", ":", "param", "region", ":", "region", "to", "deregister", "from", ":", "return", ":" ]
python
train
44.642857
RudolfCardinal/pythonlib
cardinal_pythonlib/interval.py
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/interval.py#L797-L805
def total_duration(self) -> datetime.timedelta: """ Returns a ``datetime.timedelta`` object with the total sum of durations. If there is overlap, time will be double-counted, so beware! """ total = datetime.timedelta() for interval in self.intervals: total += ...
[ "def", "total_duration", "(", "self", ")", "->", "datetime", ".", "timedelta", ":", "total", "=", "datetime", ".", "timedelta", "(", ")", "for", "interval", "in", "self", ".", "intervals", ":", "total", "+=", "interval", ".", "duration", "(", ")", "retur...
Returns a ``datetime.timedelta`` object with the total sum of durations. If there is overlap, time will be double-counted, so beware!
[ "Returns", "a", "datetime", ".", "timedelta", "object", "with", "the", "total", "sum", "of", "durations", ".", "If", "there", "is", "overlap", "time", "will", "be", "double", "-", "counted", "so", "beware!" ]
python
train
39.111111
PaloAltoNetworks/pancloud
pancloud/credentials.py
https://github.com/PaloAltoNetworks/pancloud/blob/c51e4c8aca3c988c60f062291007534edcb55285/pancloud/credentials.py#L502-L533
def revoke_access_token(self, **kwargs): """Revoke access token.""" c = self.get_credentials() data = { 'client_id': c.client_id, 'client_secret': c.client_secret, 'token': c.access_token, 'token_type_hint': 'access_token' } r = sel...
[ "def", "revoke_access_token", "(", "self", ",", "*", "*", "kwargs", ")", ":", "c", "=", "self", ".", "get_credentials", "(", ")", "data", "=", "{", "'client_id'", ":", "c", ".", "client_id", ",", "'client_secret'", ":", "c", ".", "client_secret", ",", ...
Revoke access token.
[ "Revoke", "access", "token", "." ]
python
train
29.6875
PythonCharmers/python-future
src/future/backports/email/_header_value_parser.py
https://github.com/PythonCharmers/python-future/blob/c423752879acc05eebc29b0bb9909327bd5c7308/src/future/backports/email/_header_value_parser.py#L1789-L1826
def get_local_part(value): """ local-part = dot-atom / quoted-string / obs-local-part """ local_part = LocalPart() leader = None if value[0] in CFWS_LEADER: leader, value = get_cfws(value) if not value: raise errors.HeaderParseError( "expected local-part but found '{...
[ "def", "get_local_part", "(", "value", ")", ":", "local_part", "=", "LocalPart", "(", ")", "leader", "=", "None", "if", "value", "[", "0", "]", "in", "CFWS_LEADER", ":", "leader", ",", "value", "=", "get_cfws", "(", "value", ")", "if", "not", "value", ...
local-part = dot-atom / quoted-string / obs-local-part
[ "local", "-", "part", "=", "dot", "-", "atom", "/", "quoted", "-", "string", "/", "obs", "-", "local", "-", "part" ]
python
train
38.5
saltstack/salt
salt/utils/win_dacl.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/win_dacl.py#L1864-L2029
def copy_security(source, target, obj_type='file', copy_owner=True, copy_group=True, copy_dacl=True, copy_sacl=True): r''' Copy the security descriptor of the Source to the Target. You can specify a s...
[ "def", "copy_security", "(", "source", ",", "target", ",", "obj_type", "=", "'file'", ",", "copy_owner", "=", "True", ",", "copy_group", "=", "True", ",", "copy_dacl", "=", "True", ",", "copy_sacl", "=", "True", ")", ":", "obj_dacl", "=", "dacl", "(", ...
r''' Copy the security descriptor of the Source to the Target. You can specify a specific portion of the security descriptor to copy using one of the `copy_*` parameters. .. note:: At least one `copy_*` parameter must be ``True`` .. note:: The user account running this command must...
[ "r", "Copy", "the", "security", "descriptor", "of", "the", "Source", "to", "the", "Target", ".", "You", "can", "specify", "a", "specific", "portion", "of", "the", "security", "descriptor", "to", "copy", "using", "one", "of", "the", "copy_", "*", "parameter...
python
train
35.060241
chimera0/accel-brain-code
Reinforcement-Learning/demo/demo_autocompletion.py
https://github.com/chimera0/accel-brain-code/blob/03661f6f544bed656269fcd4b3c23c9061629daa/Reinforcement-Learning/demo/demo_autocompletion.py#L62-L78
def extract_possible_actions(self, state_key): ''' Concreat method. Args: state_key The key of state. this value is point in map. Returns: [(x, y)] ''' if state_key in self.__state_action_list_dict: return self.__state_action_l...
[ "def", "extract_possible_actions", "(", "self", ",", "state_key", ")", ":", "if", "state_key", "in", "self", ".", "__state_action_list_dict", ":", "return", "self", ".", "__state_action_list_dict", "[", "state_key", "]", "else", ":", "action_list", "=", "[", "]"...
Concreat method. Args: state_key The key of state. this value is point in map. Returns: [(x, y)]
[ "Concreat", "method", "." ]
python
train
33.647059
googleapis/google-cloud-python
datastore/google/cloud/datastore/_http.py
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/datastore/google/cloud/datastore/_http.py#L38-L78
def _request(http, project, method, data, base_url): """Make a request over the Http transport to the Cloud Datastore API. :type http: :class:`requests.Session` :param http: HTTP object to make requests. :type project: str :param project: The project to make the request for. :type method: str...
[ "def", "_request", "(", "http", ",", "project", ",", "method", ",", "data", ",", "base_url", ")", ":", "headers", "=", "{", "\"Content-Type\"", ":", "\"application/x-protobuf\"", ",", "\"User-Agent\"", ":", "connection_module", ".", "DEFAULT_USER_AGENT", ",", "c...
Make a request over the Http transport to the Cloud Datastore API. :type http: :class:`requests.Session` :param http: HTTP object to make requests. :type project: str :param project: The project to make the request for. :type method: str :param method: The API call method name (ie, ``runQuery...
[ "Make", "a", "request", "over", "the", "Http", "transport", "to", "the", "Cloud", "Datastore", "API", "." ]
python
train
34.02439
pepkit/peppy
peppy/utils.py
https://github.com/pepkit/peppy/blob/f0f725e1557936b81c86573a77400e6f8da78f05/peppy/utils.py#L121-L128
def expandpath(path): """ Expand a filesystem path that may or may not contain user/env vars. :param str path: path to expand :return str: expanded version of input path """ return os.path.expandvars(os.path.expanduser(path)).replace("//", "/")
[ "def", "expandpath", "(", "path", ")", ":", "return", "os", ".", "path", ".", "expandvars", "(", "os", ".", "path", ".", "expanduser", "(", "path", ")", ")", ".", "replace", "(", "\"//\"", ",", "\"/\"", ")" ]
Expand a filesystem path that may or may not contain user/env vars. :param str path: path to expand :return str: expanded version of input path
[ "Expand", "a", "filesystem", "path", "that", "may", "or", "may", "not", "contain", "user", "/", "env", "vars", "." ]
python
train
32.75
turicas/rows
rows/utils.py
https://github.com/turicas/rows/blob/c74da41ae9ed091356b803a64f8a30c641c5fc45/rows/utils.py#L983-L1079
def generate_schema(table, export_fields, output_format, output_fobj): """Generate table schema for a specific output format and write Current supported output formats: 'txt', 'sql' and 'django'. The table name and all fields names pass for a slugifying process (table name is taken from file name). ...
[ "def", "generate_schema", "(", "table", ",", "export_fields", ",", "output_format", ",", "output_fobj", ")", ":", "if", "output_format", "in", "(", "\"csv\"", ",", "\"txt\"", ")", ":", "from", "rows", "import", "plugins", "data", "=", "[", "{", "\"field_name...
Generate table schema for a specific output format and write Current supported output formats: 'txt', 'sql' and 'django'. The table name and all fields names pass for a slugifying process (table name is taken from file name).
[ "Generate", "table", "schema", "for", "a", "specific", "output", "format", "and", "write" ]
python
train
37.041237
peterldowns/python-mustache
mustache/loading.py
https://github.com/peterldowns/python-mustache/blob/ea3753696ea9886b6eb39cc5de27db7054adc069/mustache/loading.py#L26-L42
def get_abs_template_path(template_name, directory, extension): """ Given a template name, a directory, and an extension, return the absolute path to the template. """ # Get the relative path relative_path = join(directory, template_name) file_with_ext = template_name if extension: # If...
[ "def", "get_abs_template_path", "(", "template_name", ",", "directory", ",", "extension", ")", ":", "# Get the relative path", "relative_path", "=", "join", "(", "directory", ",", "template_name", ")", "file_with_ext", "=", "template_name", "if", "extension", ":", "...
Given a template name, a directory, and an extension, return the absolute path to the template.
[ "Given", "a", "template", "name", "a", "directory", "and", "an", "extension", "return", "the", "absolute", "path", "to", "the", "template", "." ]
python
train
40.176471
blockstack/blockstack-files
blockstack_file/blockstack_file.py
https://github.com/blockstack/blockstack-files/blob/8d88cc48bdf8ed57f17d4bba860e972bde321921/blockstack_file/blockstack_file.py#L249-L273
def file_key_regenerate( blockchain_id, hostname, config_path=CONFIG_PATH, wallet_keys=None ): """ Generate a new encryption key. Retire the existing key, if it exists. Return {'status': True} on success Return {'error': ...} on error """ config_dir = os.path.dirname(config_path) cu...
[ "def", "file_key_regenerate", "(", "blockchain_id", ",", "hostname", ",", "config_path", "=", "CONFIG_PATH", ",", "wallet_keys", "=", "None", ")", ":", "config_dir", "=", "os", ".", "path", ".", "dirname", "(", "config_path", ")", "current_key", "=", "file_key...
Generate a new encryption key. Retire the existing key, if it exists. Return {'status': True} on success Return {'error': ...} on error
[ "Generate", "a", "new", "encryption", "key", ".", "Retire", "the", "existing", "key", "if", "it", "exists", ".", "Return", "{", "status", ":", "True", "}", "on", "success", "Return", "{", "error", ":", "...", "}", "on", "error" ]
python
train
46.16
user-cont/colin
colin/core/target.py
https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/core/target.py#L383-L387
def tmpdir(self): """ Temporary directory holding all the runtime data. """ if self._tmpdir is None: self._tmpdir = mkdtemp(prefix="colin-", dir="/var/tmp") return self._tmpdir
[ "def", "tmpdir", "(", "self", ")", ":", "if", "self", ".", "_tmpdir", "is", "None", ":", "self", ".", "_tmpdir", "=", "mkdtemp", "(", "prefix", "=", "\"colin-\"", ",", "dir", "=", "\"/var/tmp\"", ")", "return", "self", ".", "_tmpdir" ]
Temporary directory holding all the runtime data.
[ "Temporary", "directory", "holding", "all", "the", "runtime", "data", "." ]
python
train
41.6
Pajinek/vhm
server/apps/core/scripts/generate.py
https://github.com/Pajinek/vhm/blob/e323e99855fd5c40fd61fba87c2646a1165505ed/server/apps/core/scripts/generate.py#L45-L92
def creatauth(name, homedir): """ Function create user in linux for group and set homedir. Function return gid and uid.""" uid, gid = [None, None] # get information about user command = "id %s" % (name) data = commands.getstatusoutput(command) if data[0] > 0: # create new system user ...
[ "def", "creatauth", "(", "name", ",", "homedir", ")", ":", "uid", ",", "gid", "=", "[", "None", ",", "None", "]", "# get information about user", "command", "=", "\"id %s\"", "%", "(", "name", ")", "data", "=", "commands", ".", "getstatusoutput", "(", "c...
Function create user in linux for group and set homedir. Function return gid and uid.
[ "Function", "create", "user", "in", "linux", "for", "group", "and", "set", "homedir", ".", "Function", "return", "gid", "and", "uid", "." ]
python
train
29.416667
raphaelvallat/pingouin
pingouin/correlation.py
https://github.com/raphaelvallat/pingouin/blob/58b19fa4fffbfe09d58b456e3926a148249e4d9b/pingouin/correlation.py#L148-L193
def shepherd(x, y, n_boot=200): """ Shepherd's Pi correlation, equivalent to Spearman's rho after outliers removal. Parameters ---------- x, y : array_like First and second set of observations. x and y must be independent. n_boot : int Number of bootstrap samples to calculat...
[ "def", "shepherd", "(", "x", ",", "y", ",", "n_boot", "=", "200", ")", ":", "from", "scipy", ".", "stats", "import", "spearmanr", "X", "=", "np", ".", "column_stack", "(", "(", "x", ",", "y", ")", ")", "# Bootstrapping on Mahalanobis distance", "m", "=...
Shepherd's Pi correlation, equivalent to Spearman's rho after outliers removal. Parameters ---------- x, y : array_like First and second set of observations. x and y must be independent. n_boot : int Number of bootstrap samples to calculate. Returns ------- r : float ...
[ "Shepherd", "s", "Pi", "correlation", "equivalent", "to", "Spearman", "s", "rho", "after", "outliers", "removal", "." ]
python
train
24.913043
ranaroussi/pywallet
pywallet/utils/bip32.py
https://github.com/ranaroussi/pywallet/blob/206ff224389c490d8798f660c9e79fe97ebb64cf/pywallet/utils/bip32.py#L501-L578
def deserialize(cls, key, network="bitcoin_testnet"): """Load the ExtendedBip32Key from a hex key. The key consists of * 4 byte version bytes (network key) * 1 byte depth: - 0x00 for master nodes, - 0x01 for level-1 descendants, .... ...
[ "def", "deserialize", "(", "cls", ",", "key", ",", "network", "=", "\"bitcoin_testnet\"", ")", ":", "network", "=", "Wallet", ".", "get_network", "(", "network", ")", "if", "len", "(", "key", ")", "in", "[", "78", ",", "(", "78", "+", "32", ")", "]...
Load the ExtendedBip32Key from a hex key. The key consists of * 4 byte version bytes (network key) * 1 byte depth: - 0x00 for master nodes, - 0x01 for level-1 descendants, .... * 4 byte fingerprint of the parent's key (0x00000000 if master ke...
[ "Load", "the", "ExtendedBip32Key", "from", "a", "hex", "key", "." ]
python
train
42.538462
phareous/insteonlocal
insteonlocal/Hub.py
https://github.com/phareous/insteonlocal/blob/a4544a17d143fb285852cb873e862c270d55dd00/insteonlocal/Hub.py#L439-L469
def get_command_response_from_cache(self, device_id, command, command2): """Gets response""" key = self.create_key_from_command(command, command2) command_cache = self.get_cache_from_file(device_id) if device_id not in command_cache: command_cache[device_id] = {} ...
[ "def", "get_command_response_from_cache", "(", "self", ",", "device_id", ",", "command", ",", "command2", ")", ":", "key", "=", "self", ".", "create_key_from_command", "(", "command", ",", "command2", ")", "command_cache", "=", "self", ".", "get_cache_from_file", ...
Gets response
[ "Gets", "response" ]
python
train
38.677419
apple/turicreate
deps/src/boost_1_68_0/tools/build/src/build/virtual_target.py
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/boost_1_68_0/tools/build/src/build/virtual_target.py#L863-L884
def actualize_source_type (self, sources, prop_set): """ Helper for 'actualize_sources'. For each passed source, actualizes it with the appropriate scanner. Returns the actualized virtual targets. """ assert is_iterable_typed(sources, VirtualTarget) assert isinsta...
[ "def", "actualize_source_type", "(", "self", ",", "sources", ",", "prop_set", ")", ":", "assert", "is_iterable_typed", "(", "sources", ",", "VirtualTarget", ")", "assert", "isinstance", "(", "prop_set", ",", "property_set", ".", "PropertySet", ")", "result", "="...
Helper for 'actualize_sources'. For each passed source, actualizes it with the appropriate scanner. Returns the actualized virtual targets.
[ "Helper", "for", "actualize_sources", ".", "For", "each", "passed", "source", "actualizes", "it", "with", "the", "appropriate", "scanner", ".", "Returns", "the", "actualized", "virtual", "targets", "." ]
python
train
32.454545
Neurita/boyle
boyle/dicom/convert.py
https://github.com/Neurita/boyle/blob/2dae7199849395a209c887d5f30506e1de8a9ad9/boyle/dicom/convert.py#L193-L229
def remove_dcm2nii_underprocessed(filepaths): """ Return a subset of `filepaths`. Keep only the files that have a basename longer than the others with same suffix. This works based on that dcm2nii appends a preffix character for each processing step it does automatically in the DICOM to NifTI conversion...
[ "def", "remove_dcm2nii_underprocessed", "(", "filepaths", ")", ":", "cln_flist", "=", "[", "]", "# sort them by size", "len_sorted", "=", "sorted", "(", "filepaths", ",", "key", "=", "len", ")", "for", "idx", ",", "fpath", "in", "enumerate", "(", "len_sorted",...
Return a subset of `filepaths`. Keep only the files that have a basename longer than the others with same suffix. This works based on that dcm2nii appends a preffix character for each processing step it does automatically in the DICOM to NifTI conversion. Parameters ---------- filepaths: iterab...
[ "Return", "a", "subset", "of", "filepaths", ".", "Keep", "only", "the", "files", "that", "have", "a", "basename", "longer", "than", "the", "others", "with", "same", "suffix", ".", "This", "works", "based", "on", "that", "dcm2nii", "appends", "a", "preffix"...
python
valid
27.810811
Murali-group/halp
halp/directed_hypergraph.py
https://github.com/Murali-group/halp/blob/6eb27466ba84e2281e18f93b62aae5efb21ef8b3/halp/directed_hypergraph.py#L833-L844
def get_forward_star(self, node): """Given a node, get a copy of that node's forward star. :param node: node to retrieve the forward-star of. :returns: set -- set of hyperedge_ids for the hyperedges in the node's forward star. :raises: ValueError -- No such node ...
[ "def", "get_forward_star", "(", "self", ",", "node", ")", ":", "if", "node", "not", "in", "self", ".", "_node_attributes", ":", "raise", "ValueError", "(", "\"No such node exists.\"", ")", "return", "self", ".", "_forward_star", "[", "node", "]", ".", "copy"...
Given a node, get a copy of that node's forward star. :param node: node to retrieve the forward-star of. :returns: set -- set of hyperedge_ids for the hyperedges in the node's forward star. :raises: ValueError -- No such node exists.
[ "Given", "a", "node", "get", "a", "copy", "of", "that", "node", "s", "forward", "star", "." ]
python
train
39.583333
apple/turicreate
deps/src/libxml2-2.9.1/python/libxml2.py
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/libxml2-2.9.1/python/libxml2.py#L3652-L3661
def isRef(self, doc, attr): """Determine whether an attribute is of type Ref. In case we have DTD(s) then this is simple, otherwise we use an heuristic: name Ref (upper or lowercase). """ if doc is None: doc__o = None else: doc__o = doc._o if attr is None: attr__o = ...
[ "def", "isRef", "(", "self", ",", "doc", ",", "attr", ")", ":", "if", "doc", "is", "None", ":", "doc__o", "=", "None", "else", ":", "doc__o", "=", "doc", ".", "_o", "if", "attr", "is", "None", ":", "attr__o", "=", "None", "else", ":", "attr__o", ...
Determine whether an attribute is of type Ref. In case we have DTD(s) then this is simple, otherwise we use an heuristic: name Ref (upper or lowercase).
[ "Determine", "whether", "an", "attribute", "is", "of", "type", "Ref", ".", "In", "case", "we", "have", "DTD", "(", "s", ")", "then", "this", "is", "simple", "otherwise", "we", "use", "an", "heuristic", ":", "name", "Ref", "(", "upper", "or", "lowercase...
python
train
42.6
google/grr
grr/core/grr_response_core/lib/parsers/wmi_parser.py
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/parsers/wmi_parser.py#L197-L216
def ParseMultiple(self, result_dicts): """Parse the WMI packages output.""" status = rdf_client.SoftwarePackage.InstallState.INSTALLED packages = [] for result_dict in result_dicts: result = result_dict.ToDict() # InstalledOn comes back in a godawful format such as '7/10/2013'. insta...
[ "def", "ParseMultiple", "(", "self", ",", "result_dicts", ")", ":", "status", "=", "rdf_client", ".", "SoftwarePackage", ".", "InstallState", ".", "INSTALLED", "packages", "=", "[", "]", "for", "result_dict", "in", "result_dicts", ":", "result", "=", "result_d...
Parse the WMI packages output.
[ "Parse", "the", "WMI", "packages", "output", "." ]
python
train
36.4
mikedh/trimesh
trimesh/scene/transforms.py
https://github.com/mikedh/trimesh/blob/25e059bf6d4caa74f62ffd58ce4f61a90ee4e518/trimesh/scene/transforms.py#L300-L306
def show(self): """ Plot the graph layout of the scene. """ import matplotlib.pyplot as plt nx.draw(self.transforms, with_labels=True) plt.show()
[ "def", "show", "(", "self", ")", ":", "import", "matplotlib", ".", "pyplot", "as", "plt", "nx", ".", "draw", "(", "self", ".", "transforms", ",", "with_labels", "=", "True", ")", "plt", ".", "show", "(", ")" ]
Plot the graph layout of the scene.
[ "Plot", "the", "graph", "layout", "of", "the", "scene", "." ]
python
train
26.714286
rix0rrr/gcl
gcl/query.py
https://github.com/rix0rrr/gcl/blob/4e3bccc978a9c60aaaffd20f6f291c4d23775cdf/gcl/query.py#L173-L186
def ldSet(self, what, key, value): """List/dictionary-aware set.""" if isListKey(key): # Make sure we keep the indexes consistent, insert missing_values # as necessary. We do remember the lists, so that we can remove # missing values after inserting all values from all selectors. self.li...
[ "def", "ldSet", "(", "self", ",", "what", ",", "key", ",", "value", ")", ":", "if", "isListKey", "(", "key", ")", ":", "# Make sure we keep the indexes consistent, insert missing_values", "# as necessary. We do remember the lists, so that we can remove", "# missing values aft...
List/dictionary-aware set.
[ "List", "/", "dictionary", "-", "aware", "set", "." ]
python
train
35.285714
AkihikoITOH/capybara
capybara/virtualenv/lib/python2.7/site-packages/pip/_vendor/_markerlib/markers.py
https://github.com/AkihikoITOH/capybara/blob/e86c2173ea386654f4ae061148e8fbe3f25e715c/capybara/virtualenv/lib/python2.7/site-packages/pip/_vendor/_markerlib/markers.py#L78-L81
def visit_Attribute(self, node): """Flatten one level of attribute access.""" new_node = ast.Name("%s.%s" % (node.value.id, node.attr), node.ctx) return ast.copy_location(new_node, node)
[ "def", "visit_Attribute", "(", "self", ",", "node", ")", ":", "new_node", "=", "ast", ".", "Name", "(", "\"%s.%s\"", "%", "(", "node", ".", "value", ".", "id", ",", "node", ".", "attr", ")", ",", "node", ".", "ctx", ")", "return", "ast", ".", "co...
Flatten one level of attribute access.
[ "Flatten", "one", "level", "of", "attribute", "access", "." ]
python
test
51.75
tensorflow/cleverhans
cleverhans/attack_bundling.py
https://github.com/tensorflow/cleverhans/blob/97488e215760547b81afc53f5e5de8ba7da5bd98/cleverhans/attack_bundling.py#L490-L505
def save(criteria, report, report_path, adv_x_val): """ Saves the report and adversarial examples. :param criteria: dict, of the form returned by AttackGoal.get_criteria :param report: dict containing a confidence report :param report_path: string, filepath :param adv_x_val: numpy array containing dataset o...
[ "def", "save", "(", "criteria", ",", "report", ",", "report_path", ",", "adv_x_val", ")", ":", "print_stats", "(", "criteria", "[", "'correctness'", "]", ",", "criteria", "[", "'confidence'", "]", ",", "'bundled'", ")", "print", "(", "\"Saving to \"", "+", ...
Saves the report and adversarial examples. :param criteria: dict, of the form returned by AttackGoal.get_criteria :param report: dict containing a confidence report :param report_path: string, filepath :param adv_x_val: numpy array containing dataset of adversarial examples
[ "Saves", "the", "report", "and", "adversarial", "examples", ".", ":", "param", "criteria", ":", "dict", "of", "the", "form", "returned", "by", "AttackGoal", ".", "get_criteria", ":", "param", "report", ":", "dict", "containing", "a", "confidence", "report", ...
python
train
38.25
dshean/pygeotools
pygeotools/lib/geolib.py
https://github.com/dshean/pygeotools/blob/5ac745717c0098d01eb293ff1fe32fd7358c76ab/pygeotools/lib/geolib.py#L647-L654
def geom_transform(geom, t_srs): """Transform a geometry in place """ s_srs = geom.GetSpatialReference() if not s_srs.IsSame(t_srs): ct = osr.CoordinateTransformation(s_srs, t_srs) geom.Transform(ct) geom.AssignSpatialReference(t_srs)
[ "def", "geom_transform", "(", "geom", ",", "t_srs", ")", ":", "s_srs", "=", "geom", ".", "GetSpatialReference", "(", ")", "if", "not", "s_srs", ".", "IsSame", "(", "t_srs", ")", ":", "ct", "=", "osr", ".", "CoordinateTransformation", "(", "s_srs", ",", ...
Transform a geometry in place
[ "Transform", "a", "geometry", "in", "place" ]
python
train
33.375
AkihikoITOH/capybara
capybara/virtualenv/lib/python2.7/site-packages/pip/_vendor/pkg_resources/__init__.py
https://github.com/AkihikoITOH/capybara/blob/e86c2173ea386654f4ae061148e8fbe3f25e715c/capybara/virtualenv/lib/python2.7/site-packages/pip/_vendor/pkg_resources/__init__.py#L2968-L2973
def _get_mro(cls): """Get an mro for a type or classic class""" if not isinstance(cls, type): class cls(cls, object): pass return cls.__mro__[1:] return cls.__mro__
[ "def", "_get_mro", "(", "cls", ")", ":", "if", "not", "isinstance", "(", "cls", ",", "type", ")", ":", "class", "cls", "(", "cls", ",", "object", ")", ":", "pass", "return", "cls", ".", "__mro__", "[", "1", ":", "]", "return", "cls", ".", "__mro_...
Get an mro for a type or classic class
[ "Get", "an", "mro", "for", "a", "type", "or", "classic", "class" ]
python
test
31.166667
CalebBell/thermo
thermo/mixture.py
https://github.com/CalebBell/thermo/blob/3857ed023a3e64fd3039a32d53576c24990ef1c3/thermo/mixture.py#L2194-L2209
def mul(self): r'''Viscosity of the mixture in the liquid phase at its current temperature, pressure, and composition in units of [Pa*s]. For calculation of this property at other temperatures and pressures, or specifying manually the method used to calculate it, and more - see ...
[ "def", "mul", "(", "self", ")", ":", "return", "self", ".", "ViscosityLiquidMixture", "(", "self", ".", "T", ",", "self", ".", "P", ",", "self", ".", "zs", ",", "self", ".", "ws", ")" ]
r'''Viscosity of the mixture in the liquid phase at its current temperature, pressure, and composition in units of [Pa*s]. For calculation of this property at other temperatures and pressures, or specifying manually the method used to calculate it, and more - see the object oriented int...
[ "r", "Viscosity", "of", "the", "mixture", "in", "the", "liquid", "phase", "at", "its", "current", "temperature", "pressure", "and", "composition", "in", "units", "of", "[", "Pa", "*", "s", "]", "." ]
python
valid
42.125
sernst/cauldron
cauldron/cli/threads.py
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/cli/threads.py#L42-L49
def is_running(self) -> bool: """Specifies whether or not the thread is running""" return ( self._has_started and self.is_alive() or self.completed_at is None or (datetime.utcnow() - self.completed_at).total_seconds() < 0.5 )
[ "def", "is_running", "(", "self", ")", "->", "bool", ":", "return", "(", "self", ".", "_has_started", "and", "self", ".", "is_alive", "(", ")", "or", "self", ".", "completed_at", "is", "None", "or", "(", "datetime", ".", "utcnow", "(", ")", "-", "sel...
Specifies whether or not the thread is running
[ "Specifies", "whether", "or", "not", "the", "thread", "is", "running" ]
python
train
36.25
user-cont/colin
colin/utils/cont.py
https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/utils/cont.py#L63-L86
def name(self): """ Get the string representation of the image (registry, namespace, repository and digest together). :return: str """ name_parts = [] if self.registry: name_parts.append(self.registry) if self.namespace: name_part...
[ "def", "name", "(", "self", ")", ":", "name_parts", "=", "[", "]", "if", "self", ".", "registry", ":", "name_parts", ".", "append", "(", "self", ".", "registry", ")", "if", "self", ".", "namespace", ":", "name_parts", ".", "append", "(", "self", ".",...
Get the string representation of the image (registry, namespace, repository and digest together). :return: str
[ "Get", "the", "string", "representation", "of", "the", "image", "(", "registry", "namespace", "repository", "and", "digest", "together", ")", "." ]
python
train
24.625
mitsei/dlkit
dlkit/json_/assessment/objects.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/objects.py#L1881-L1891
def get_deadline_metadata(self): """Gets the metadata for the assessment deadline. return: (osid.Metadata) - metadata for the end time *compliance: mandatory -- This method must be implemented.* """ # Implemented from template for osid.resource.ResourceForm.get_group_metadata_t...
[ "def", "get_deadline_metadata", "(", "self", ")", ":", "# Implemented from template for osid.resource.ResourceForm.get_group_metadata_template", "metadata", "=", "dict", "(", "self", ".", "_mdata", "[", "'deadline'", "]", ")", "metadata", ".", "update", "(", "{", "'exis...
Gets the metadata for the assessment deadline. return: (osid.Metadata) - metadata for the end time *compliance: mandatory -- This method must be implemented.*
[ "Gets", "the", "metadata", "for", "the", "assessment", "deadline", "." ]
python
train
43.909091
PyCQA/pylint
pylint/pyreverse/diagrams.py
https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/pyreverse/diagrams.py#L217-L223
def module(self, name): """return a module by its name, raise KeyError if not found """ for mod in self.modules(): if mod.node.name == name: return mod raise KeyError(name)
[ "def", "module", "(", "self", ",", "name", ")", ":", "for", "mod", "in", "self", ".", "modules", "(", ")", ":", "if", "mod", ".", "node", ".", "name", "==", "name", ":", "return", "mod", "raise", "KeyError", "(", "name", ")" ]
return a module by its name, raise KeyError if not found
[ "return", "a", "module", "by", "its", "name", "raise", "KeyError", "if", "not", "found" ]
python
test
32.285714
Rackspace-DOT/flask_keystone
setup.py
https://github.com/Rackspace-DOT/flask_keystone/blob/6f6d630e9e66a3beca6607b0b786510ec2a79747/setup.py#L120-L144
def read(*filenames, **kwargs): """ Read file contents into string. Used by setup.py to concatenate long_description. :param string filenames: Files to be read and concatenated. :rtype: string """ encoding = kwargs.get('encoding', 'utf-8') sep = kwargs.get('sep', '\n') buf = [] ...
[ "def", "read", "(", "*", "filenames", ",", "*", "*", "kwargs", ")", ":", "encoding", "=", "kwargs", ".", "get", "(", "'encoding'", ",", "'utf-8'", ")", "sep", "=", "kwargs", ".", "get", "(", "'sep'", ",", "'\\n'", ")", "buf", "=", "[", "]", "for"...
Read file contents into string. Used by setup.py to concatenate long_description. :param string filenames: Files to be read and concatenated. :rtype: string
[ "Read", "file", "contents", "into", "string", "." ]
python
train
30.08
sdispater/orator
orator/orm/relations/belongs_to_many.py
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/relations/belongs_to_many.py#L734-L757
def detach(self, ids=None, touch=True): """ Detach models from the relationship. """ if isinstance(ids, orator.orm.model.Model): ids = ids.get_key() if ids is None: ids = [] query = self._new_pivot_query() if not isinstance(ids, list): ...
[ "def", "detach", "(", "self", ",", "ids", "=", "None", ",", "touch", "=", "True", ")", ":", "if", "isinstance", "(", "ids", ",", "orator", ".", "orm", ".", "model", ".", "Model", ")", ":", "ids", "=", "ids", ".", "get_key", "(", ")", "if", "ids...
Detach models from the relationship.
[ "Detach", "models", "from", "the", "relationship", "." ]
python
train
21.166667
google-research/batch-ppo
agents/algorithms/ppo/utility.py
https://github.com/google-research/batch-ppo/blob/3d09705977bae4e7c3eb20339a3b384d2a5531e4/agents/algorithms/ppo/utility.py#L127-L157
def gradient_summaries(grad_vars, groups=None, scope='gradients'): """Create histogram summaries of the gradient. Summaries can be grouped via regexes matching variables names. Args: grad_vars: List of (gradient, variable) tuples as returned by optimizers. groups: Mapping of name to regex for grouping s...
[ "def", "gradient_summaries", "(", "grad_vars", ",", "groups", "=", "None", ",", "scope", "=", "'gradients'", ")", ":", "groups", "=", "groups", "or", "{", "r'all'", ":", "r'.*'", "}", "grouped", "=", "collections", ".", "defaultdict", "(", "list", ")", "...
Create histogram summaries of the gradient. Summaries can be grouped via regexes matching variables names. Args: grad_vars: List of (gradient, variable) tuples as returned by optimizers. groups: Mapping of name to regex for grouping summaries. scope: Name scope for this operation. Returns: Summ...
[ "Create", "histogram", "summaries", "of", "the", "gradient", "." ]
python
train
34.064516
Netflix-Skunkworks/cloudaux
cloudaux/gcp/decorators.py
https://github.com/Netflix-Skunkworks/cloudaux/blob/c4b0870c3ac68b1c69e71d33cf78b6a8bdf437ea/cloudaux/gcp/decorators.py#L100-L141
def iter_project(projects, key_file=None): """ Call decorated function for each item in project list. Note: the function 'decorated' is expected to return a value plus a dictionary of exceptions. If item in list is a dictionary, we look for a 'project' and 'key_file' entry, respectively. If item i...
[ "def", "iter_project", "(", "projects", ",", "key_file", "=", "None", ")", ":", "def", "decorator", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "decorated_function", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "item_list", ...
Call decorated function for each item in project list. Note: the function 'decorated' is expected to return a value plus a dictionary of exceptions. If item in list is a dictionary, we look for a 'project' and 'key_file' entry, respectively. If item in list is of type string_types, we assume it is the pro...
[ "Call", "decorated", "function", "for", "each", "item", "in", "project", "list", "." ]
python
valid
38.904762
awslabs/sockeye
sockeye/training.py
https://github.com/awslabs/sockeye/blob/5d64a1ee1ef3cbba17c6d1d94bc061020c43f6ab/sockeye/training.py#L506-L511
def save(self, fname: str): """ Saves this training state to fname. """ with open(fname, "wb") as fp: pickle.dump(self, fp)
[ "def", "save", "(", "self", ",", "fname", ":", "str", ")", ":", "with", "open", "(", "fname", ",", "\"wb\"", ")", "as", "fp", ":", "pickle", ".", "dump", "(", "self", ",", "fp", ")" ]
Saves this training state to fname.
[ "Saves", "this", "training", "state", "to", "fname", "." ]
python
train
27
adafruit/Adafruit_Python_GPIO
Adafruit_GPIO/GPIO.py
https://github.com/adafruit/Adafruit_Python_GPIO/blob/a92a23d6b5869663b2bc1ccf78bb11585076a9c4/Adafruit_GPIO/GPIO.py#L93-L99
def setup_pins(self, pins): """Setup multiple pins as inputs or outputs at once. Pins should be a dict of pin name to pin type (IN or OUT). """ # General implementation that can be optimized by derived classes. for pin, value in iter(pins.items()): self.setup(pin, va...
[ "def", "setup_pins", "(", "self", ",", "pins", ")", ":", "# General implementation that can be optimized by derived classes.", "for", "pin", ",", "value", "in", "iter", "(", "pins", ".", "items", "(", ")", ")", ":", "self", ".", "setup", "(", "pin", ",", "va...
Setup multiple pins as inputs or outputs at once. Pins should be a dict of pin name to pin type (IN or OUT).
[ "Setup", "multiple", "pins", "as", "inputs", "or", "outputs", "at", "once", ".", "Pins", "should", "be", "a", "dict", "of", "pin", "name", "to", "pin", "type", "(", "IN", "or", "OUT", ")", "." ]
python
valid
45.428571
ttinies/sc2gameMapRepo
sc2maptool/functions.py
https://github.com/ttinies/sc2gameMapRepo/blob/3a215067fae8f86f6a3ffe37272fbd7a5461cfab/sc2maptool/functions.py#L12-L25
def selectMap(name=None, excludeName=False, closestMatch=True, **tags): """select a map by name and/or critiera""" matches = filterMapAttrs(**tags) if not matches: raise c.InvalidMapSelection("could not find any matching maps given criteria: %s"%tags) if name: # if name is specified, consider only the b...
[ "def", "selectMap", "(", "name", "=", "None", ",", "excludeName", "=", "False", ",", "closestMatch", "=", "True", ",", "*", "*", "tags", ")", ":", "matches", "=", "filterMapAttrs", "(", "*", "*", "tags", ")", "if", "not", "matches", ":", "raise", "c"...
select a map by name and/or critiera
[ "select", "a", "map", "by", "name", "and", "/", "or", "critiera" ]
python
train
65.571429
mromanello/hucitlib
knowledge_base/surfext/__init__.py
https://github.com/mromanello/hucitlib/blob/6587d1b04eb7e5b48ad7359be845e5d3b444d6fa/knowledge_base/surfext/__init__.py#L121-L162
def add_abbreviation(self, new_abbreviation): """ Adds a new name variant to an author. :param new_abbreviation: the abbreviation to be added :return: `True` if the abbreviation is added, `False` otherwise (the abbreviation is a duplicate) """ try: assert new...
[ "def", "add_abbreviation", "(", "self", ",", "new_abbreviation", ")", ":", "try", ":", "assert", "new_abbreviation", "not", "in", "self", ".", "get_abbreviations", "(", ")", "except", "Exception", "as", "e", ":", "# TODO: raise a custom exception", "logger", ".", ...
Adds a new name variant to an author. :param new_abbreviation: the abbreviation to be added :return: `True` if the abbreviation is added, `False` otherwise (the abbreviation is a duplicate)
[ "Adds", "a", "new", "name", "variant", "to", "an", "author", "." ]
python
train
52.333333
RedFantom/ttkwidgets
ttkwidgets/timeline.py
https://github.com/RedFantom/ttkwidgets/blob/02150322060f867b6e59a175522ef84b09168019/ttkwidgets/timeline.py#L780-L798
def get_time_string(time, unit): """ Create a properly formatted string given a time and unit :param time: Time to format :type time: float :param unit: Unit to apply format of. Only supports hours ('h') and minutes ('m'). :type unit: str :return: A s...
[ "def", "get_time_string", "(", "time", ",", "unit", ")", ":", "supported_units", "=", "[", "\"h\"", ",", "\"m\"", "]", "if", "unit", "not", "in", "supported_units", ":", "return", "\"{}\"", ".", "format", "(", "round", "(", "time", ",", "2", ")", ")", ...
Create a properly formatted string given a time and unit :param time: Time to format :type time: float :param unit: Unit to apply format of. Only supports hours ('h') and minutes ('m'). :type unit: str :return: A string in format '{whole}:{part}' :rtype: str
[ "Create", "a", "properly", "formatted", "string", "given", "a", "time", "and", "unit" ]
python
train
35.894737
GNS3/gns3-server
gns3server/compute/dynamips/nodes/c7200.py
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/nodes/c7200.py#L209-L229
def set_power_supplies(self, power_supplies): """ Sets the 2 power supplies with 0 = off, 1 = on. :param power_supplies: list of 2 power supplies. Example: [1, 0] = first power supply is on, second is off. """ power_supply_id = 0 for power_supply in power_suppli...
[ "def", "set_power_supplies", "(", "self", ",", "power_supplies", ")", ":", "power_supply_id", "=", "0", "for", "power_supply", "in", "power_supplies", ":", "yield", "from", "self", ".", "_hypervisor", ".", "send", "(", "'c7200 set_power_supply \"{name}\" {power_supply...
Sets the 2 power supplies with 0 = off, 1 = on. :param power_supplies: list of 2 power supplies. Example: [1, 0] = first power supply is on, second is off.
[ "Sets", "the", "2", "power", "supplies", "with", "0", "=", "off", "1", "=", "on", "." ]
python
train
64.761905
F5Networks/f5-common-python
f5-sdk-dist/build_pkgs.py
https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5-sdk-dist/build_pkgs.py#L351-L366
def store_json(obj, destination): """store_json Takes in a json-portable object and a filesystem-based destination and stores the json-portable object as JSON into the filesystem-based destination. This is blind, dumb, and stupid; thus, it can fail if the object is more complex than simple dict, list, int, str, e...
[ "def", "store_json", "(", "obj", ",", "destination", ")", ":", "with", "open", "(", "destination", ",", "'r+'", ")", "as", "FH", ":", "fcntl", ".", "lockf", "(", "FH", ",", "fcntl", ".", "LOCK_EX", ")", "json_in", "=", "json", ".", "loads", "(", "F...
store_json Takes in a json-portable object and a filesystem-based destination and stores the json-portable object as JSON into the filesystem-based destination. This is blind, dumb, and stupid; thus, it can fail if the object is more complex than simple dict, list, int, str, etc. type object structures.
[ "store_json" ]
python
train
41.25
tomi77/python-t77-date
t77_date/datetime.py
https://github.com/tomi77/python-t77-date/blob/b4b12ce6a02884fb62460f6b9068e7fa28979fce/t77_date/datetime.py#L74-L87
def set_next_week_day(val, week_day, iso=False): """ Set week day. New date will be greater or equal than input date. :param val: datetime or date :type val: datetime.datetime | datetime.date :param week_day: Week day to set :type week_day: int :param iso: week_day in ISO format, or not ...
[ "def", "set_next_week_day", "(", "val", ",", "week_day", ",", "iso", "=", "False", ")", ":", "return", "_set_week_day", "(", "val", ",", "week_day", ",", "val", ".", "isoweekday", "(", ")", "if", "iso", "else", "val", ".", "weekday", "(", ")", ",", "...
Set week day. New date will be greater or equal than input date. :param val: datetime or date :type val: datetime.datetime | datetime.date :param week_day: Week day to set :type week_day: int :param iso: week_day in ISO format, or not :type iso: bool :return: datetime.datetime | datetime...
[ "Set", "week", "day", ".", "New", "date", "will", "be", "greater", "or", "equal", "than", "input", "date", ".", ":", "param", "val", ":", "datetime", "or", "date", ":", "type", "val", ":", "datetime", ".", "datetime", "|", "datetime", ".", "date", ":...
python
train
35.571429
edx/edx-enterprise
enterprise/api_client/lms.py
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api_client/lms.py#L377-L398
def _get_results(self, identity_provider, param_name, param_value, result_field_name): """ Calls the third party auth api endpoint to get the mapping between usernames and remote ids. """ try: kwargs = {param_name: param_value} returned = self.client.providers(ide...
[ "def", "_get_results", "(", "self", ",", "identity_provider", ",", "param_name", ",", "param_value", ",", "result_field_name", ")", ":", "try", ":", "kwargs", "=", "{", "param_name", ":", "param_value", "}", "returned", "=", "self", ".", "client", ".", "prov...
Calls the third party auth api endpoint to get the mapping between usernames and remote ids.
[ "Calls", "the", "third", "party", "auth", "api", "endpoint", "to", "get", "the", "mapping", "between", "usernames", "and", "remote", "ids", "." ]
python
valid
40.5
clalancette/pycdlib
pycdlib/dr.py
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/dr.py#L1077-L1093
def set_data_location(self, current_extent, tag_location): # pylint: disable=unused-argument # type: (int, int) -> None ''' A method to set the new extent location that the data for this Directory Record should live at. Parameters: current_extent - The new extent. ...
[ "def", "set_data_location", "(", "self", ",", "current_extent", ",", "tag_location", ")", ":", "# pylint: disable=unused-argument", "# type: (int, int) -> None", "if", "not", "self", ".", "_initialized", ":", "raise", "pycdlibexception", ".", "PyCdlibInternalError", "(", ...
A method to set the new extent location that the data for this Directory Record should live at. Parameters: current_extent - The new extent. Returns: Nothing.
[ "A", "method", "to", "set", "the", "new", "extent", "location", "that", "the", "data", "for", "this", "Directory", "Record", "should", "live", "at", "." ]
python
train
36.176471
utek/pyseaweed
pyseaweed/weed.py
https://github.com/utek/pyseaweed/blob/218049329885425a2b8370157fa44952e64516be/pyseaweed/weed.py#L107-L124
def get_file_size(self, fid): """ Gets size of uploaded file Or None if file doesn't exist. Args: **fid**: File identifier <volume_id>,<file_name_hash> Returns: Int or None """ url = self.get_file_url(fid) res = self.conn.head(url...
[ "def", "get_file_size", "(", "self", ",", "fid", ")", ":", "url", "=", "self", ".", "get_file_url", "(", "fid", ")", "res", "=", "self", ".", "conn", ".", "head", "(", "url", ")", "if", "res", "is", "not", "None", ":", "size", "=", "res", ".", ...
Gets size of uploaded file Or None if file doesn't exist. Args: **fid**: File identifier <volume_id>,<file_name_hash> Returns: Int or None
[ "Gets", "size", "of", "uploaded", "file", "Or", "None", "if", "file", "doesn", "t", "exist", "." ]
python
train
26.5
collectiveacuity/jsonModel
jsonmodel/validators.py
https://github.com/collectiveacuity/jsonModel/blob/1ea64c36d78add3faa7b85ff82c5ec685458c940/jsonmodel/validators.py#L1414-L1468
def _walk(self, path_to_root, record_dict): ''' a helper method for finding the record endpoint from a path to root :param path_to_root: string with dot path to root from :param record_dict: :return: list, dict, string, number, or boolean at path to root ''' # ...
[ "def", "_walk", "(", "self", ",", "path_to_root", ",", "record_dict", ")", ":", "# split path to root into segments", "item_pattern", "=", "re", ".", "compile", "(", "'\\d+\\\\]'", ")", "dot_pattern", "=", "re", ".", "compile", "(", "'\\\\.|\\\\['", ")", "path_s...
a helper method for finding the record endpoint from a path to root :param path_to_root: string with dot path to root from :param record_dict: :return: list, dict, string, number, or boolean at path to root
[ "a", "helper", "method", "for", "finding", "the", "record", "endpoint", "from", "a", "path", "to", "root" ]
python
train
40.872727
secynic/ipwhois
ipwhois/net.py
https://github.com/secynic/ipwhois/blob/b5d634d36b0b942d538d38d77b3bdcd815f155a0/ipwhois/net.py#L672-L793
def get_http_json(self, url=None, retry_count=3, rate_limit_timeout=120, headers=None): """ The function for retrieving a json result via HTTP. Args: url (:obj:`str`): The URL to retrieve (required). retry_count (:obj:`int`): The number of times to ...
[ "def", "get_http_json", "(", "self", ",", "url", "=", "None", ",", "retry_count", "=", "3", ",", "rate_limit_timeout", "=", "120", ",", "headers", "=", "None", ")", ":", "if", "headers", "is", "None", ":", "headers", "=", "{", "'Accept'", ":", "'applic...
The function for retrieving a json result via HTTP. Args: url (:obj:`str`): The URL to retrieve (required). retry_count (:obj:`int`): The number of times to retry in case socket errors, timeouts, connection resets, etc. are encountered. Defaults to 3. ...
[ "The", "function", "for", "retrieving", "a", "json", "result", "via", "HTTP", "." ]
python
train
37.852459